Commit 002aa905 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/Makefile.am app/gimphelp.[ch] new files

1999-09-27  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/gimphelp.[ch]
	* app/gimpui.[ch]: new files

	* app/interface.[ch]
	* app/preferences_dialog.[ch]

	The GIMP Help System part 1: Press "F1" in any dialog to pop up
	the help page for this dialog.

	Moved the widget constructors from preferences_dialog.[ch] and the
	query boxes from interface.[ch] to gimpui.[ch].

	The dialog constructors take a help_func and a help_data
	parameter and install the "F1" accelerator which emits the new
	"help" signal.

	The "help" signal callback calls help_func(help_data) which finally
	has to call gimp_help() which in turn invokes the help browser.

	Still have to find a proper way to (1) prevent "F1" being assigned
	to some menu item and (2) to catch "F1" while browsing the menu
	trees in order to pop up the help for the selected item.

	* app/menus.c: a <Toolbox>/File/Help... menu item.
	* app/commands.[ch]: a command callback for the "Help..." menu item.

	* app/gimprc.[ch]: new boolean gimprc variable "use_help".

	* app/info_dialog.[ch]: pass a help function and data to the info
	dialog constructor.

	* app/tools.[ch]: store the tools help page names in the tool info
	structure. Export a special tools_help_func() which shows the help
	page for the active tool.

	* app/[all files calling a dialog constructor]: pass the dialog's
	help page to the constructor.

	Most dialogs are now created by gimp_dialog_new() which also sets
	up the action_area and the WM delete event callback, so I removed
	the resp. code from these files.

	Fixed some minor bugs and did some other stuff but didn't change
	any logic except dialog creation.

	* plug-ins/helpbrowser/helpbrowser.c: don't try to call a running
	help browser and don't install any menu path (all done in
	app/gimphelp.[ch] now).
parent 46a53f0a
1999-09-27 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/gimphelp.[ch]
* app/gimpui.[ch]: new files
* app/interface.[ch]
* app/preferences_dialog.[ch]
The GIMP Help System part 1: Press "F1" in any dialog to pop up
the help page for this dialog.
Moved the widget constructors from preferences_dialog.[ch] and the
query boxes from interface.[ch] to gimpui.[ch].
The dialog constructors take a help_func and a help_data
parameter and install the "F1" accelerator which emits the new
"help" signal.
The "help" signal callback calls help_func(help_data) which finally
has to call gimp_help() which in turn invokes the help browser.
Still have to find a proper way to (1) prevent "F1" being assigned
to some menu item and (2) to catch "F1" while browsing the menu
trees in order to pop up the help for the selected item.
* app/menus.c: a <Toolbox>/File/Help... menu item.
* app/commands.[ch]: a command callback for the "Help..." menu item.
* app/gimprc.[ch]: new boolean gimprc variable "use_help".
* app/info_dialog.[ch]: pass a help function and data to the info
dialog constructor.
* app/tools.[ch]: store the tools help page names in the tool info
structure. Export a special tools_help_func() which shows the help
page for the active tool.
* app/[all files calling a dialog constructor]: pass the dialog's
help page to the constructor.
Most dialogs are now created by gimp_dialog_new() which also sets
up the action_area and the WM delete event callback, so I removed
the resp. code from these files.
Fixed some minor bugs and did some other stuff but didn't change
any logic except dialog creation.
* plug-ins/helpbrowser/helpbrowser.c: don't try to call a running
help browser and don't install any menu path (all done in
app/gimphelp.[ch] now).
Mon Sep 27 17:13:48 1999 ape@gandalf.spacetec.no (Asbjorn Pettersen)
* app/unittest/gimpparse.c (global_parse_init):
......
......@@ -203,6 +203,8 @@ gimp_SOURCES = \
gimpcontextpreview.h \
gimpdnd.c \
gimpdnd.h \
gimphelp.c \
gimphelp.h \
gimphistogram.c \
gimphistogram.h \
gimphistogramP.h \
......@@ -222,6 +224,8 @@ gimp_SOURCES = \
gimprc.c \
gimprc.h \
gimprc_cmds.c \
gimpui.c \
gimpui.h \
gimpunit.c \
global_edit.c \
global_edit.h \
......
......@@ -35,13 +35,14 @@
#include "gdisplay_ops.h"
#include "gdisplay_color_ui.h"
#include "gimage_mask.h"
#include "gimphelp.h"
#include "gimprc.h"
#include "gimpui.h"
#include "global_edit.h"
#include "gradient.h"
#include "image_render.h"
#include "info_window.h"
#include "nav_window.h"
#include "interface.h"
#include "invert.h"
#include "lc_dialog.h"
#include "layer_select.h"
......@@ -74,7 +75,6 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean);
static void image_resize_callback (GtkWidget *, gpointer);
static void image_scale_callback (GtkWidget *, gpointer);
static void image_cancel_callback (GtkWidget *, gpointer);
static gint image_delete_callback (GtkWidget *, GdkEvent *, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_border_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gpointer, gpointer);
......@@ -345,54 +345,69 @@ void
select_border_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay * gdisp;
GtkWidget *qbox;
GDisplay *gdisp;
return_if_no_display (gdisp);
gtk_widget_show (query_size_box (_("Border Selection"),
_("Border selection by:"),
selection_border_radius, 1, 32767, 0,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_border_callback, gdisp->gimage));
qbox = gimp_query_size_box (_("Border Selection"),
gimp_standard_help_func,
"dialogs/border_selection_dialog.html",
_("Border selection by:"),
selection_border_radius, 1, 32767, 0,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_border_callback, gdisp->gimage);
gtk_widget_show (qbox);
}
void
select_feather_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay * gdisp;
GtkWidget *qbox;
GDisplay *gdisp;
return_if_no_display (gdisp);
gtk_widget_show (query_size_box (_("Feather Selection"),
_("Feather selection by:"),
selection_feather_radius, 0, 32767, 3,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_feather_callback, gdisp->gimage));
qbox = gimp_query_size_box (_("Feather Selection"),
gimp_standard_help_func,
"dialogs/feather_selection_dialog.html",
_("Feather selection by:"),
selection_feather_radius, 0, 32767, 3,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_feather_callback, gdisp->gimage);
gtk_widget_show (qbox);
}
void
select_grow_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay * gdisp;
GtkWidget *qbox;
GDisplay *gdisp;
return_if_no_display (gdisp);
gtk_widget_show (query_size_box (_("Grow Selection"),
_("Grow selection by:"),
selection_grow_pixels, 1, 32767, 0,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_grow_callback, gdisp->gimage));
qbox = gimp_query_size_box (_("Grow Selection"),
gimp_standard_help_func,
"dialogs/grow_selection_dialog.html",
_("Grow selection by:"),
selection_grow_pixels, 1, 32767, 0,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_grow_callback, gdisp->gimage);
gtk_widget_show (qbox);
}
void
......@@ -405,15 +420,18 @@ select_shrink_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
return_if_no_display (gdisp);
shrink_dialog = query_size_box (N_("Shrink Selection"),
N_("Shrink selection by:"),
selection_shrink_pixels, 1, 32767, 0,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_shrink_callback, gdisp->gimage);
shrink_dialog =
gimp_query_size_box (N_("Shrink Selection"),
gimp_standard_help_func,
"dialogs/shrink_selection_dialog.html",
N_("Shrink selection by:"),
selection_shrink_pixels, 1, 32767, 0,
gdisp->gimage->unit,
MIN (gdisp->gimage->xresolution,
gdisp->gimage->yresolution),
gdisp->dot_for_dot,
GTK_OBJECT (gdisp->gimage), "destroy",
gimage_mask_shrink_callback, gdisp->gimage);
edge_lock = gtk_check_button_new_with_label (_("Shrink from image border"));
/* eeek */
......@@ -810,7 +828,6 @@ image_resize_cmd_callback (GtkWidget *widget,
gdisp->dot_for_dot,
image_resize_callback,
image_cancel_callback,
image_delete_callback,
image_resize);
gtk_widget_show (image_resize->resize->resize_shell);
......@@ -842,7 +859,6 @@ image_scale_cmd_callback (GtkWidget *widget,
gdisp->dot_for_dot,
image_scale_callback,
image_cancel_callback,
image_delete_callback,
image_scale);
gtk_widget_show (image_scale->resize->resize_shell);
......@@ -1175,6 +1191,13 @@ about_dialog_cmd_callback (GtkWidget *widget,
about_dialog_create (FALSE);
}
void
gimp_help_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
gimp_help ("");
}
void
tips_dialog_cmd_callback (GtkWidget *widget,
gpointer client_data)
......@@ -1284,17 +1307,6 @@ image_scale_callback (GtkWidget *widget,
g_free (image_scale);
}
static gint
image_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
{
image_cancel_callback (widget, client_data);
return TRUE;
}
static void
image_cancel_callback (GtkWidget *widget,
gpointer client_data)
......
......@@ -109,6 +109,7 @@ void dialogs_error_console_cmd_callback (GtkWidget *, gpointer);
void dialogs_module_browser_cmd_callback (GtkWidget *, gpointer);
void dialogs_display_filters_cmd_callback (GtkWidget *, gpointer);
void about_dialog_cmd_callback (GtkWidget *, gpointer);
void gimp_help_cmd_callback (GtkWidget *, gpointer);
void tips_dialog_cmd_callback (GtkWidget *, gpointer);
#endif /* __COMMANDS_H__ */
......@@ -24,7 +24,6 @@
#include <string.h>
#include "libgimp/gimpintl.h"
#include "actionarea.h"
#include "appenv.h"
#include "channel.h"
#include "color_panel.h"
......@@ -33,6 +32,7 @@
#include "gimpcontext.h"
#include "gimage_mask.h"
#include "gimpimage.h"
#include "gimpui.h"
#include "global_edit.h"
#include "qmask.h"
#include "undo.h"
......@@ -60,23 +60,8 @@ static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gdouble *scale_val);
static gint qmask_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data);
/* Actual code */
static gint
qmask_query_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer client_data)
{
edit_qmask_query_cancel_callback (widget, client_data);
return TRUE;
}
static void
qmask_query_scale_update (GtkAdjustment *adjustment, gdouble *scale_val)
{
......@@ -86,40 +71,39 @@ qmask_query_scale_update (GtkAdjustment *adjustment, gdouble *scale_val)
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
(GtkSignalFunc) qmask_deactivate,
gdisp);
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
g_assert(gdisp);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
(GtkSignalFunc) qmask_deactivate,
gdisp);
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Change the state of the buttons */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gdisp->qmaskon),
gdisp->gimage->qmask_state);
/* Change the state of the buttons */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gdisp->qmaskon),
gdisp->gimage->qmask_state);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gdisp->qmaskoff),
!gdisp->gimage->qmask_state);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gdisp->qmaskoff),
!gdisp->gimage->qmask_state);
/* Enable toggle again */
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskoff),
(GtkSignalFunc) qmask_deactivate,
gdisp);
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
/* Enable toggle again */
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskoff),
(GtkSignalFunc) qmask_deactivate,
gdisp);
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
void
qmask_click_handler (GtkWidget *widget,
GdkEventButton *event,
......@@ -135,104 +119,103 @@ qmask_click_handler (GtkWidget *widget,
}
}
void
qmask_deactivate(GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
{
gimg = gdisp->gimage;
if (!gimg) return;
if (!gdisp->gimage->qmask_state) {
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
{
gimg = gdisp->gimage;
if (!gimg) return;
if (!gdisp->gimage->qmask_state) {
return; /* if already set do nothing */
}
}
undo_push_group_start (gimg, QMASK_UNDO);
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimage_mask_load (gimg, gmask);
gimage_remove_channel(gimg, gmask);
undo_push_qmask(gimg,1);
gdisp->gimage->qmask_state = 0;
gdisplays_flush ();
gimage_mask_load (gimg, gmask);
gimage_remove_channel(gimg, gmask);
undo_push_qmask(gimg,1);
gdisp->gimage->qmask_state = 0;
gdisplays_flush ();
}
else
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
undo_push_group_end (gimg);
}
}
void
qmask_activate(GtkWidget *w,
GDisplay *gdisp)
qmask_activate (GtkWidget *w,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
double opacity;
unsigned char *color;
double opacity;
unsigned char *color;
if (gdisp)
{
gimg = gdisp->gimage;
if (!gimg) return;
if (gdisp)
{
gimg = gdisp->gimage;
if (!gimg) return;
if (gdisp->gimage->qmask_state) {
if (gdisp->gimage->qmask_state) {
return; /* If already set, do nothing */
}
}
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
color = gimg->qmask_color;
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) ) {
gimg->qmask_state = 1; /* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
{
floating_sel_to_layer (layer);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) ) {
gimg->qmask_state = 1; /* if the user was clever and created his own */
return;
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask(gimg,0);
gdisp->gimage->qmask_state = 1;
gdisplays_flush();
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask(gimg,0);
gdisp->gimage->qmask_state = 1;
gdisplays_flush();
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
{
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask(gimg,0);
gdisp->gimage->qmask_state = 1;
gdisplays_flush();
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask(gimg,0);
gdisp->gimage->qmask_state = 1;
gdisplays_flush();
}
undo_push_group_end(gimg);
}
undo_push_group_end(gimg);
}
}
static void
......@@ -249,12 +232,6 @@ edit_qmask_channel_query (GDisplay * gdisp)
gint i;
guchar channel_color[3] = { 0, 0, 0 };
static ActionAreaItem action_items[] =
{
{ N_("OK"), edit_qmask_query_ok_callback, NULL, NULL },
{ N_("Cancel"), edit_qmask_query_cancel_callback, NULL, NULL }
};
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new (EditQmaskOptions, 1);
......@@ -267,24 +244,25 @@ edit_qmask_channel_query (GDisplay * gdisp)
options->color_panel = color_panel_new (channel_color, 48, 64);
/* The dialog */
options->query_box = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (options->query_box),
"edit_qmask_atributes", "Gimp");
gtk_window_set_title (GTK_WINDOW (options->query_box),
_("Edit Qmask Attributes"));
gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE);
/* Handle the wm close signal */
gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event",
GTK_SIGNAL_FUNC (qmask_query_delete_callback),
options);
options->query_box =
gimp_dialog_new (_("Edit Qmask Attributes"), "edit_qmask_attributes",
gimp_standard_help_func,
"dialogs/edit_qmask_attributes_dialog.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
_("OK"), edit_qmask_query_ok_callback,
options, NULL, TRUE, FALSE,
_("Cancel"), edit_qmask_query_cancel_callback,
options, NULL, FALSE, TRUE,
NULL);
/* The main hbox */
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
hbox);
/* The vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
......@@ -316,10 +294,6 @@ edit_qmask_channel_query (GDisplay * gdisp)
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel->color_panel_widget);
action_items[0].user_data = options;
action_items[1].user_data = options;
build_action_area (GTK_DIALOG (options->query_box), action_items, 2, 0);
gtk_widget_show (table);
gtk_widget_show (vbox);
gtk_widget_show (hbox);
......@@ -327,7 +301,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
}
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
......@@ -338,8 +312,8 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name(options->gimage, "Qmask");
opacity = (int) (255* options->opacity/100);
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */
......@@ -377,7 +351,9 @@ static void edit_qmask_query_ok_callback (GtkWidget *widget,
g_free (options);
}
static void edit_qmask_query_cancel_callback (GtkWidget *widget, gpointer client_data)
static void