mirror of https://github.com/GNOME/gimp.git
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".
This commit is contained in:
parent
43136b7cfb
commit
ee6ad0e212
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
||||||
|
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>
|
Wed Jan 5 13:51:19 CET 2000 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/main.c: removed i18n tags from error messages in the
|
* app/main.c: removed i18n tags from error messages in the
|
||||||
|
|
330
app/gimphelp.c
330
app/gimphelp.c
|
@ -24,7 +24,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "gimphelp.h"
|
#include "gimphelp.h"
|
||||||
|
@ -38,56 +37,16 @@
|
||||||
#define DEBUG_HELP
|
#define DEBUG_HELP
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
static gint gimp_idle_help (gpointer help_data);
|
||||||
static void gimp_help_internal (gchar *current_locale,
|
static void gimp_help_internal (gchar *current_locale,
|
||||||
gchar *help_data);
|
gchar *help_data);
|
||||||
static void gimp_help_netscape (gchar *current_locale,
|
static void gimp_help_netscape (gchar *current_locale,
|
||||||
gchar *help_data);
|
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 */
|
/* 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 */
|
/* The standard help function */
|
||||||
void
|
void
|
||||||
gimp_standard_help_func (gchar *help_data)
|
gimp_standard_help_func (gchar *help_data)
|
||||||
|
@ -95,137 +54,55 @@ gimp_standard_help_func (gchar *help_data)
|
||||||
gimp_help (help_data);
|
gimp_help (help_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gimp_help_connect_help_accel (GtkWidget *widget,
|
|
||||||
GimpHelpFunc help_func,
|
|
||||||
gchar *help_data)
|
|
||||||
{
|
|
||||||
GtkAccelGroup *accel_group;
|
|
||||||
|
|
||||||
if (!help_func)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* set up the help signals and tips query widget */
|
|
||||||
if (!tips_query)
|
|
||||||
{
|
|
||||||
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");
|
|
||||||
|
|
||||||
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the main help function */
|
/* the main help function */
|
||||||
void
|
void
|
||||||
gimp_help (gchar *help_data)
|
gimp_help (gchar *help_data)
|
||||||
{
|
{
|
||||||
static gchar *current_locale = "C";
|
if (use_help)
|
||||||
|
|
||||||
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
|
|
||||||
help_data = "welcome.html";
|
|
||||||
|
|
||||||
#ifdef DEBUG_HELP
|
|
||||||
g_print ("Help Page: %s\n", help_data);
|
|
||||||
#endif /* DEBUG_HELP */
|
|
||||||
|
|
||||||
switch (help_browser)
|
|
||||||
{
|
{
|
||||||
case HELP_BROWSER_GIMP:
|
if (help_data)
|
||||||
gimp_help_internal (current_locale, help_data);
|
help_data = g_strdup (help_data);
|
||||||
break;
|
|
||||||
|
|
||||||
case HELP_BROWSER_NETSCAPE:
|
gtk_idle_add ((GtkFunction) gimp_idle_help, (gpointer) help_data);
|
||||||
gimp_help_netscape (current_locale, help_data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gimp_context_help (void)
|
|
||||||
{
|
|
||||||
if (tips_query)
|
|
||||||
gimp_help_tips_query_start (NULL, tips_query);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************/
|
/*********************/
|
||||||
/* local functions */
|
/* local functions */
|
||||||
/*********************/
|
/*********************/
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gimp_idle_help (gpointer help_data)
|
||||||
|
{
|
||||||
|
static gchar *current_locale = "C";
|
||||||
|
|
||||||
|
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
|
||||||
|
help_data = g_strdup ("welcome.html");
|
||||||
|
|
||||||
|
#ifdef DEBUG_HELP
|
||||||
|
g_print ("Help Page: %s\n", (gchar *) help_data);
|
||||||
|
#endif /* DEBUG_HELP */
|
||||||
|
|
||||||
|
switch (help_browser)
|
||||||
|
{
|
||||||
|
case HELP_BROWSER_GIMP:
|
||||||
|
gimp_help_internal (current_locale, (gchar *) help_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HELP_BROWSER_NETSCAPE:
|
||||||
|
gimp_help_netscape (current_locale, (gchar *) help_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (help_data)
|
||||||
|
g_free (help_data);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_help_internal (gchar *current_locale,
|
gimp_help_internal (gchar *current_locale,
|
||||||
gchar *help_data)
|
gchar *help_data)
|
||||||
|
@ -304,136 +181,3 @@ gimp_help_netscape (gchar *current_locale,
|
||||||
|
|
||||||
g_free (url);
|
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 <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimp/gimphelpui.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HELP_BROWSER_GIMP,
|
HELP_BROWSER_GIMP,
|
||||||
HELP_BROWSER_NETSCAPE
|
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 */
|
/* the standard help function */
|
||||||
void gimp_standard_help_func (gchar *help_data);
|
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);
|
|
||||||
|
|
||||||
/* the main help function */
|
/* the main help function */
|
||||||
void gimp_help (gchar *help_data);
|
void gimp_help (gchar *help_data);
|
||||||
|
|
||||||
/* activate the context help inspector */
|
|
||||||
void gimp_context_help (void);
|
|
||||||
|
|
||||||
#endif /* __GIMP_HELP_H__ */
|
#endif /* __GIMP_HELP_H__ */
|
||||||
|
|
231
app/gimpui.c
231
app/gimpui.c
|
@ -30,237 +30,6 @@
|
||||||
* Widget Constructors...
|
* 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 *
|
GtkWidget *
|
||||||
gimp_option_menu_new (GtkSignalFunc menu_item_callback,
|
gimp_option_menu_new (GtkSignalFunc menu_item_callback,
|
||||||
gpointer initial, /* user_data */
|
gpointer initial, /* user_data */
|
||||||
|
|
50
app/gimpui.h
50
app/gimpui.h
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "gimphelp.h"
|
#include "gimphelp.h"
|
||||||
|
|
||||||
|
#include "libgimp/gimpdialog.h"
|
||||||
#include "libgimp/gimpunit.h"
|
#include "libgimp/gimpunit.h"
|
||||||
|
|
||||||
/* typedefs */
|
/* typedefs */
|
||||||
|
@ -33,55 +34,6 @@ typedef void (* GimpQueryFunc) (GtkWidget *, gpointer, gpointer);
|
||||||
|
|
||||||
/* widget constructors */
|
/* 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,
|
GtkWidget * gimp_option_menu_new (GtkSignalFunc menu_item_callback,
|
||||||
gpointer initial, /* user_data */
|
gpointer initial, /* user_data */
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "gimphelp.h"
|
#include "gimphelp.h"
|
||||||
|
@ -38,56 +37,16 @@
|
||||||
#define DEBUG_HELP
|
#define DEBUG_HELP
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
static gint gimp_idle_help (gpointer help_data);
|
||||||
static void gimp_help_internal (gchar *current_locale,
|
static void gimp_help_internal (gchar *current_locale,
|
||||||
gchar *help_data);
|
gchar *help_data);
|
||||||
static void gimp_help_netscape (gchar *current_locale,
|
static void gimp_help_netscape (gchar *current_locale,
|
||||||
gchar *help_data);
|
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 */
|
/* 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 */
|
/* The standard help function */
|
||||||
void
|
void
|
||||||
gimp_standard_help_func (gchar *help_data)
|
gimp_standard_help_func (gchar *help_data)
|
||||||
|
@ -95,137 +54,55 @@ gimp_standard_help_func (gchar *help_data)
|
||||||
gimp_help (help_data);
|
gimp_help (help_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gimp_help_connect_help_accel (GtkWidget *widget,
|
|
||||||
GimpHelpFunc help_func,
|
|
||||||
gchar *help_data)
|
|
||||||
{
|
|
||||||
GtkAccelGroup *accel_group;
|
|
||||||
|
|
||||||
if (!help_func)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* set up the help signals and tips query widget */
|
|
||||||
if (!tips_query)
|
|
||||||
{
|
|
||||||
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");
|
|
||||||
|
|
||||||
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the main help function */
|
/* the main help function */
|
||||||
void
|
void
|
||||||
gimp_help (gchar *help_data)
|
gimp_help (gchar *help_data)
|
||||||
{
|
{
|
||||||
static gchar *current_locale = "C";
|
if (use_help)
|
||||||
|
|
||||||
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
|
|
||||||
help_data = "welcome.html";
|
|
||||||
|
|
||||||
#ifdef DEBUG_HELP
|
|
||||||
g_print ("Help Page: %s\n", help_data);
|
|
||||||
#endif /* DEBUG_HELP */
|
|
||||||
|
|
||||||
switch (help_browser)
|
|
||||||
{
|
{
|
||||||
case HELP_BROWSER_GIMP:
|
if (help_data)
|
||||||
gimp_help_internal (current_locale, help_data);
|
help_data = g_strdup (help_data);
|
||||||
break;
|
|
||||||
|
|
||||||
case HELP_BROWSER_NETSCAPE:
|
gtk_idle_add ((GtkFunction) gimp_idle_help, (gpointer) help_data);
|
||||||
gimp_help_netscape (current_locale, help_data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gimp_context_help (void)
|
|
||||||
{
|
|
||||||
if (tips_query)
|
|
||||||
gimp_help_tips_query_start (NULL, tips_query);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************/
|
/*********************/
|
||||||
/* local functions */
|
/* local functions */
|
||||||
/*********************/
|
/*********************/
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gimp_idle_help (gpointer help_data)
|
||||||
|
{
|
||||||
|
static gchar *current_locale = "C";
|
||||||
|
|
||||||
|
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
|
||||||
|
help_data = g_strdup ("welcome.html");
|
||||||
|
|
||||||
|
#ifdef DEBUG_HELP
|
||||||
|
g_print ("Help Page: %s\n", (gchar *) help_data);
|
||||||
|
#endif /* DEBUG_HELP */
|
||||||
|
|
||||||
|
switch (help_browser)
|
||||||
|
{
|
||||||
|
case HELP_BROWSER_GIMP:
|
||||||
|
gimp_help_internal (current_locale, (gchar *) help_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HELP_BROWSER_NETSCAPE:
|
||||||
|
gimp_help_netscape (current_locale, (gchar *) help_data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (help_data)
|
||||||
|
g_free (help_data);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_help_internal (gchar *current_locale,
|
gimp_help_internal (gchar *current_locale,
|
||||||
gchar *help_data)
|
gchar *help_data)
|
||||||
|
@ -304,136 +181,3 @@ gimp_help_netscape (gchar *current_locale,
|
||||||
|
|
||||||
g_free (url);
|
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 <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimp/gimphelpui.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HELP_BROWSER_GIMP,
|
HELP_BROWSER_GIMP,
|
||||||
HELP_BROWSER_NETSCAPE
|
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 */
|
/* the standard help function */
|
||||||
void gimp_standard_help_func (gchar *help_data);
|
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);
|
|
||||||
|
|
||||||
/* the main help function */
|
/* the main help function */
|
||||||
void gimp_help (gchar *help_data);
|
void gimp_help (gchar *help_data);
|
||||||
|
|
||||||
/* activate the context help inspector */
|
|
||||||
void gimp_context_help (void);
|
|
||||||
|
|
||||||
#endif /* __GIMP_HELP_H__ */
|
#endif /* __GIMP_HELP_H__ */
|
||||||
|
|
|
@ -30,237 +30,6 @@
|
||||||
* Widget Constructors...
|
* 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 *
|
GtkWidget *
|
||||||
gimp_option_menu_new (GtkSignalFunc menu_item_callback,
|
gimp_option_menu_new (GtkSignalFunc menu_item_callback,
|
||||||
gpointer initial, /* user_data */
|
gpointer initial, /* user_data */
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "gimphelp.h"
|
#include "gimphelp.h"
|
||||||
|
|
||||||
|
#include "libgimp/gimpdialog.h"
|
||||||
#include "libgimp/gimpunit.h"
|
#include "libgimp/gimpunit.h"
|
||||||
|
|
||||||
/* typedefs */
|
/* typedefs */
|
||||||
|
@ -33,55 +34,6 @@ typedef void (* GimpQueryFunc) (GtkWidget *, gpointer, gpointer);
|
||||||
|
|
||||||
/* widget constructors */
|
/* 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,
|
GtkWidget * gimp_option_menu_new (GtkSignalFunc menu_item_callback,
|
||||||
gpointer initial, /* user_data */
|
gpointer initial, /* user_data */
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,12 @@ libgimpi_a_SOURCES = \
|
||||||
gimpchainbutton.h \
|
gimpchainbutton.h \
|
||||||
gimpcolorbutton.c \
|
gimpcolorbutton.c \
|
||||||
gimpcolorspace.c \
|
gimpcolorspace.c \
|
||||||
|
gimpdialog.c \
|
||||||
|
gimpdialog.h \
|
||||||
gimpfileselection.c \
|
gimpfileselection.c \
|
||||||
gimpfileselection.h \
|
gimpfileselection.h \
|
||||||
|
gimphelpui.c \
|
||||||
|
gimphelpui.h \
|
||||||
gimpmatrix.c \
|
gimpmatrix.c \
|
||||||
gimpmatrix.h \
|
gimpmatrix.h \
|
||||||
gimppatheditor.c \
|
gimppatheditor.c \
|
||||||
|
@ -73,6 +77,7 @@ libgimp_la_SOURCES = \
|
||||||
gimpdrawable.c \
|
gimpdrawable.c \
|
||||||
gimpenv.c \
|
gimpenv.c \
|
||||||
gimpgradient.c \
|
gimpgradient.c \
|
||||||
|
gimphelp.c \
|
||||||
gimpimage.c \
|
gimpimage.c \
|
||||||
gimplayer.c \
|
gimplayer.c \
|
||||||
gimpmatrix.c \
|
gimpmatrix.c \
|
||||||
|
@ -103,10 +108,12 @@ libgimpui_la_SOURCES = \
|
||||||
gimpbrushmenu.c \
|
gimpbrushmenu.c \
|
||||||
gimpgradientmenu.c \
|
gimpgradientmenu.c \
|
||||||
gimppatternmenu.c \
|
gimppatternmenu.c \
|
||||||
gimpexport.c \
|
|
||||||
gimpchainbutton.c \
|
gimpchainbutton.c \
|
||||||
gimpcolorbutton.c \
|
gimpcolorbutton.c \
|
||||||
|
gimpdialog.c \
|
||||||
|
gimpexport.c \
|
||||||
gimpfileselection.c \
|
gimpfileselection.c \
|
||||||
|
gimphelpui.c \
|
||||||
gimppatheditor.c \
|
gimppatheditor.c \
|
||||||
gimpsizeentry.c \
|
gimpsizeentry.c \
|
||||||
gimpunitmenu.c
|
gimpunitmenu.c
|
||||||
|
@ -119,11 +126,13 @@ gimpinclude_HEADERS = \
|
||||||
gimpcolorbutton.h \
|
gimpcolorbutton.h \
|
||||||
gimpcolorspace.h \
|
gimpcolorspace.h \
|
||||||
gimpcompat.h \
|
gimpcompat.h \
|
||||||
|
gimpdialog.h \
|
||||||
gimpenums.h \
|
gimpenums.h \
|
||||||
gimpenv.h \
|
gimpenv.h \
|
||||||
gimpexport.h \
|
gimpexport.h \
|
||||||
gimpfeatures.h \
|
gimpfeatures.h \
|
||||||
gimpfileselection.h \
|
gimpfileselection.h \
|
||||||
|
gimphelpui.h \
|
||||||
gimplimits.h \
|
gimplimits.h \
|
||||||
gimpmath.h \
|
gimpmath.h \
|
||||||
gimpmatrix.h \
|
gimpmatrix.h \
|
||||||
|
|
|
@ -872,6 +872,14 @@ void gimp_attach_new_parasite (const char *name,
|
||||||
const void *data);
|
const void *data);
|
||||||
void gimp_parasite_detach (const char *name);
|
void gimp_parasite_detach (const char *name);
|
||||||
|
|
||||||
|
/****************************************
|
||||||
|
* Help *
|
||||||
|
****************************************/
|
||||||
|
|
||||||
|
void gimp_standard_help_func (gchar *help_data);
|
||||||
|
void gimp_plugin_help_func (gchar *help_data);
|
||||||
|
void gimp_help (gchar *help_data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpdialog.c
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "libgimp/gimpdialog.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "pixmaps/wilber.xpm"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
gimp_dialog_set_icon (dialog);
|
||||||
|
|
||||||
|
/* connect the "F1" help key */
|
||||||
|
if (help_func)
|
||||||
|
gimp_help_connect_help_accel (dialog, help_func, help_data);
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_dialog_set_icon (GtkWidget *dialog)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dialog);
|
||||||
|
g_return_if_fail (GTK_IS_WINDOW (dialog));
|
||||||
|
|
||||||
|
if (GTK_WIDGET_REALIZED (dialog))
|
||||||
|
gimp_dialog_realize_callback (dialog, NULL);
|
||||||
|
else
|
||||||
|
gtk_signal_connect (GTK_OBJECT (dialog), "realize",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_dialog_realize_callback),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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*);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpdialog.h
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef __GIMP_DIALOG_H__
|
||||||
|
#define __GIMP_DIALOG_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimp/gimphelpui.h"
|
||||||
|
#include "libgimp/gimpunit.h"
|
||||||
|
|
||||||
|
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_set_icon (GtkWidget *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,
|
||||||
|
*/
|
||||||
|
|
||||||
|
...);
|
||||||
|
|
||||||
|
void gimp_dialog_create_action_areav (GtkDialog *dialog,
|
||||||
|
va_list args);
|
||||||
|
|
||||||
|
#endif /* __GIMP_DIALOG_H__ */
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimphelp.c
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "gimp.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_standard_help_func (gchar *help_data)
|
||||||
|
{
|
||||||
|
gimp_help (help_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_plugin_help_func (gchar *help_data)
|
||||||
|
{
|
||||||
|
gchar *help_page;
|
||||||
|
|
||||||
|
help_page = g_strdup_printf ("filters/%s.html", help_data);
|
||||||
|
|
||||||
|
gimp_help (help_data);
|
||||||
|
|
||||||
|
g_free (help_page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_help (gchar *help_data)
|
||||||
|
{
|
||||||
|
GParam *return_vals;
|
||||||
|
int nreturn_vals;
|
||||||
|
|
||||||
|
return_vals = gimp_run_procedure ("gimp_help",
|
||||||
|
&nreturn_vals,
|
||||||
|
PARAM_STRING, help_data,
|
||||||
|
PARAM_END);
|
||||||
|
|
||||||
|
gimp_destroy_params (return_vals, nreturn_vals);
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimphelp.c
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "gimp.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_standard_help_func (gchar *help_data)
|
||||||
|
{
|
||||||
|
gimp_help (help_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_plugin_help_func (gchar *help_data)
|
||||||
|
{
|
||||||
|
gchar *help_page;
|
||||||
|
|
||||||
|
help_page = g_strdup_printf ("filters/%s.html", help_data);
|
||||||
|
|
||||||
|
gimp_help (help_data);
|
||||||
|
|
||||||
|
g_free (help_page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_help (gchar *help_data)
|
||||||
|
{
|
||||||
|
GParam *return_vals;
|
||||||
|
int nreturn_vals;
|
||||||
|
|
||||||
|
return_vals = gimp_run_procedure ("gimp_help",
|
||||||
|
&nreturn_vals,
|
||||||
|
PARAM_STRING, help_data,
|
||||||
|
PARAM_END);
|
||||||
|
|
||||||
|
gimp_destroy_params (return_vals, nreturn_vals);
|
||||||
|
}
|
|
@ -0,0 +1,308 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimphelpui.c
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "gimphelpui.h"
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_help_connect_help_accel (GtkWidget *widget,
|
||||||
|
GimpHelpFunc help_func,
|
||||||
|
gchar *help_data)
|
||||||
|
{
|
||||||
|
GtkAccelGroup *accel_group;
|
||||||
|
|
||||||
|
if (!help_func)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* set up the help signals and tips query widget */
|
||||||
|
if (!tips_query)
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
|
||||||
|
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_context_help (void)
|
||||||
|
{
|
||||||
|
if (tips_query)
|
||||||
|
gimp_help_tips_query_start (NULL, tips_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************/
|
||||||
|
/* local functions */
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
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)
|
||||||
|
(* 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 (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 (! GTK_TIPS_QUERY (tips_query)->in_query)
|
||||||
|
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_start, tips_query);
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimphelpui.h
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef __GIMP_HELP_UI_H__
|
||||||
|
#define __GIMP_HELP_UI_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* activate the context help inspector */
|
||||||
|
void gimp_context_help (void);
|
||||||
|
|
||||||
|
#endif /* __GIMP_HELP_UI_H__ */
|
|
@ -19,12 +19,14 @@
|
||||||
#ifndef __GIMP_UI_H__
|
#ifndef __GIMP_UI_H__
|
||||||
#define __GIMP_UI_H__
|
#define __GIMP_UI_H__
|
||||||
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "libgimp/gimpchainbutton.h"
|
#include "libgimp/gimpchainbutton.h"
|
||||||
#include "libgimp/gimpcolorbutton.h"
|
#include "libgimp/gimpcolorbutton.h"
|
||||||
|
#include "libgimp/gimpdialog.h"
|
||||||
#include "libgimp/gimpexport.h"
|
#include "libgimp/gimpexport.h"
|
||||||
#include "libgimp/gimpfileselection.h"
|
#include "libgimp/gimpfileselection.h"
|
||||||
|
#include "libgimp/gimphelpui.h"
|
||||||
#include "libgimp/gimpmenu.h"
|
#include "libgimp/gimpmenu.h"
|
||||||
#include "libgimp/gimppatheditor.h"
|
#include "libgimp/gimppatheditor.h"
|
||||||
#include "libgimp/gimpsizeentry.h"
|
#include "libgimp/gimpsizeentry.h"
|
||||||
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpdialog.c
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "libgimp/gimpdialog.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "pixmaps/wilber.xpm"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
gimp_dialog_set_icon (dialog);
|
||||||
|
|
||||||
|
/* connect the "F1" help key */
|
||||||
|
if (help_func)
|
||||||
|
gimp_help_connect_help_accel (dialog, help_func, help_data);
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_dialog_set_icon (GtkWidget *dialog)
|
||||||
|
{
|
||||||
|
g_return_if_fail (dialog);
|
||||||
|
g_return_if_fail (GTK_IS_WINDOW (dialog));
|
||||||
|
|
||||||
|
if (GTK_WIDGET_REALIZED (dialog))
|
||||||
|
gimp_dialog_realize_callback (dialog, NULL);
|
||||||
|
else
|
||||||
|
gtk_signal_connect (GTK_OBJECT (dialog), "realize",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_dialog_realize_callback),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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*);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpdialog.h
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef __GIMP_DIALOG_H__
|
||||||
|
#define __GIMP_DIALOG_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimp/gimphelpui.h"
|
||||||
|
#include "libgimp/gimpunit.h"
|
||||||
|
|
||||||
|
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_set_icon (GtkWidget *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,
|
||||||
|
*/
|
||||||
|
|
||||||
|
...);
|
||||||
|
|
||||||
|
void gimp_dialog_create_action_areav (GtkDialog *dialog,
|
||||||
|
va_list args);
|
||||||
|
|
||||||
|
#endif /* __GIMP_DIALOG_H__ */
|
|
@ -0,0 +1,308 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimphelpui.c
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "gimphelpui.h"
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_help_connect_help_accel (GtkWidget *widget,
|
||||||
|
GimpHelpFunc help_func,
|
||||||
|
gchar *help_data)
|
||||||
|
{
|
||||||
|
GtkAccelGroup *accel_group;
|
||||||
|
|
||||||
|
if (!help_func)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* set up the help signals and tips query widget */
|
||||||
|
if (!tips_query)
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
|
||||||
|
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_context_help (void)
|
||||||
|
{
|
||||||
|
if (tips_query)
|
||||||
|
gimp_help_tips_query_start (NULL, tips_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************/
|
||||||
|
/* local functions */
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
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)
|
||||||
|
(* 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 (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 (! GTK_TIPS_QUERY (tips_query)->in_query)
|
||||||
|
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_start, tips_query);
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* LIBGIMP - The GIMP Library
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimphelpui.h
|
||||||
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef __GIMP_HELP_UI_H__
|
||||||
|
#define __GIMP_HELP_UI_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* activate the context help inspector */
|
||||||
|
void gimp_context_help (void);
|
||||||
|
|
||||||
|
#endif /* __GIMP_HELP_UI_H__ */
|
|
@ -358,6 +358,7 @@ static void
|
||||||
close_callback (GtkWidget *widget,
|
close_callback (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (data));
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,6 +386,7 @@ ok_callback (GtkWidget *widget,
|
||||||
grid_cfg.ioffset = (int)(gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2) + 0.5);
|
grid_cfg.ioffset = (int)(gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2) + 0.5);
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (data));
|
gtk_widget_destroy (GTK_WIDGET (data));
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -451,7 +453,6 @@ dialog (gint32 image_ID,
|
||||||
{
|
{
|
||||||
GtkWidget *dlg;
|
GtkWidget *dlg;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GtkWidget *hbbox;
|
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *width;
|
GtkWidget *width;
|
||||||
GtkWidget *space;
|
GtkWidget *space;
|
||||||
|
@ -470,42 +471,23 @@ dialog (gint32 image_ID,
|
||||||
argv[0] = g_strdup ("grid");
|
argv[0] = g_strdup ("grid");
|
||||||
|
|
||||||
gtk_init (&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
gtk_rc_parse(gimp_gtkrc());
|
gtk_rc_parse (gimp_gtkrc ());
|
||||||
|
|
||||||
dlg = gtk_dialog_new ();
|
dlg = gimp_dialog_new (_("Grid"), "grid",
|
||||||
gtk_window_set_title (GTK_WINDOW (dlg), _("Grid"));
|
gimp_plugin_help_func, argv[0],
|
||||||
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
|
GTK_WIN_POS_MOUSE,
|
||||||
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
|
FALSE, TRUE, FALSE,
|
||||||
(GtkSignalFunc) close_callback, NULL);
|
|
||||||
|
_("OK"), ok_callback,
|
||||||
|
NULL, NULL, TRUE, FALSE,
|
||||||
|
_("Cancel"), close_callback,
|
||||||
|
NULL, NULL, FALSE, TRUE,
|
||||||
|
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* Get the image resolution and unit */
|
/* Get the image resolution and unit */
|
||||||
gimp_image_get_resolution (image_ID, &xres, &yres);
|
gimp_image_get_resolution (image_ID, &xres, &yres);
|
||||||
unit = gimp_image_get_unit (image_ID);
|
unit = gimp_image_get_unit (image_ID);
|
||||||
|
|
||||||
/* Action area */
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 2);
|
|
||||||
gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dlg)->action_area), FALSE);
|
|
||||||
hbbox = gtk_hbutton_box_new ();
|
|
||||||
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
|
|
||||||
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dlg)->action_area), hbbox, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (hbbox);
|
|
||||||
|
|
||||||
button = gtk_button_new_with_label (_("OK"));
|
|
||||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
||||||
(GtkSignalFunc) ok_callback,
|
|
||||||
dlg);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_grab_default (button);
|
|
||||||
gtk_widget_show (button);
|
|
||||||
|
|
||||||
button = gtk_button_new_with_label (_("Cancel"));
|
|
||||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
|
||||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
|
||||||
(GtkSignalFunc) gtk_widget_destroy,
|
|
||||||
GTK_OBJECT (dlg));
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (button);
|
|
||||||
|
|
||||||
/* The width entries */
|
/* The width entries */
|
||||||
hbox = gtk_hbox_new (FALSE, 0);
|
hbox = gtk_hbox_new (FALSE, 0);
|
||||||
|
@ -736,5 +718,3 @@ dialog (gint32 image_ID,
|
||||||
|
|
||||||
return run_flag;
|
return run_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue