From 002aa905dbb1f316e3ab4d98accc902938058574 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 27 Sep 1999 17:58:10 +0000 Subject: [PATCH] app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer * 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 /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). --- ChangeLog | 52 + app/Makefile.am | 4 + app/actions/help-commands.c | 120 +- app/actions/help-commands.h | 1 + app/actions/qmask-commands.c | 268 +- app/actions/quick-mask-commands.c | 268 +- app/app_procs.c | 58 +- app/base/color-balance.c | 50 +- app/base/curves.c | 55 +- app/base/hue-saturation.c | 61 +- app/base/threshold.c | 53 +- app/brightness_contrast.c | 43 +- app/brush_edit.c | 96 +- app/brush_select.c | 137 +- app/by_color_select.c | 67 +- app/channel_ops.c | 42 +- app/channels_dialog.c | 88 +- app/color_balance.c | 50 +- app/color_notebook.c | 118 +- app/color_picker.c | 4 +- app/color_select.c | 60 +- app/commands.c | 120 +- app/commands.h | 1 + app/convert.c | 52 +- app/core/gimp-edit.c | 92 +- app/core/gimpdrawable-offset.c | 42 +- app/core/gimpedit.c | 92 +- app/core/gimpimage-convert.c | 52 +- app/core/gimpimage-duplicate.c | 42 +- app/core/gimpimage-qmask.c | 268 +- app/core/gimpimage-quick-mask.c | 268 +- app/crop.c | 5 +- app/curves.c | 55 +- app/devices.c | 146 +- app/dialogs/color-dialog.c | 118 +- app/dialogs/image-new-dialog.c | 97 +- app/dialogs/info-dialog.c | 25 +- app/dialogs/info-dialog.h | 12 +- app/dialogs/info-window.c | 8 +- app/dialogs/module-dialog.c | 28 +- app/dialogs/preferences-dialog.c | 401 +-- app/dialogs/preferences-dialog.h | 9 - app/dialogs/resize-dialog.c | 78 +- app/dialogs/resize-dialog.h | 3 - app/dialogs/user-install-dialog.c | 101 +- app/display/gimpdisplay-ops.c | 46 +- app/display/gimpdisplayshell-draw.c | 513 +--- app/display/gimpdisplayshell-draw.h | 81 +- app/display/gimpdisplayshell-filter-dialog.c | 39 +- app/display/gimpdisplayshell-filter.c | 55 +- app/display/gimpdisplayshell-qmask.c | 268 +- app/display/gimpdisplayshell.c | 513 +--- app/display/gimpdisplayshell.h | 81 +- app/display/gimpnavigationeditor.c | 14 +- app/display/gimpnavigationview.c | 14 +- app/display/gimpprogress.c | 63 +- app/errorconsole.c | 111 +- app/errors.c | 5 +- app/file_new_dialog.c | 97 +- app/fileops.c | 270 +- app/gdisplay_color.c | 55 +- app/gdisplay_color_ui.c | 39 +- app/gdisplay_ops.c | 46 +- app/gimpdrawable-offset.c | 42 +- app/gimphelp.c | 132 + app/gimphelp.h | 39 + app/gimpimage-convert.c | 52 +- app/gimpimage-duplicate.c | 42 +- app/gimpprogress.c | 63 +- app/gimprc.c | 5 +- app/gimprc.h | 2 +- app/gimpui.c | 857 ++++++ app/gimpui.h | 175 ++ app/global_edit.c | 92 +- app/gradient.c | 2743 +++++++++--------- app/gradient_editor.c | 2743 +++++++++--------- app/gradient_select.c | 354 ++- app/gui/brush-editor.c | 96 +- app/gui/brush-select.c | 137 +- app/gui/channels-dialog.c | 88 +- app/gui/color-notebook.c | 118 +- app/gui/color-select.c | 60 +- app/gui/commands.c | 120 +- app/gui/commands.h | 1 + app/gui/device-status-dialog.c | 146 +- app/gui/file-new-dialog.c | 97 +- app/gui/gradient-editor.c | 2743 +++++++++--------- app/gui/gradient-select.c | 354 ++- app/gui/help-commands.c | 120 +- app/gui/help-commands.h | 1 + app/gui/info-dialog.c | 25 +- app/gui/info-dialog.h | 12 +- app/gui/info-window.c | 8 +- app/gui/input-dialog.c | 146 +- app/gui/layers-dialog.c | 228 +- app/gui/menus.c | 1 + app/gui/module-browser.c | 28 +- app/gui/palette-editor.c | 155 +- app/gui/palette-select.c | 63 +- app/gui/paths-dialog.c | 20 +- app/gui/pattern-select.c | 91 +- app/gui/preferences-dialog.c | 401 +-- app/gui/preferences-dialog.h | 9 - app/gui/qmask-commands.c | 268 +- app/gui/resize-dialog.c | 78 +- app/gui/resize-dialog.h | 3 - app/gui/user-install-dialog.c | 101 +- app/histogram_tool.c | 44 +- app/hue_saturation.c | 61 +- app/info_dialog.c | 25 +- app/info_dialog.h | 12 +- app/info_window.c | 8 +- app/install.c | 101 +- app/interface.c | 513 +--- app/interface.h | 81 +- app/layers_dialog.c | 228 +- app/lc_dialog.c | 22 +- app/levels.c | 61 +- app/measure.c | 8 +- app/menus.c | 1 + app/menus/menus.c | 1 + app/module_db.c | 28 +- app/nav_window.c | 14 +- app/palette.c | 155 +- app/palette_select.c | 63 +- app/paths_dialog.c | 20 +- app/pattern_select.c | 91 +- app/perspective_tool.c | 3 +- app/posterize.c | 48 +- app/preferences_dialog.c | 401 +-- app/preferences_dialog.h | 9 - app/qmask.c | 268 +- app/resize.c | 78 +- app/resize.h | 3 - app/rotate_tool.c | 3 +- app/scale_tool.c | 3 +- app/shear_tool.c | 3 +- app/threshold.c | 53 +- app/tools.c | 201 +- app/tools.h | 2 + app/tools/brightness_contrast.c | 43 +- app/tools/by_color_select.c | 67 +- app/tools/color_balance.c | 50 +- app/tools/color_picker.c | 4 +- app/tools/crop.c | 5 +- app/tools/curves.c | 55 +- app/tools/gimpbrightnesscontrasttool.c | 43 +- app/tools/gimpbycolorselecttool.c | 67 +- app/tools/gimpcolorbalancetool.c | 50 +- app/tools/gimpcroptool.c | 5 +- app/tools/gimpcurvestool.c | 55 +- app/tools/gimphistogramtool.c | 44 +- app/tools/gimphuesaturationtool.c | 61 +- app/tools/gimplevelstool.c | 61 +- app/tools/gimpmeasuretool.c | 8 +- app/tools/gimpperspectivetool.c | 3 +- app/tools/gimpposterizetool.c | 48 +- app/tools/gimprotatetool.c | 3 +- app/tools/gimpscaletool.c | 3 +- app/tools/gimpsheartool.c | 3 +- app/tools/gimpthresholdtool.c | 53 +- app/tools/histogram_tool.c | 44 +- app/tools/hue_saturation.c | 61 +- app/tools/levels.c | 61 +- app/tools/measure.c | 8 +- app/tools/perspective_tool.c | 3 +- app/tools/posterize.c | 48 +- app/tools/rotate_tool.c | 3 +- app/tools/scale_tool.c | 3 +- app/tools/shear_tool.c | 3 +- app/tools/threshold.c | 53 +- app/tools/tools.c | 201 +- app/tools/tools.h | 2 + app/tools/transform_core.c | 53 +- app/transform_core.c | 53 +- app/undo_history.c | 50 +- app/user_install.c | 101 +- app/widgets/gimpbrusheditor.c | 96 +- app/widgets/gimpcolordialog.c | 118 +- app/widgets/gimpcolordisplayeditor.c | 39 +- app/widgets/gimpdeviceinfo.c | 146 +- app/widgets/gimpdevices.c | 146 +- app/widgets/gimpgradienteditor.c | 2743 +++++++++--------- app/widgets/gimphelp.c | 132 + app/widgets/gimphelp.h | 39 + app/widgets/gimpitemfactory.c | 1 + app/widgets/gimppaletteeditor.c | 155 +- app/widgets/gimpwidgets-utils.c | 857 ++++++ app/widgets/gimpwidgets-utils.h | 175 ++ libgimpwidgets/gimpcolorselect.c | 60 +- plug-ins/helpbrowser/helpbrowser.c | 51 +- 191 files changed, 12912 insertions(+), 15115 deletions(-) create mode 100644 app/gimphelp.c create mode 100644 app/gimphelp.h create mode 100644 app/gimpui.c create mode 100644 app/gimpui.h create mode 100644 app/widgets/gimphelp.c create mode 100644 app/widgets/gimphelp.h create mode 100644 app/widgets/gimpwidgets-utils.c create mode 100644 app/widgets/gimpwidgets-utils.h diff --git a/ChangeLog b/ChangeLog index 6a7d292aa2..30c1c20631 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,55 @@ +1999-09-27 Michael Natterer + + * 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 /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): diff --git a/app/Makefile.am b/app/Makefile.am index d2c1dcd073..8bf685fa87 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -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 \ diff --git a/app/actions/help-commands.c b/app/actions/help-commands.c index 344fd7017d..9dc31ff075 100644 --- a/app/actions/help-commands.c +++ b/app/actions/help-commands.c @@ -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) diff --git a/app/actions/help-commands.h b/app/actions/help-commands.h index aba3d13a1e..7dbf589d23 100644 --- a/app/actions/help-commands.h +++ b/app/actions/help-commands.h @@ -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__ */ diff --git a/app/actions/qmask-commands.c b/app/actions/qmask-commands.c index 29c2706729..5dea7de4c1 100644 --- a/app/actions/qmask-commands.c +++ b/app/actions/qmask-commands.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/actions/quick-mask-commands.c b/app/actions/quick-mask-commands.c index 29c2706729..5dea7de4c1 100644 --- a/app/actions/quick-mask-commands.c +++ b/app/actions/quick-mask-commands.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/app_procs.c b/app/app_procs.c index 67bb943455..ec7d1fe99c 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include #include #include @@ -57,6 +58,7 @@ #include "gimprc.h" #include "gimpparasite.h" #include "gimpset.h" +#include "gimpui.h" #include "global_edit.h" #include "gradient.h" #include "gximage.h" @@ -325,7 +327,7 @@ static GtkWidget *label2 = NULL; static GtkWidget *pbar = NULL; static void -destroy_initialization_status_window(void) +destroy_initialization_status_window (void) { if (win_initstatus) { @@ -338,7 +340,7 @@ destroy_initialization_status_window(void) } static void -make_initialization_status_window(void) +make_initialization_status_window (void) { if (no_interface == FALSE) { @@ -413,9 +415,9 @@ make_initialization_status_window(void) } void -app_init_update_status (char *label1val, - char *label2val, - float pct_progress) +app_init_update_status (char *label1val, + char *label2val, + float pct_progress) { char *temp; @@ -710,20 +712,10 @@ really_quit_cancel_callback (GtkWidget *widget, gtk_widget_destroy (dialog); } -static gint -really_quit_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - really_quit_cancel_callback (widget, (GtkWidget *) client_data); - return TRUE; -} - static void really_quit_dialog (void) { GtkWidget *dialog; - GtkWidget *button; GtkWidget *hbox; GtkWidget *pixmap_widget; GdkPixmap *pixmap; @@ -734,36 +726,22 @@ really_quit_dialog (void) menus_set_sensitive_glue ("", N_("/File/Quit"), FALSE); menus_set_sensitive_glue ("", N_("/File/Quit"), FALSE); - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "really_quit", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Really Quit?")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2); + dialog = gimp_dialog_new (_("Really Quit?"), "really_quit", + gimp_standard_help_func, + "dialogs/really_quit_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - (GtkSignalFunc) really_quit_delete_callback, - dialog); + _("Quit"), really_quit_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), really_quit_cancel_callback, + NULL, NULL, FALSE, TRUE, - button = gtk_button_new_with_label (_("Quit")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) really_quit_callback, - dialog); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE, TRUE, 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 (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) really_quit_cancel_callback, - dialog); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE, TRUE, 0); - gtk_widget_show (button); + NULL); hbox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox); gtk_widget_show (hbox); gtk_widget_realize (dialog); diff --git a/app/base/color-balance.c b/app/base/color-balance.c index 6e66f75f05..02db705ef2 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -28,6 +28,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" @@ -69,8 +70,6 @@ static void color_balance_update (ColorBalanceDialog *, int); static void color_balance_preview (ColorBalanceDialog *); static void color_balance_ok_callback (GtkWidget *, gpointer); static void color_balance_cancel_callback (GtkWidget *, gpointer); -static gint color_balance_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void color_balance_shadows_callback (GtkWidget *, gpointer); static void color_balance_midtones_callback (GtkWidget *, gpointer); static void color_balance_highlights_callback (GtkWidget *, gpointer); @@ -253,7 +252,6 @@ color_balance_initialize (GDisplay *gdisp) /* Color Balance dialog */ /**************************/ -/* the action area structure */ static ColorBalanceDialog * color_balance_new_dialog () { @@ -269,15 +267,9 @@ color_balance_new_dialog () GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_balance_ok_callback, NULL, NULL }, - { N_("Cancel"), color_balance_cancel_callback, NULL, NULL } - }; - - char *appl_mode_names[] = + gchar *appl_mode_names[] = { N_("Shadows"), N_("Midtones"), @@ -297,18 +289,21 @@ color_balance_new_dialog () cbd->application_mode = SHADOWS; /* The shell and main vbox */ - cbd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cbd->shell), "color_balance", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cbd->shell), _("Color Balance")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cbd->shell), "delete_event", - GTK_SIGNAL_FUNC (color_balance_delete_callback), - cbd); + cbd->shell = gimp_dialog_new (_("Color Balance"), "color_balance", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), color_balance_ok_callback, + cbd, NULL, TRUE, FALSE, + _("Cancel"), color_balance_cancel_callback, + cbd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cbd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cbd->shell)->vbox), vbox); /* Horizontal box for application mode */ hbox = gtk_hbox_new (TRUE, 2); @@ -473,11 +468,6 @@ color_balance_new_dialog () } gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cbd; - action_items[1].user_data = cbd; - build_action_area (GTK_DIALOG (cbd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (cbd->shell); @@ -614,16 +604,6 @@ color_balance_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -color_balance_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_balance_cancel_callback (w, client_data); - - return TRUE; -} - static void color_balance_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/base/curves.c b/app/base/curves.c index b80a204d07..60b11f4044 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -21,7 +21,6 @@ #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "cursorutil.h" @@ -29,6 +28,7 @@ #include "general.h" #include "gdisplay.h" #include "gimphistogram.h" +#include "gimpui.h" #include "interface.h" #include "curves.h" #include "gimplut.h" @@ -114,7 +114,6 @@ static void curves_free_callback (GtkWidget *, gpointer); static void curves_reset_callback (GtkWidget *, gpointer); static void curves_ok_callback (GtkWidget *, gpointer); static void curves_cancel_callback (GtkWidget *, gpointer); -static gint curves_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void curves_preview_update (GtkWidget *, gpointer); static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); @@ -519,14 +518,7 @@ curves_new_dialog () GtkWidget *channel_hbox; GtkWidget *menu; GtkWidget *table; - int i, j; - - static ActionAreaItem action_items[] = - { - { N_("Reset"), curves_reset_callback, NULL, NULL }, - { N_("OK"), curves_ok_callback, NULL, NULL }, - { N_("Cancel"), curves_cancel_callback, NULL, NULL } - }; + gint i, j; static MenuItem curve_type_items[] = { @@ -535,7 +527,7 @@ curves_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - cd = g_malloc (sizeof (CurvesDialog)); + cd = g_new (CurvesDialog, 1); cd->cursor_ind_height = cd->cursor_ind_width = -1; cd->preview = TRUE; cd->curve_type = SMOOTH; @@ -556,17 +548,23 @@ curves_new_dialog () curve_type_items [i].user_data = (gpointer) cd; /* The shell and main vbox */ - cd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cd->shell), "curves", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cd->shell), _("Curves")); + cd->shell = gimp_dialog_new (_("Curves"), "curves", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Reset"), curves_reset_callback, + cd, NULL, FALSE, FALSE, + _("OK"), curves_ok_callback, + cd, NULL, TRUE, FALSE, + _("Cancel"), curves_cancel_callback, + cd, NULL, FALSE, TRUE, + + NULL); - gtk_signal_connect (GTK_OBJECT (cd->shell), "delete_event", - GTK_SIGNAL_FUNC (curves_delete_callback), - cd); - vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cd->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -670,12 +668,6 @@ curves_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cd; - action_items[1].user_data = cd; - action_items[2].user_data = cd; - build_action_area (GTK_DIALOG (cd->shell), action_items, 3, 0); - gtk_widget_show (vbox); return cd; @@ -1278,24 +1270,15 @@ curves_cancel_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -curves_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - curves_cancel_callback (w, data); - - return TRUE; -} static void -curves_preview_update (GtkWidget *w, +curves_preview_update (GtkWidget *widget, gpointer data) { CurvesDialog *cd; cd = (CurvesDialog *) data; - if (GTK_TOGGLE_BUTTON (w)->active) + if (GTK_TOGGLE_BUTTON (widget)->active) { cd->preview = TRUE; curves_preview (cd); diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c index 941aa8221a..33fab136a9 100644 --- a/app/base/hue-saturation.c +++ b/app/base/hue-saturation.c @@ -18,6 +18,7 @@ #include #include #include + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -25,6 +26,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "hue_saturation.h" #include "interface.h" @@ -88,8 +90,6 @@ static void hue_saturation_update (HueSaturationDialog *, static void hue_saturation_preview (HueSaturationDialog *); static void hue_saturation_ok_callback (GtkWidget *, gpointer); static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static gint hue_saturation_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void hue_saturation_master_callback (GtkWidget *, gpointer); static void hue_saturation_R_callback (GtkWidget *, gpointer); static void hue_saturation_Y_callback (GtkWidget *, gpointer); @@ -223,7 +223,7 @@ hue_saturation (PixelRegion *srcPR, } -/* by_color select action functions */ +/* hue saturation action functions */ static void hue_saturation_control (Tool *tool, @@ -281,7 +281,7 @@ tools_free_hue_saturation (Tool *tool) color_bal = (HueSaturation *) tool->private; - /* Close the color select dialog */ + /* Close the hue saturation dialog */ if (hue_saturation_dialog) hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog); @@ -299,7 +299,7 @@ hue_saturation_initialize (GDisplay *gdisp) return; } - /* The "hue-saturation color" dialog */ + /* The "hue-saturation" dialog */ if (!hue_saturation_dialog) hue_saturation_dialog = hue_saturation_new_dialog (); else @@ -354,15 +354,9 @@ hue_saturation_new_dialog () GtkWidget *frame; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), hue_saturation_ok_callback, NULL, NULL }, - { N_("Cancel"), hue_saturation_cancel_callback, NULL, NULL } - }; - - char *hue_partition_names[] = + gchar *hue_partition_names[] = { N_("Master"), N_("R"), @@ -384,23 +378,26 @@ hue_saturation_new_dialog () hue_saturation_M_callback }; - hsd = g_malloc (sizeof (HueSaturationDialog)); + hsd = g_new (HueSaturationDialog, 1); hsd->hue_partition = 0; - hsd->preview = TRUE; + hsd->preview = TRUE; /* The shell and main vbox */ - hsd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (hsd->shell), "hue_saturation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (hsd->shell), _("Hue-Saturation")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (hsd->shell), "delete_event", - GTK_SIGNAL_FUNC (hue_saturation_delete_callback), - hsd); + hsd->shell = gimp_dialog_new (_("Hue-Saturation"), "hue_satiration", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), hue_saturation_ok_callback, + hsd, NULL, TRUE, FALSE, + _("Cancel"), hue_saturation_cancel_callback, + hsd, NULL, FALSE, TRUE, + + NULL); main_vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (hsd->shell)->vbox), main_vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (hsd->shell)->vbox), main_vbox); /* The main hbox containing hue partitions and sliders */ main_hbox = gtk_hbox_new (FALSE, 2); @@ -579,12 +576,6 @@ hue_saturation_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = hsd; - action_items[1].user_data = hsd; - build_action_area (GTK_DIALOG (hsd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (main_hbox); @@ -699,16 +690,6 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -hue_saturation_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - hue_saturation_cancel_callback (w, client_data); - - return TRUE; -} - static void hue_saturation_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/base/threshold.c b/app/base/threshold.c index f0fbb393a7..20685a58ba 100644 --- a/app/base/threshold.c +++ b/app/base/threshold.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "general.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "threshold.h" @@ -56,8 +56,6 @@ static ThresholdDialog * threshold_new_dialog (void); static void threshold_preview (ThresholdDialog *); static void threshold_ok_callback (GtkWidget *, gpointer); static void threshold_cancel_callback (GtkWidget *, gpointer); -static gint threshold_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void threshold_preview_update (GtkWidget *, gpointer); static void threshold_low_threshold_text_update (GtkWidget *, gpointer); static void threshold_high_threshold_text_update (GtkWidget *, gpointer); @@ -273,31 +271,29 @@ threshold_new_dialog () GtkWidget *frame; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), threshold_ok_callback, NULL, NULL }, - { N_("Cancel"), threshold_cancel_callback, NULL, NULL } - }; - - td = g_malloc (sizeof (ThresholdDialog)); - td->preview = TRUE; - td->low_threshold = 127; + td = g_new (ThresholdDialog, 1); + td->preview = TRUE; + td->low_threshold = 127; td->high_threshold = 255; - td->hist = gimp_histogram_new(); + td->hist = gimp_histogram_new (); /* The shell and main vbox */ - td->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (td->shell), "threshold", "Gimp"); - gtk_window_set_title (GTK_WINDOW (td->shell), _("Threshold")); + td->shell = + gimp_dialog_new (_("Threshold"), "threshold", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (td->shell), "delete_event", - GTK_SIGNAL_FUNC (threshold_delete_callback), - td); + _("OK"), threshold_ok_callback, + td, NULL, TRUE, FALSE, + _("Cancel"), threshold_cancel_callback, + td, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (td->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (td->shell)->vbox), vbox); /* Horizontal box for threshold text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -362,11 +358,6 @@ threshold_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = td; - action_items[1].user_data = td; - build_action_area (GTK_DIALOG (td->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (td->shell); @@ -411,16 +402,6 @@ threshold_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -threshold_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - threshold_cancel_callback (w, client_data); - - return TRUE; -} - static void threshold_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/brightness_contrast.c b/app/brightness_contrast.c index 0c7557477c..8bfde39e55 100644 --- a/app/brightness_contrast.c +++ b/app/brightness_contrast.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "brightness_contrast.h" #include "drawable.h" #include "gimage_mask.h" +#include "gimpui.h" #include "gdisplay.h" #include "image_map.h" #include "interface.h" @@ -89,7 +89,6 @@ static void brightness_contrast_update (BrightnessContrastDia static void brightness_contrast_preview (BrightnessContrastDialog *); static void brightness_contrast_ok_callback (GtkWidget *, gpointer); static void brightness_contrast_cancel_callback (GtkWidget *, gpointer); -static gint brightness_contrast_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void brightness_contrast_preview_update (GtkWidget *, gpointer); static void brightness_contrast_brightness_scale_update (GtkAdjustment *, gpointer); static void brightness_contrast_contrast_scale_update (GtkAdjustment *, gpointer); @@ -208,26 +207,24 @@ brightness_contrast_new_dialog () GtkWidget *toggle; GtkObject *data; - static ActionAreaItem action_items[] = - { - { N_("OK"), brightness_contrast_ok_callback, NULL, NULL }, - { N_("Cancel"), brightness_contrast_cancel_callback, NULL, NULL } - }; - bcd = g_new (BrightnessContrastDialog, 1); bcd->preview = TRUE; bcd->lut = gimp_lut_new (); /* The shell and main vbox */ - bcd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bcd->shell), "brightness_contrast", "Gimp"); - gtk_window_set_title (GTK_WINDOW (bcd->shell), _("Brightness-Contrast")); + bcd->shell = + gimp_dialog_new (_("Brightness-Contrast"), "brightness_contrast", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle wm close signal */ - gtk_signal_connect (GTK_OBJECT (bcd->shell), "delete_event", - GTK_SIGNAL_FUNC (brightness_contrast_delete_callback), - bcd); + _("OK"), brightness_contrast_ok_callback, + bcd, NULL, TRUE, FALSE, + _("Cancel"), brightness_contrast_cancel_callback, + bcd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -320,12 +317,6 @@ brightness_contrast_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = bcd; - action_items[1].user_data = bcd; - build_action_area (GTK_DIALOG (bcd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (bcd->shell); @@ -412,16 +403,6 @@ brightness_contrast_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -brightness_contrast_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - brightness_contrast_cancel_callback (widget, data); - - return TRUE; -} - static void brightness_contrast_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/brush_edit.c b/app/brush_edit.c index 28f0fa3746..4541982c79 100644 --- a/app/brush_edit.c +++ b/app/brush_edit.c @@ -23,22 +23,16 @@ #include "appenv.h" #include "gimpbrushgenerated.h" #include "brush_edit.h" -#include "actionarea.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" -static void brush_edit_close_callback (GtkWidget *w, void *data); +static void brush_edit_close_callback (GtkWidget *, gpointer); static gint brush_edit_preview_resize (GtkWidget *widget, GdkEvent *event, BrushEditGeneratedWindow *begw); -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Close"), brush_edit_close_callback, NULL, NULL } -}; - static void -update_brush_callback (GtkAdjustment *adjustment, +update_brush_callback (GtkAdjustment *adjustment, BrushEditGeneratedWindow *begw) { if (begw->brush && @@ -64,15 +58,6 @@ update_brush_callback (GtkAdjustment *adjustment, } } -static gint -brush_edit_delete_callback (GtkWidget *w, - BrushEditGeneratedWindow *begw) -{ - if (GTK_WIDGET_VISIBLE (w)) - gtk_widget_hide (w); - return TRUE; -} - static void brush_edit_clear_preview (BrushEditGeneratedWindow *begw) { @@ -93,7 +78,7 @@ brush_edit_clear_preview (BrushEditGeneratedWindow *begw) } static gint -brush_edit_brush_dirty_callback(GimpBrush *brush, +brush_edit_brush_dirty_callback (GimpBrush *brush, BrushEditGeneratedWindow *begw) { int x, y, width, yend, ystart, xo; @@ -138,15 +123,17 @@ brush_edit_brush_dirty_callback(GimpBrush *brush, return TRUE; } -void brush_renamed_callback(GtkWidget *widget, BrushEditGeneratedWindow *begw) +void +brush_renamed_callback (GtkWidget *widget, + BrushEditGeneratedWindow *begw) { gtk_entry_set_text(GTK_ENTRY(begw->name), gimp_brush_get_name(GIMP_BRUSH(begw->brush))); } void -brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw, - GimpBrush *gbrush) +brush_edit_generated_set_brush (BrushEditGeneratedWindow *begw, + GimpBrush *gbrush) { GimpBrushGenerated *brush = 0; if (begw->brush == (GimpBrushGenerated*)gbrush) @@ -189,16 +176,21 @@ brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw, } } -void name_changed_func(GtkWidget *widget, BrushEditGeneratedWindow *begw) +void +name_changed_func (GtkWidget *widget, + BrushEditGeneratedWindow *begw) { gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(widget)); gimp_brush_set_name(GIMP_BRUSH(begw->brush), entry_text); } -void focus_out_func(GtkWidget *wid1, GtkWidget *wid2, BrushEditGeneratedWindow *begw) +void +focus_out_func (GtkWidget *wid1, + GtkWidget *wid2, + BrushEditGeneratedWindow *begw) { - name_changed_func(wid1, begw); + name_changed_func (wid1, begw); } BrushEditGeneratedWindow * @@ -210,34 +202,31 @@ brush_edit_generated_new () GtkWidget *slider; GtkWidget *table; - - - begw = g_malloc (sizeof (BrushEditGeneratedWindow)); + begw = g_new (BrushEditGeneratedWindow, 1); begw->brush = NULL; - begw->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (begw->shell), "generatedbrusheditor", - "Gimp"); - gtk_window_set_title (GTK_WINDOW (begw->shell), _("Brush Editor")); - gtk_window_set_policy(GTK_WINDOW(begw->shell), FALSE, TRUE, FALSE); + begw->shell = gimp_dialog_new (_("Brush Editor"), "generated_brush_editor", + gimp_standard_help_func, + "dialogs/generated_brush_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Close"), brush_edit_close_callback, + begw, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (begw->shell)->vbox), vbox, - TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (begw->shell)->vbox), vbox); - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (begw->shell), "delete_event", - GTK_SIGNAL_FUNC (brush_edit_delete_callback), - begw); + /* Populate the window with some widgets */ -/* Populate the window with some widgets */ - - /* table for brush controlls */ + /* table for brush controlls */ table = gtk_table_new(5, 4, FALSE); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); - /* Brush's name */ + /* Brush's name */ begw->name = gtk_entry_new(); gtk_box_pack_start (GTK_BOX (vbox), begw->name, TRUE, TRUE, 0); @@ -249,7 +238,7 @@ brush_edit_generated_new () begw); gtk_widget_show(begw->name); - /* brush's preview widget w/frame */ + /* brush's preview widget w/frame */ begw->frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (begw->frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), begw->frame, TRUE, TRUE, 0); @@ -276,7 +265,7 @@ brush_edit_generated_new () /* brush radius scale */ label = gtk_label_new (_("Radius:")); gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5); -/* gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); */ + /* gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); */ gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 3, 0, 0, 0); begw->radius_data = GTK_ADJUSTMENT (gtk_adjustment_new (10.0, 0.0, 100.0, 0.1, 1.0, 0.0)); slider = gtk_hscale_new (begw->radius_data); @@ -341,20 +330,15 @@ brush_edit_generated_new () gtk_table_set_col_spacing(GTK_TABLE (table), 0, 3); gtk_widget_show (table); - /* The action area */ - action_items[0].user_data = begw; - build_action_area (GTK_DIALOG (begw->shell), action_items, 1, 0); - gtk_widget_show (vbox); gtk_widget_show (begw->shell); - return begw; } static gint -brush_edit_preview_resize (GtkWidget *widget, - GdkEvent *event, +brush_edit_preview_resize (GtkWidget *widget, + GdkEvent *event, BrushEditGeneratedWindow *begw) { gtk_preview_size (GTK_PREVIEW (begw->preview), @@ -363,14 +347,16 @@ brush_edit_preview_resize (GtkWidget *widget, /* update the display */ if (begw->brush) - brush_edit_brush_dirty_callback(GIMP_BRUSH(begw->brush), begw); + brush_edit_brush_dirty_callback (GIMP_BRUSH (begw->brush), begw); return FALSE; } static void -brush_edit_close_callback (GtkWidget *w, void *data) +brush_edit_close_callback (GtkWidget *widget, + gpointer data) { - BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *)data; + BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *) data; + if (GTK_WIDGET_VISIBLE (begw->shell)) gtk_widget_hide (begw->shell); } diff --git a/app/brush_select.c b/app/brush_select.c index 04c34f4888..967d5ba394 100644 --- a/app/brush_select.c +++ b/app/brush_select.c @@ -23,7 +23,6 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "brush_scale.h" #include "gimpbrushgenerated.h" #include "gimpbrushlist.h" @@ -32,6 +31,7 @@ #include "gimpcontext.h" #include "gimplist.h" #include "gimprc.h" +#include "gimpui.h" #include "brush_edit.h" #include "brush_select.h" #include "colormaps.h" @@ -140,12 +140,10 @@ static void paint_mode_menu_callback (GtkWidget *, gpointer); static gint brush_select_events (GtkWidget *, GdkEvent *, BrushSelectP); static gint brush_select_resize (GtkWidget *, GdkEvent *, BrushSelectP); -static gint brush_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void preview_scroll_update (GtkAdjustment *, gpointer); static void opacity_scale_update (GtkAdjustment *, gpointer); static void spacing_scale_update (GtkAdjustment *, gpointer); - /* local variables */ /* List of active dialogs */ @@ -154,7 +152,6 @@ GSList *brush_active_dialogs = NULL; /* Brush editor dialog (main brush dialog only) */ static BrushEditGeneratedWindow *brush_edit_generated_dialog; - /* If title == NULL then it is the main brush dialog */ BrushSelectP brush_select_new (gchar *title, @@ -184,13 +181,7 @@ brush_select_new (gchar *title, GimpBrushP active = NULL; gint gotinitbrush = FALSE; - static ActionAreaItem action_items[] = - { - { N_("Refresh"), brush_select_refresh_callback, NULL, NULL }, - { N_("Close"), brush_select_close_callback, NULL, NULL } - }; - - bsp = g_malloc (sizeof (_BrushSelect)); + bsp = g_new (_BrushSelect, 1); bsp->redraw = TRUE; bsp->scroll_offset = 0; bsp->callback_name = 0; @@ -205,35 +196,42 @@ brush_select_new (gchar *title, bsp->freeze = FALSE; /* The shell and main vbox */ - bsp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bsp->shell), "brushselection", "Gimp"); - - if (!title) + if (title) { - gtk_window_set_title (GTK_WINDOW (bsp->shell), _("Brush Selection")); + bsp->shell = gimp_dialog_new (title, "brush_selection", + gimp_standard_help_func, + "dialogs/brush_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* set dialog's size later because weird thing will happen if the - * size was not saved in the current paint options mode - */ - session_set_window_geometry (bsp->shell, &brush_select_session_info, - FALSE); - } - else - { - gtk_window_set_title (GTK_WINDOW (bsp->shell), title); + _("Close"), brush_select_close_callback, + bsp, NULL, TRUE, TRUE, + + NULL); if (init_name && strlen (init_name)) active = gimp_brush_list_get_brush (brush_list, init_name); if (active) gotinitbrush = TRUE; } + else + { + bsp->shell = gimp_dialog_new (_("Brush Selection"), "brush_selection", + gimp_standard_help_func, + "dialogs/brush_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_window_set_policy (GTK_WINDOW (bsp->shell), FALSE, TRUE, FALSE); + _("Refresh"), brush_select_refresh_callback, + bsp, NULL, FALSE, FALSE, + _("Close"), brush_select_close_callback, + bsp, NULL, TRUE, TRUE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (bsp->shell), "delete_event", - GTK_SIGNAL_FUNC (brush_select_delete_callback), - bsp); + NULL); + + session_set_window_geometry (bsp->shell, &brush_select_session_info, + FALSE); + } /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -425,14 +423,6 @@ brush_select_new (gchar *title, gtk_widget_show (table); - /* The action area */ - action_items[0].user_data = bsp; - action_items[1].user_data = bsp; - if (title) - build_action_area (GTK_DIALOG (bsp->shell), &action_items[1], 1, 0); - else - build_action_area (GTK_DIALOG (bsp->shell), action_items, 2, 1); - gtk_widget_show (bsp->options_box); gtk_widget_show (hbox); gtk_widget_show (vbox); @@ -447,7 +437,7 @@ brush_select_new (gchar *title, display_brushes (bsp); /* Only for main dialog */ - if(!title) + if (!title) { /* add callbacks to keep the display area current */ gimp_list_foreach (GIMP_LIST (brush_list), @@ -514,7 +504,6 @@ brush_select_new (gchar *title, return bsp; } - void brush_select_select (BrushSelectP bsp, GimpBrushP brush) @@ -546,7 +535,6 @@ brush_select_select (BrushSelectP bsp, brush_select_show_selected (bsp, row, col); } - void brush_select_free (BrushSelectP bsp) { @@ -838,7 +826,6 @@ typedef struct { GimpBrushP brush; } popup_timeout_args_t; - static gint brush_popup_anim_timeout (gpointer data) { @@ -1104,7 +1091,6 @@ display_brush (BrushSelectP bsp, } } - static void display_setup (BrushSelectP bsp) { @@ -1156,7 +1142,6 @@ display_brushes (BrushSelectP bsp) gimp_list_foreach (GIMP_LIST (brush_list), (GFunc) do_display_brush, bsp); } - static void brush_select_show_selected (BrushSelectP bsp, int row, @@ -1246,7 +1231,6 @@ brush_select_show_selected (BrushSelectP bsp, g_free (buf); } - static void preview_calc_scrollbar (BrushSelectP bsp) { @@ -1343,7 +1327,6 @@ update_active_brush_field (BrushSelectP bsp) gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data), "value_changed"); } - static void edit_active_brush () { @@ -1508,56 +1491,47 @@ brush_select_events (GtkWidget *widget, } static gint -edit_brush_callback (GtkWidget *w, - GdkEvent *e, +edit_brush_callback (GtkWidget *widget, + GdkEvent *event, gpointer data) { - edit_active_brush(); + edit_active_brush (); return TRUE; } static gint -delete_brush_callback (GtkWidget *w, - GdkEvent *e, +delete_brush_callback (GtkWidget *widget, + GdkEvent *event, gpointer data) { - delete_active_brush(data); + delete_active_brush (data); return TRUE; } static gint -new_brush_callback (GtkWidget *w, - GdkEvent *e, +new_brush_callback (GtkWidget *widget, + GdkEvent *event, gpointer data) { GimpBrushGenerated *brush; + brush = gimp_brush_generated_new (10, .5, 0.0, 1.0); - gimp_brush_list_add(brush_list, GIMP_BRUSH (brush)); + gimp_brush_list_add (brush_list, GIMP_BRUSH (brush)); select_brush (GIMP_BRUSH (brush)); if (brush_edit_generated_dialog) brush_edit_generated_set_brush (brush_edit_generated_dialog, - get_active_brush()); - edit_brush_callback (w, e, data); - return TRUE; -} - -static gint -brush_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - brush_select_close_callback (w, data); - + get_active_brush ()); + edit_brush_callback (widget, event, data); return TRUE; } static void -brush_select_close_callback (GtkWidget *w, /* Unused so can be NULL */ - gpointer client_data) +brush_select_close_callback (GtkWidget *widget, + gpointer data) { BrushSelectP bsp; - bsp = (BrushSelectP) client_data; + bsp = (BrushSelectP) data; if (GTK_WIDGET_VISIBLE (bsp->shell)) gtk_widget_hide (bsp->shell); @@ -1572,15 +1546,14 @@ brush_select_close_callback (GtkWidget *w, /* Unused so can be NULL */ } } - static void -brush_select_refresh_callback (GtkWidget *w, - gpointer client_data) +brush_select_refresh_callback (GtkWidget *widget, + gpointer data) { BrushSelectP bsp; GimpBrushP active; - bsp = (BrushSelectP) client_data; + bsp = (BrushSelectP) data; /* re-init the brush list */ bsp->freeze = TRUE; @@ -1608,7 +1581,6 @@ brush_select_refresh_callback (GtkWidget *w, gtk_widget_draw (bsp->preview, NULL); } - static void preview_scroll_update (GtkAdjustment *adjustment, gpointer data) @@ -1617,7 +1589,7 @@ preview_scroll_update (GtkAdjustment *adjustment, GimpBrushP active; int row, col, index; - bsp = data; + bsp = (BrushSelectP) data; if (bsp) { @@ -1645,24 +1617,25 @@ preview_scroll_update (GtkAdjustment *adjustment, } static void -paint_mode_menu_callback (GtkWidget *w, - gpointer client_data) +paint_mode_menu_callback (GtkWidget *widget, + gpointer data) { - BrushSelectP bsp = (BrushSelectP) gtk_object_get_user_data (GTK_OBJECT (w)); + BrushSelectP bsp; + bsp = (BrushSelectP) gtk_object_get_user_data (GTK_OBJECT (widget)); + if (bsp == brush_select_dialog) { gimp_context_set_paint_mode (gimp_context_get_user (), - (int) client_data); + (int) data); } else { - bsp->paint_mode = (int) client_data; + bsp->paint_mode = (int) data; brush_change_callbacks (bsp, 0); } } - static void opacity_scale_update (GtkAdjustment *adjustment, gpointer data) diff --git a/app/by_color_select.c b/app/by_color_select.c index cbec398598..deb874f008 100644 --- a/app/by_color_select.c +++ b/app/by_color_select.c @@ -28,6 +28,7 @@ #include "gimage_mask.h" #include "gimprc.h" #include "gimpset.h" +#include "gimpui.h" #include "gdisplay.h" #include "selection_options.h" @@ -87,8 +88,6 @@ static gint by_color_select_preview_events (GtkWidget *, GdkEventButton *, static void by_color_select_type_callback (GtkWidget *, gpointer); static void by_color_select_reset_callback (GtkWidget *, gpointer); static void by_color_select_close_callback (GtkWidget *, gpointer); -static gint by_color_select_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void by_color_select_fuzzy_update (GtkAdjustment *, gpointer); static void by_color_select_preview_button_press (ByColorDialog *, GdkEventButton *); @@ -529,15 +528,14 @@ by_color_select_new_dialog () GtkWidget *options_box; GtkWidget *label; GtkWidget *util_box; - GtkWidget *push_button; GtkWidget *slider; GtkWidget *radio_box; GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - char *button_names[] = + gchar *button_names[] = { N_("Replace"), N_("Add"), @@ -545,7 +543,7 @@ by_color_select_new_dialog () N_("Intersect") }; - int button_values[] = + gint button_values[] = { REPLACE, ADD, @@ -553,28 +551,30 @@ by_color_select_new_dialog () INTERSECT }; - bcd = g_malloc (sizeof (ByColorDialog)); - bcd->gimage = NULL; + bcd = g_new (ByColorDialog, 1); + bcd->gimage = NULL; bcd->operation = REPLACE; bcd->threshold = DEFAULT_FUZZINESS; /* The shell and main vbox */ - bcd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bcd->shell), "by_color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (bcd->shell), _("By Color Selection")); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->action_area), 2); + bcd->shell = gimp_dialog_new (_("By Color Selection"), "by_color_selection", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (bcd->shell), "delete_event", - (GtkSignalFunc) by_color_select_delete_callback, - bcd); + _("Reset"), by_color_select_reset_callback, + bcd, NULL, FALSE, FALSE, + _("Close"), by_color_select_close_callback, + bcd, NULL, TRUE, TRUE, - /* The vbox */ + NULL); + + /* The vbox */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->vbox), vbox); - /* The horizontal box containing preview & options box */ + /* The horizontal box containing preview & options box */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -650,25 +650,6 @@ by_color_select_new_dialog () gtk_widget_show (slider); gtk_widget_show (util_box); - /* The reset push button */ - push_button = gtk_button_new_with_label (_("Reset")); - GTK_WIDGET_SET_FLAGS (push_button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->action_area), push_button, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (push_button), "clicked", - (GtkSignalFunc) by_color_select_reset_callback, - bcd); - gtk_widget_grab_default (push_button); - gtk_widget_show (push_button); - - /* The close push button */ - push_button = gtk_button_new_with_label (_("Close")); - GTK_WIDGET_SET_FLAGS (push_button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->action_area), push_button, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (push_button), "clicked", - (GtkSignalFunc) by_color_select_close_callback, - bcd); - gtk_widget_show (push_button); - gtk_widget_show (options_box); gtk_widget_show (hbox); gtk_widget_show (vbox); @@ -852,16 +833,6 @@ by_color_select_reset_callback (GtkWidget *widget, by_color_select_draw (bcd, bcd->gimage); } -static gint -by_color_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - by_color_select_close_callback (w, client_data); - - return TRUE; -} - static void by_color_select_close_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/channel_ops.c b/app/channel_ops.c index a0309e5502..c61e6748ee 100644 --- a/app/channel_ops.c +++ b/app/channel_ops.c @@ -18,12 +18,12 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "channel_ops.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" @@ -53,7 +53,6 @@ struct _OffsetDialog /* Forward declarations */ static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static gint offset_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void offset_wraparound_update (GtkWidget *, gpointer); static void offset_fill_type_update (GtkWidget *, gpointer); @@ -77,12 +76,6 @@ channel_ops_offset (GimpImage* gimage) GimpDrawable *drawable; - static ActionAreaItem action_items[] = - { - { N_("OK"), offset_ok_callback, NULL, NULL }, - { N_("Cancel"), offset_cancel_callback, NULL, NULL } - }; - drawable = gimage_active_drawable (gimage); off_d = g_new (OffsetDialog, 1); @@ -90,15 +83,19 @@ channel_ops_offset (GimpImage* gimage) off_d->fill_type = drawable_has_alpha (drawable); off_d->gimage = gimage; - off_d->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (off_d->dlg), "offset", "Gimp"); - gtk_window_set_title (GTK_WINDOW (off_d->dlg), _("Offset")); + off_d->dlg = gimp_dialog_new (_("Offset"), "offset", + gimp_standard_help_func, + "dialogs/offset_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (off_d->dlg), "delete_event", - GTK_SIGNAL_FUNC (offset_delete_callback), - off_d); + _("OK"), offset_ok_callback, + off_d, NULL, TRUE, FALSE, + _("Cancel"), offset_cancel_callback, + off_d, NULL, FALSE, TRUE, + NULL); + /* The vbox for first column of options */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -221,15 +218,10 @@ channel_ops_offset (GimpImage* gimage) (GtkSignalFunc) offset_halfheight_callback, off_d); - action_items[0].user_data = off_d; - action_items[1].user_data = off_d; - build_action_area (GTK_DIALOG (off_d->dlg), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (off_d->dlg); } - void offset (GimpImage *gimage, GimpDrawable *drawable, @@ -495,16 +487,6 @@ offset_ok_callback (GtkWidget *widget, g_free (off_d); } -static gint -offset_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - offset_cancel_callback (widget, data); - - return TRUE; -} - static void offset_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/channels_dialog.c b/app/channels_dialog.c index 22b4c9cd97..65eb33dae3 100644 --- a/app/channels_dialog.c +++ b/app/channels_dialog.c @@ -17,7 +17,6 @@ */ #include "gdk/gdkkeysyms.h" #include "appenv.h" -#include "actionarea.h" #include "channels_dialog.h" #include "colormaps.h" #include "color_panel.h" @@ -28,6 +27,7 @@ #include "gimage_mask.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "interface.h" #include "layers_dialogP.h" #include "lc_dialogP.h" @@ -2363,16 +2363,6 @@ new_channel_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -new_channel_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - new_channel_query_cancel_callback (widget, data); - - return TRUE; -} - static void new_channel_query_scale_update (GtkAdjustment *adjustment, gdouble *scale_val) @@ -2391,12 +2381,6 @@ channels_dialog_new_channel_query (GimpImage* gimage) GtkWidget *opacity_scale; GtkObject *opacity_scale_data; - static ActionAreaItem action_items[] = - { - { N_("OK"), new_channel_query_ok_callback, NULL, NULL }, - { N_("Cancel"), new_channel_query_cancel_callback, NULL, NULL } - }; - /* the new options structure */ options = g_new (NewChannelOptions, 1); options->gimage = gimage; @@ -2404,17 +2388,19 @@ channels_dialog_new_channel_query (GimpImage* gimage) 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), - "new_channel_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), - _("New Channel Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("New Channel Options"), "new_channel_options", + gimp_standard_help_func, + "dialogs/channels_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (new_channel_query_delete_callback), - options); + _("OK"), new_channel_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), new_channel_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 2); @@ -2469,11 +2455,6 @@ channels_dialog_new_channel_query (GimpImage* gimage) TRUE, TRUE, 0); gtk_widget_show (options->color_panel->color_panel_widget); - /* The action area */ - action_items[0].user_data = options; - action_items[1].user_data = options; - build_action_area (GTK_DIALOG (options->query_box), action_items, 2, 1); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (hbox); @@ -2558,16 +2539,6 @@ edit_channel_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -edit_channel_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - edit_channel_query_cancel_callback (widget, data); - - return TRUE; -} - static void channels_dialog_edit_channel_query (ChannelWidget *channel_widget) { @@ -2580,12 +2551,6 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget) GtkObject *opacity_scale_data; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), edit_channel_query_ok_callback, NULL, NULL }, - { N_("Cancel"), edit_channel_query_cancel_callback, NULL, NULL } - }; - /* the new options structure */ options = g_new (EditChannelOptions, 1); options->channel_widget = channel_widget; @@ -2597,17 +2562,19 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget) 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_channel_atributes", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), - _("Edit Channel Attributes")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Edit Channel Attributes"), "edit_channel_attributes", + gimp_standard_help_func, + "dialogs/channels_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (edit_channel_query_delete_callback), - options); + _("OK"), edit_channel_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), edit_channel_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 2); @@ -2661,11 +2628,6 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget) TRUE, TRUE, 0); gtk_widget_show (options->color_panel->color_panel_widget); - /* The action area */ - 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); diff --git a/app/color_balance.c b/app/color_balance.c index 6e66f75f05..02db705ef2 100644 --- a/app/color_balance.c +++ b/app/color_balance.c @@ -28,6 +28,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" @@ -69,8 +70,6 @@ static void color_balance_update (ColorBalanceDialog *, int); static void color_balance_preview (ColorBalanceDialog *); static void color_balance_ok_callback (GtkWidget *, gpointer); static void color_balance_cancel_callback (GtkWidget *, gpointer); -static gint color_balance_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void color_balance_shadows_callback (GtkWidget *, gpointer); static void color_balance_midtones_callback (GtkWidget *, gpointer); static void color_balance_highlights_callback (GtkWidget *, gpointer); @@ -253,7 +252,6 @@ color_balance_initialize (GDisplay *gdisp) /* Color Balance dialog */ /**************************/ -/* the action area structure */ static ColorBalanceDialog * color_balance_new_dialog () { @@ -269,15 +267,9 @@ color_balance_new_dialog () GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_balance_ok_callback, NULL, NULL }, - { N_("Cancel"), color_balance_cancel_callback, NULL, NULL } - }; - - char *appl_mode_names[] = + gchar *appl_mode_names[] = { N_("Shadows"), N_("Midtones"), @@ -297,18 +289,21 @@ color_balance_new_dialog () cbd->application_mode = SHADOWS; /* The shell and main vbox */ - cbd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cbd->shell), "color_balance", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cbd->shell), _("Color Balance")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cbd->shell), "delete_event", - GTK_SIGNAL_FUNC (color_balance_delete_callback), - cbd); + cbd->shell = gimp_dialog_new (_("Color Balance"), "color_balance", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), color_balance_ok_callback, + cbd, NULL, TRUE, FALSE, + _("Cancel"), color_balance_cancel_callback, + cbd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cbd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cbd->shell)->vbox), vbox); /* Horizontal box for application mode */ hbox = gtk_hbox_new (TRUE, 2); @@ -473,11 +468,6 @@ color_balance_new_dialog () } gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cbd; - action_items[1].user_data = cbd; - build_action_area (GTK_DIALOG (cbd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (cbd->shell); @@ -614,16 +604,6 @@ color_balance_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -color_balance_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_balance_cancel_callback (w, client_data); - - return TRUE; -} - static void color_balance_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/color_notebook.c b/app/color_notebook.c index bdb4b3739c..39976e007a 100644 --- a/app/color_notebook.c +++ b/app/color_notebook.c @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #define __COLOR_NOTEBOOK_C__ 1 #include "config.h" @@ -29,28 +28,17 @@ #include #include "appenv.h" -#include "actionarea.h" #include "color_notebook.h" +#include "gimpui.h" #include "libgimp/color_selector.h" #include "libgimp/gimpintl.h" - - -static void color_notebook_ok_callback (GtkWidget *, gpointer); +static void color_notebook_ok_callback (GtkWidget *, gpointer); static void color_notebook_cancel_callback (GtkWidget *, gpointer); -static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void color_notebook_update_callback (void *, int, int, int); static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint); - -static ActionAreaItem action_items[2] = -{ - { N_("OK"), color_notebook_ok_callback, NULL, NULL }, - { N_("Cancel"), color_notebook_cancel_callback, NULL, NULL }, -}; - - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo { char *name; /* label used in notebook tab */ @@ -98,28 +86,33 @@ color_notebook_new (int r, g_return_val_if_fail (selector_info != NULL, NULL); - cnp = g_malloc (sizeof (_ColorNotebook)); + cnp = g_new (_ColorNotebook, 1); - cnp->callback = callback; - cnp->client_data = client_data; + cnp->callback = callback; + cnp->client_data = client_data; cnp->wants_updates = wants_updates; - cnp->selectors = NULL; - cnp->cur_page = NULL; + cnp->selectors = NULL; + cnp->cur_page = NULL; - cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; + cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff; - cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; + cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; - /* window hints need to stay the same, so people's window manager - * setups still work */ - cnp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE); + cnp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_notebook_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event", - (GtkSignalFunc) color_notebook_delete_callback, cnp); + wants_updates ? _("Close") : _("OK"), + color_notebook_ok_callback, + cnp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_notebook_cancel_callback, + cnp, NULL, FALSE, TRUE, + + NULL); /* do we actually need a notebook? */ if (selector_info->next) @@ -179,21 +172,6 @@ color_notebook_new (int r, info = info->next; } - /* The action area */ - action_items[0].user_data = cnp; - action_items[1].user_data = cnp; - if (cnp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0); - gtk_widget_show (cnp->shell); /* this must come after showing the widget, otherwise we get a @@ -209,7 +187,6 @@ color_notebook_new (int r, return cnp; } - void color_notebook_show (ColorNotebookP cnp) { @@ -217,7 +194,6 @@ color_notebook_show (ColorNotebookP cnp) gtk_widget_show (cnp->shell); } - void color_notebook_hide (ColorNotebookP cnp) { @@ -253,13 +229,12 @@ color_notebook_free (ColorNotebookP cnp) g_free (cnp); } - void color_notebook_set_color (ColorNotebookP cnp, - int r, - int g, - int b, - int set_current) + int r, + int g, + int b, + int set_current) { ColorSelectorInstance *csel; g_return_if_fail (cnp != NULL); @@ -279,11 +254,12 @@ color_notebook_set_color (ColorNotebookP cnp, csel->info->m.setcolor (csel->selector_data, r, g, b, set_current); } - - /* Called by a colour selector on user selection of a colour */ static void -color_notebook_update_callback (void *data, int r, int g, int b) +color_notebook_update_callback (void *data, + int r, + int g, + int b) { ColorSelectorInstance *csel; ColorNotebookP cnp; @@ -307,16 +283,13 @@ color_notebook_update_callback (void *data, int r, int g, int b) } } - - - static void -color_notebook_ok_callback (GtkWidget *w, - gpointer client_data) +color_notebook_ok_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->values[RED], @@ -326,25 +299,13 @@ color_notebook_ok_callback (GtkWidget *w, cnp->client_data); } - -static gint -color_notebook_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_notebook_cancel_callback (w, client_data); - - return TRUE; -} - - static void -color_notebook_cancel_callback (GtkWidget *w, - gpointer client_data) +color_notebook_cancel_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->orig_values[RED], @@ -355,14 +316,14 @@ color_notebook_cancel_callback (GtkWidget *w, } static void -color_notebook_page_switch (GtkWidget *w, +color_notebook_page_switch (GtkWidget *widget, GtkNotebookPage *page, guint page_num) { ColorNotebookP cnp; ColorSelectorInstance *csel; - cnp = gtk_object_get_user_data (GTK_OBJECT (w)); + cnp = gtk_object_get_user_data (GTK_OBJECT (widget)); csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook"); g_return_if_fail (cnp != NULL && csel != NULL); @@ -466,5 +427,4 @@ selector_death (ColorSelectorInfo *info) g_warning ("color selector %p not found, can't happen!", info); } - /* End of color_notebook.c */ diff --git a/app/color_picker.c b/app/color_picker.c index c38ac4be79..612edf0e06 100644 --- a/app/color_picker.c +++ b/app/color_picker.c @@ -22,6 +22,7 @@ #include "draw_core.h" #include "drawable.h" #include "gdisplay.h" +#include "gimphelp.h" #include "cursorutil.h" #include "info_dialog.h" #include "palette.h" @@ -248,7 +249,8 @@ color_picker_button_press (Tool *tool, { GtkWidget *hbox; - color_picker_info = info_dialog_new (_("Color Picker")); + color_picker_info = info_dialog_new (_("Color Picker"), + tools_help_func, NULL); /* if the gdisplay is for a color image, the dialog must have RGB */ switch (drawable_type (tool->drawable)) diff --git a/app/color_select.c b/app/color_select.c index 1108664b37..8222bbd0c0 100644 --- a/app/color_select.c +++ b/app/color_select.c @@ -16,16 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include #include #include + #include "appenv.h" -#include "actionarea.h" #include "color_select.h" #include "colormaps.h" #include "errors.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "session.h" #include "color_area.h" /* for color_area_draw_rect */ @@ -110,7 +112,6 @@ static void color_select_update_colors (ColorSelect *, gint); static void color_select_ok_callback (GtkWidget *, gpointer); static void color_select_cancel_callback (GtkWidget *, gpointer); -static gint color_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static gint color_select_xy_expose (GtkWidget *, GdkEventExpose *, ColorSelect *); static gint color_select_xy_events (GtkWidget *, GdkEvent *, @@ -190,12 +191,6 @@ color_select_new (gint r, ColorSelect *csp; GtkWidget *main_vbox; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_select_ok_callback, NULL, NULL }, - { N_("Cancel"), color_select_cancel_callback, NULL, NULL } - }; - csp = g_new (ColorSelect, 1); csp->callback = callback; @@ -211,37 +206,26 @@ color_select_new (gint r, color_select_update_hsv_values (csp); color_select_update_pos (csp); - csp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (csp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (csp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (csp->shell), FALSE, FALSE, FALSE); + csp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, + wants_updates ? _("Close") : _("OK"), + color_select_ok_callback, + csp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_select_cancel_callback, + csp, NULL, FALSE, TRUE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (csp->shell), "delete_event", - (GtkSignalFunc) color_select_delete_callback, csp); + NULL); main_vbox = color_select_widget_new (csp, r, g, b); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (csp->shell)->vbox), main_vbox); gtk_widget_show (main_vbox); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, - TRUE, TRUE, 0); - - /* The action area */ - action_items[0].user_data = csp; - action_items[1].user_data = csp; - if (csp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0); - color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values); color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values); @@ -997,16 +981,6 @@ color_select_ok_callback (GtkWidget *widget, } } -static gint -color_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - color_select_cancel_callback (widget, data); - - return TRUE; -} - static void color_select_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/commands.c b/app/commands.c index 344fd7017d..9dc31ff075 100644 --- a/app/commands.c +++ b/app/commands.c @@ -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) diff --git a/app/commands.h b/app/commands.h index aba3d13a1e..7dbf589d23 100644 --- a/app/commands.h +++ b/app/commands.h @@ -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__ */ diff --git a/app/convert.c b/app/convert.c index 0df5f9247a..7525cc7742 100644 --- a/app/convert.c +++ b/app/convert.c @@ -86,17 +86,16 @@ #include #include "appenv.h" -#include "actionarea.h" #include "convert.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "fsdither.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "undo.h" #include "palette.h" -#include "preferences_dialog.h" /* ick. */ #include "libgimp/gimpintl.h" #include "libgimp/gimpmath.h" @@ -393,7 +392,6 @@ typedef struct static void indexed_ok_callback (GtkWidget *, gpointer); static void indexed_cancel_callback (GtkWidget *, gpointer); -static gint indexed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void indexed_num_cols_update (GtkWidget *, gpointer); static void indexed_radio_update (GtkWidget *, gpointer); static void frame_sensitivity_update (GtkWidget *, gpointer); @@ -457,13 +455,6 @@ convert_to_grayscale (GimpImage* gimage) gdisplays_flush (); } -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("OK"), indexed_ok_callback, NULL, NULL }, - { N_("Cancel"), indexed_cancel_callback, NULL, NULL } -}; - void convert_to_indexed (GimpImage *gimage) { @@ -478,7 +469,7 @@ convert_to_indexed (GimpImage *gimage) GSList *group = NULL; gint maxval; - dialog = g_new(IndexedDialog, 1); + dialog = g_new (IndexedDialog, 1); dialog->gimage = gimage; dialog->custom_frame = NULL; @@ -496,21 +487,31 @@ convert_to_indexed (GimpImage *gimage) dialog->monopal_flag = smonopal_flag; dialog->reusepal_flag = sreusepal_flag; - dialog->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog->shell), "indexed_color_conversion", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog->shell), _("Indexed Color Conversion")); - gtk_signal_connect (GTK_OBJECT (dialog->shell), "delete_event", - GTK_SIGNAL_FUNC (indexed_delete_callback), - dialog); + dialog->shell = + gimp_dialog_new (_("Indexed Color Conversion"), "indexed_color_conversion", + gimp_standard_help_func, + "dialogs/indexed_color_conversion_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), indexed_ok_callback, + dialog, NULL, TRUE, FALSE, + _("Cancel"), indexed_cancel_callback, + dialog, NULL, FALSE, TRUE, + + NULL); frame = gtk_frame_new (_("General Palette Options")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); gtk_container_set_border_width (GTK_CONTAINER (frame), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox), frame, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox), frame, + TRUE, TRUE, 0); + gtk_widget_show(frame); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_container_set_border_width (GTK_CONTAINER (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox)), 4); + /* put the vbox in the frame */ gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show(vbox); @@ -823,11 +824,6 @@ convert_to_indexed (GimpImage *gimage) gtk_widget_show(frame); } - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (dialog->shell); } @@ -957,16 +953,6 @@ indexed_ok_callback (GtkWidget *widget, dialog = NULL; } -static gint -indexed_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - indexed_cancel_callback (w, client_data); - - return TRUE; -} - static void indexed_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c index 3c521ef96c..2aa1d78983 100644 --- a/app/core/gimp-edit.c +++ b/app/core/gimp-edit.c @@ -24,8 +24,8 @@ #include "gdisplay.h" #include "gimage.h" #include "gimage_mask.h" +#include "gimpui.h" #include "global_edit.h" -#include "interface.h" #include "layer.h" #include "paint_funcs.h" #include "tools.h" @@ -666,12 +666,12 @@ named_buffer_delete_callback (GtkWidget *w, } static void -named_buffer_cancel_callback (GtkWidget *w, - gpointer client_data) +named_buffer_cancel_callback (GtkWidget *widget, + gpointer data) { PasteNamedDlg *pn_dlg; - pn_dlg = (PasteNamedDlg *) client_data; + pn_dlg = (PasteNamedDlg *) data; /* Destroy the box */ gtk_widget_destroy (pn_dlg->shell); @@ -679,16 +679,6 @@ named_buffer_cancel_callback (GtkWidget *w, g_free (pn_dlg); } -static gint -named_buffer_dialog_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - named_buffer_cancel_callback (w, client_data); - - return TRUE; -} - static void paste_named_buffer (GDisplay *gdisp) { @@ -706,27 +696,27 @@ paste_named_buffer (GDisplay *gdisp) { N_("Paste Into"), named_buffer_paste_into_callback, NULL, NULL }, { N_("Paste As New"), named_buffer_paste_as_new_callback, NULL, NULL } }; - static ActionAreaItem other_action_items[] = - { - { N_("Delete"), named_buffer_delete_callback, NULL, NULL }, - { N_("Cancel"), named_buffer_cancel_callback, NULL, NULL } - }; - pn_dlg = (PasteNamedDlg *) g_malloc (sizeof (PasteNamedDlg)); + pn_dlg = g_new (PasteNamedDlg, 1); pn_dlg->gdisp = gdisp; - - pn_dlg->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (pn_dlg->shell), "paste_named_buffer", "Gimp"); - gtk_window_set_title (GTK_WINDOW (pn_dlg->shell), _("Paste Named Buffer")); - gtk_window_position (GTK_WINDOW (pn_dlg->shell), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (pn_dlg->shell), "delete_event", - GTK_SIGNAL_FUNC (named_buffer_dialog_delete_callback), - pn_dlg); + pn_dlg->shell = + gimp_dialog_new (_("Paste Named Buffer"), "paste_named_buffer", + gimp_standard_help_func, + "dialogs/paste_named_buffer_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, + _("Delete"), named_buffer_delete_callback, + pn_dlg, NULL, FALSE, FALSE, + _("Cancel"), named_buffer_cancel_callback, + pn_dlg, NULL, TRUE, TRUE, + + NULL); + vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pn_dlg->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pn_dlg->shell)->vbox), vbox); gtk_widget_show (vbox); label = gtk_label_new (_("Select a buffer to paste:")); @@ -763,10 +753,6 @@ paste_named_buffer (GDisplay *gdisp) } gtk_widget_show (bbox); - other_action_items[0].user_data = pn_dlg; - other_action_items[1].user_data = pn_dlg; - build_action_area (GTK_DIALOG (pn_dlg->shell), other_action_items, 2, 1); - gtk_widget_show (pn_dlg->shell); } @@ -791,7 +777,7 @@ new_named_buffer (TileManager *tiles, } static void -cut_named_buffer_callback (GtkWidget *w, +cut_named_buffer_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { @@ -811,22 +797,27 @@ cut_named_buffer_callback (GtkWidget *w, int named_edit_cut (void *gdisp_ptr) { - GDisplay *gdisp; + GtkWidget *qbox; + GDisplay *gdisp; /* stop any active tool */ gdisp = (GDisplay *) gdisp_ptr; active_tool_control (HALT, gdisp_ptr); - gtk_widget_show (query_string_box (_("Cut Named"), - _("Enter a name for this buffer"), - NULL, - GTK_OBJECT (gdisp->gimage), "destroy", - cut_named_buffer_callback, gdisp)); + qbox = gimp_query_string_box (_("Cut Named"), + gimp_standard_help_func, + "dialogs/cut_named_dialog.html", + _("Enter a name for this buffer"), + NULL, + GTK_OBJECT (gdisp->gimage), "destroy", + cut_named_buffer_callback, gdisp); + gtk_widget_show (qbox); + return TRUE; } static void -copy_named_buffer_callback (GtkWidget *w, +copy_named_buffer_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { @@ -845,15 +836,20 @@ copy_named_buffer_callback (GtkWidget *w, int named_edit_copy (void *gdisp_ptr) { - GDisplay *gdisp; + GtkWidget *qbox; + GDisplay *gdisp; gdisp = (GDisplay *) gdisp_ptr; - - gtk_widget_show (query_string_box (_("Copy Named"), - _("Enter a name for this buffer"), - NULL, - GTK_OBJECT (gdisp->gimage), "destroy", - copy_named_buffer_callback, gdisp)); + + qbox = gimp_query_string_box (_("Copy Named"), + gimp_standard_help_func, + "dialogs/copy_named_dialog.html", + _("Enter a name for this buffer"), + NULL, + GTK_OBJECT (gdisp->gimage), "destroy", + copy_named_buffer_callback, gdisp); + gtk_widget_show (qbox); + return TRUE; } diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c index a0309e5502..c61e6748ee 100644 --- a/app/core/gimpdrawable-offset.c +++ b/app/core/gimpdrawable-offset.c @@ -18,12 +18,12 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "channel_ops.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" @@ -53,7 +53,6 @@ struct _OffsetDialog /* Forward declarations */ static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static gint offset_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void offset_wraparound_update (GtkWidget *, gpointer); static void offset_fill_type_update (GtkWidget *, gpointer); @@ -77,12 +76,6 @@ channel_ops_offset (GimpImage* gimage) GimpDrawable *drawable; - static ActionAreaItem action_items[] = - { - { N_("OK"), offset_ok_callback, NULL, NULL }, - { N_("Cancel"), offset_cancel_callback, NULL, NULL } - }; - drawable = gimage_active_drawable (gimage); off_d = g_new (OffsetDialog, 1); @@ -90,15 +83,19 @@ channel_ops_offset (GimpImage* gimage) off_d->fill_type = drawable_has_alpha (drawable); off_d->gimage = gimage; - off_d->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (off_d->dlg), "offset", "Gimp"); - gtk_window_set_title (GTK_WINDOW (off_d->dlg), _("Offset")); + off_d->dlg = gimp_dialog_new (_("Offset"), "offset", + gimp_standard_help_func, + "dialogs/offset_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (off_d->dlg), "delete_event", - GTK_SIGNAL_FUNC (offset_delete_callback), - off_d); + _("OK"), offset_ok_callback, + off_d, NULL, TRUE, FALSE, + _("Cancel"), offset_cancel_callback, + off_d, NULL, FALSE, TRUE, + NULL); + /* The vbox for first column of options */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -221,15 +218,10 @@ channel_ops_offset (GimpImage* gimage) (GtkSignalFunc) offset_halfheight_callback, off_d); - action_items[0].user_data = off_d; - action_items[1].user_data = off_d; - build_action_area (GTK_DIALOG (off_d->dlg), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (off_d->dlg); } - void offset (GimpImage *gimage, GimpDrawable *drawable, @@ -495,16 +487,6 @@ offset_ok_callback (GtkWidget *widget, g_free (off_d); } -static gint -offset_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - offset_cancel_callback (widget, data); - - return TRUE; -} - static void offset_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/core/gimpedit.c b/app/core/gimpedit.c index 3c521ef96c..2aa1d78983 100644 --- a/app/core/gimpedit.c +++ b/app/core/gimpedit.c @@ -24,8 +24,8 @@ #include "gdisplay.h" #include "gimage.h" #include "gimage_mask.h" +#include "gimpui.h" #include "global_edit.h" -#include "interface.h" #include "layer.h" #include "paint_funcs.h" #include "tools.h" @@ -666,12 +666,12 @@ named_buffer_delete_callback (GtkWidget *w, } static void -named_buffer_cancel_callback (GtkWidget *w, - gpointer client_data) +named_buffer_cancel_callback (GtkWidget *widget, + gpointer data) { PasteNamedDlg *pn_dlg; - pn_dlg = (PasteNamedDlg *) client_data; + pn_dlg = (PasteNamedDlg *) data; /* Destroy the box */ gtk_widget_destroy (pn_dlg->shell); @@ -679,16 +679,6 @@ named_buffer_cancel_callback (GtkWidget *w, g_free (pn_dlg); } -static gint -named_buffer_dialog_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - named_buffer_cancel_callback (w, client_data); - - return TRUE; -} - static void paste_named_buffer (GDisplay *gdisp) { @@ -706,27 +696,27 @@ paste_named_buffer (GDisplay *gdisp) { N_("Paste Into"), named_buffer_paste_into_callback, NULL, NULL }, { N_("Paste As New"), named_buffer_paste_as_new_callback, NULL, NULL } }; - static ActionAreaItem other_action_items[] = - { - { N_("Delete"), named_buffer_delete_callback, NULL, NULL }, - { N_("Cancel"), named_buffer_cancel_callback, NULL, NULL } - }; - pn_dlg = (PasteNamedDlg *) g_malloc (sizeof (PasteNamedDlg)); + pn_dlg = g_new (PasteNamedDlg, 1); pn_dlg->gdisp = gdisp; - - pn_dlg->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (pn_dlg->shell), "paste_named_buffer", "Gimp"); - gtk_window_set_title (GTK_WINDOW (pn_dlg->shell), _("Paste Named Buffer")); - gtk_window_position (GTK_WINDOW (pn_dlg->shell), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (pn_dlg->shell), "delete_event", - GTK_SIGNAL_FUNC (named_buffer_dialog_delete_callback), - pn_dlg); + pn_dlg->shell = + gimp_dialog_new (_("Paste Named Buffer"), "paste_named_buffer", + gimp_standard_help_func, + "dialogs/paste_named_buffer_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, + _("Delete"), named_buffer_delete_callback, + pn_dlg, NULL, FALSE, FALSE, + _("Cancel"), named_buffer_cancel_callback, + pn_dlg, NULL, TRUE, TRUE, + + NULL); + vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pn_dlg->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pn_dlg->shell)->vbox), vbox); gtk_widget_show (vbox); label = gtk_label_new (_("Select a buffer to paste:")); @@ -763,10 +753,6 @@ paste_named_buffer (GDisplay *gdisp) } gtk_widget_show (bbox); - other_action_items[0].user_data = pn_dlg; - other_action_items[1].user_data = pn_dlg; - build_action_area (GTK_DIALOG (pn_dlg->shell), other_action_items, 2, 1); - gtk_widget_show (pn_dlg->shell); } @@ -791,7 +777,7 @@ new_named_buffer (TileManager *tiles, } static void -cut_named_buffer_callback (GtkWidget *w, +cut_named_buffer_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { @@ -811,22 +797,27 @@ cut_named_buffer_callback (GtkWidget *w, int named_edit_cut (void *gdisp_ptr) { - GDisplay *gdisp; + GtkWidget *qbox; + GDisplay *gdisp; /* stop any active tool */ gdisp = (GDisplay *) gdisp_ptr; active_tool_control (HALT, gdisp_ptr); - gtk_widget_show (query_string_box (_("Cut Named"), - _("Enter a name for this buffer"), - NULL, - GTK_OBJECT (gdisp->gimage), "destroy", - cut_named_buffer_callback, gdisp)); + qbox = gimp_query_string_box (_("Cut Named"), + gimp_standard_help_func, + "dialogs/cut_named_dialog.html", + _("Enter a name for this buffer"), + NULL, + GTK_OBJECT (gdisp->gimage), "destroy", + cut_named_buffer_callback, gdisp); + gtk_widget_show (qbox); + return TRUE; } static void -copy_named_buffer_callback (GtkWidget *w, +copy_named_buffer_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { @@ -845,15 +836,20 @@ copy_named_buffer_callback (GtkWidget *w, int named_edit_copy (void *gdisp_ptr) { - GDisplay *gdisp; + GtkWidget *qbox; + GDisplay *gdisp; gdisp = (GDisplay *) gdisp_ptr; - - gtk_widget_show (query_string_box (_("Copy Named"), - _("Enter a name for this buffer"), - NULL, - GTK_OBJECT (gdisp->gimage), "destroy", - copy_named_buffer_callback, gdisp)); + + qbox = gimp_query_string_box (_("Copy Named"), + gimp_standard_help_func, + "dialogs/copy_named_dialog.html", + _("Enter a name for this buffer"), + NULL, + GTK_OBJECT (gdisp->gimage), "destroy", + copy_named_buffer_callback, gdisp); + gtk_widget_show (qbox); + return TRUE; } diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c index 0df5f9247a..7525cc7742 100644 --- a/app/core/gimpimage-convert.c +++ b/app/core/gimpimage-convert.c @@ -86,17 +86,16 @@ #include #include "appenv.h" -#include "actionarea.h" #include "convert.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "fsdither.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "undo.h" #include "palette.h" -#include "preferences_dialog.h" /* ick. */ #include "libgimp/gimpintl.h" #include "libgimp/gimpmath.h" @@ -393,7 +392,6 @@ typedef struct static void indexed_ok_callback (GtkWidget *, gpointer); static void indexed_cancel_callback (GtkWidget *, gpointer); -static gint indexed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void indexed_num_cols_update (GtkWidget *, gpointer); static void indexed_radio_update (GtkWidget *, gpointer); static void frame_sensitivity_update (GtkWidget *, gpointer); @@ -457,13 +455,6 @@ convert_to_grayscale (GimpImage* gimage) gdisplays_flush (); } -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("OK"), indexed_ok_callback, NULL, NULL }, - { N_("Cancel"), indexed_cancel_callback, NULL, NULL } -}; - void convert_to_indexed (GimpImage *gimage) { @@ -478,7 +469,7 @@ convert_to_indexed (GimpImage *gimage) GSList *group = NULL; gint maxval; - dialog = g_new(IndexedDialog, 1); + dialog = g_new (IndexedDialog, 1); dialog->gimage = gimage; dialog->custom_frame = NULL; @@ -496,21 +487,31 @@ convert_to_indexed (GimpImage *gimage) dialog->monopal_flag = smonopal_flag; dialog->reusepal_flag = sreusepal_flag; - dialog->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog->shell), "indexed_color_conversion", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog->shell), _("Indexed Color Conversion")); - gtk_signal_connect (GTK_OBJECT (dialog->shell), "delete_event", - GTK_SIGNAL_FUNC (indexed_delete_callback), - dialog); + dialog->shell = + gimp_dialog_new (_("Indexed Color Conversion"), "indexed_color_conversion", + gimp_standard_help_func, + "dialogs/indexed_color_conversion_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), indexed_ok_callback, + dialog, NULL, TRUE, FALSE, + _("Cancel"), indexed_cancel_callback, + dialog, NULL, FALSE, TRUE, + + NULL); frame = gtk_frame_new (_("General Palette Options")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); gtk_container_set_border_width (GTK_CONTAINER (frame), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox), frame, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox), frame, + TRUE, TRUE, 0); + gtk_widget_show(frame); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_container_set_border_width (GTK_CONTAINER (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox)), 4); + /* put the vbox in the frame */ gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show(vbox); @@ -823,11 +824,6 @@ convert_to_indexed (GimpImage *gimage) gtk_widget_show(frame); } - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (dialog->shell); } @@ -957,16 +953,6 @@ indexed_ok_callback (GtkWidget *widget, dialog = NULL; } -static gint -indexed_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - indexed_cancel_callback (w, client_data); - - return TRUE; -} - static void indexed_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index a0309e5502..c61e6748ee 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -18,12 +18,12 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "channel_ops.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" @@ -53,7 +53,6 @@ struct _OffsetDialog /* Forward declarations */ static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static gint offset_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void offset_wraparound_update (GtkWidget *, gpointer); static void offset_fill_type_update (GtkWidget *, gpointer); @@ -77,12 +76,6 @@ channel_ops_offset (GimpImage* gimage) GimpDrawable *drawable; - static ActionAreaItem action_items[] = - { - { N_("OK"), offset_ok_callback, NULL, NULL }, - { N_("Cancel"), offset_cancel_callback, NULL, NULL } - }; - drawable = gimage_active_drawable (gimage); off_d = g_new (OffsetDialog, 1); @@ -90,15 +83,19 @@ channel_ops_offset (GimpImage* gimage) off_d->fill_type = drawable_has_alpha (drawable); off_d->gimage = gimage; - off_d->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (off_d->dlg), "offset", "Gimp"); - gtk_window_set_title (GTK_WINDOW (off_d->dlg), _("Offset")); + off_d->dlg = gimp_dialog_new (_("Offset"), "offset", + gimp_standard_help_func, + "dialogs/offset_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (off_d->dlg), "delete_event", - GTK_SIGNAL_FUNC (offset_delete_callback), - off_d); + _("OK"), offset_ok_callback, + off_d, NULL, TRUE, FALSE, + _("Cancel"), offset_cancel_callback, + off_d, NULL, FALSE, TRUE, + NULL); + /* The vbox for first column of options */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -221,15 +218,10 @@ channel_ops_offset (GimpImage* gimage) (GtkSignalFunc) offset_halfheight_callback, off_d); - action_items[0].user_data = off_d; - action_items[1].user_data = off_d; - build_action_area (GTK_DIALOG (off_d->dlg), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (off_d->dlg); } - void offset (GimpImage *gimage, GimpDrawable *drawable, @@ -495,16 +487,6 @@ offset_ok_callback (GtkWidget *widget, g_free (off_d); } -static gint -offset_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - offset_cancel_callback (widget, data); - - return TRUE; -} - static void offset_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/core/gimpimage-qmask.c b/app/core/gimpimage-qmask.c index 29c2706729..5dea7de4c1 100644 --- a/app/core/gimpimage-qmask.c +++ b/app/core/gimpimage-qmask.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/core/gimpimage-quick-mask.c b/app/core/gimpimage-quick-mask.c index 29c2706729..5dea7de4c1 100644 --- a/app/core/gimpimage-quick-mask.c +++ b/app/core/gimpimage-quick-mask.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/crop.c b/app/crop.c index f461d376e4..ef02ec6c87 100644 --- a/app/crop.c +++ b/app/crop.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include #include "gdk/gdkkeysyms.h" @@ -28,6 +27,7 @@ #include "floating_sel.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimphelp.h" #include "info_dialog.h" #include "tool_options_ui.h" #include "undo.h" @@ -1030,7 +1030,8 @@ crop_info_create (Tool *tool) gdisp = (GDisplay *) tool->gdisp_ptr; /* create the info dialog */ - crop_info = info_dialog_new (_("Crop & Resize Information")); + crop_info = info_dialog_new (_("Crop & Resize Information"), + tools_help_func, NULL); /* add the information fields */ spinbutton = info_dialog_add_spinbutton (crop_info, _("Origin X:"), NULL, diff --git a/app/curves.c b/app/curves.c index b80a204d07..60b11f4044 100644 --- a/app/curves.c +++ b/app/curves.c @@ -21,7 +21,6 @@ #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "cursorutil.h" @@ -29,6 +28,7 @@ #include "general.h" #include "gdisplay.h" #include "gimphistogram.h" +#include "gimpui.h" #include "interface.h" #include "curves.h" #include "gimplut.h" @@ -114,7 +114,6 @@ static void curves_free_callback (GtkWidget *, gpointer); static void curves_reset_callback (GtkWidget *, gpointer); static void curves_ok_callback (GtkWidget *, gpointer); static void curves_cancel_callback (GtkWidget *, gpointer); -static gint curves_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void curves_preview_update (GtkWidget *, gpointer); static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); @@ -519,14 +518,7 @@ curves_new_dialog () GtkWidget *channel_hbox; GtkWidget *menu; GtkWidget *table; - int i, j; - - static ActionAreaItem action_items[] = - { - { N_("Reset"), curves_reset_callback, NULL, NULL }, - { N_("OK"), curves_ok_callback, NULL, NULL }, - { N_("Cancel"), curves_cancel_callback, NULL, NULL } - }; + gint i, j; static MenuItem curve_type_items[] = { @@ -535,7 +527,7 @@ curves_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - cd = g_malloc (sizeof (CurvesDialog)); + cd = g_new (CurvesDialog, 1); cd->cursor_ind_height = cd->cursor_ind_width = -1; cd->preview = TRUE; cd->curve_type = SMOOTH; @@ -556,17 +548,23 @@ curves_new_dialog () curve_type_items [i].user_data = (gpointer) cd; /* The shell and main vbox */ - cd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cd->shell), "curves", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cd->shell), _("Curves")); + cd->shell = gimp_dialog_new (_("Curves"), "curves", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Reset"), curves_reset_callback, + cd, NULL, FALSE, FALSE, + _("OK"), curves_ok_callback, + cd, NULL, TRUE, FALSE, + _("Cancel"), curves_cancel_callback, + cd, NULL, FALSE, TRUE, + + NULL); - gtk_signal_connect (GTK_OBJECT (cd->shell), "delete_event", - GTK_SIGNAL_FUNC (curves_delete_callback), - cd); - vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cd->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -670,12 +668,6 @@ curves_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cd; - action_items[1].user_data = cd; - action_items[2].user_data = cd; - build_action_area (GTK_DIALOG (cd->shell), action_items, 3, 0); - gtk_widget_show (vbox); return cd; @@ -1278,24 +1270,15 @@ curves_cancel_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -curves_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - curves_cancel_callback (w, data); - - return TRUE; -} static void -curves_preview_update (GtkWidget *w, +curves_preview_update (GtkWidget *widget, gpointer data) { CurvesDialog *cd; cd = (CurvesDialog *) data; - if (GTK_TOGGLE_BUTTON (w)->active) + if (GTK_TOGGLE_BUTTON (widget)->active) { cd->preview = TRUE; curves_preview (cd); diff --git a/app/devices.c b/app/devices.c index 9faa2b0ea4..4ca834935d 100644 --- a/app/devices.c +++ b/app/devices.c @@ -15,19 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "config.h" #include #include #include "appenv.h" -#include "actionarea.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "devices.h" #include "interface.h" #include "gimprc.h" +#include "gimpui.h" #include "palette.h" #include "session.h" #include "tools.h" @@ -63,7 +62,7 @@ struct _DeviceInfo { GimpBrushP brush; GPatternP pattern; ToolType tool; - unsigned char foreground[3]; + guchar foreground[3]; }; typedef struct _DeviceInfoDialog DeviceInfoDialog; @@ -115,13 +114,6 @@ static void device_status_drop_pattern (GtkWidget *, /* Global data */ int current_device = GDK_CORE_POINTER; -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Save"), (ActionCallback)devices_write_rc, NULL, NULL }, - { N_("Close"), devices_close_callback, NULL, NULL } -}; - /* dnd stuff */ static GtkTargetEntry color_area_target_table[] = { @@ -151,17 +143,17 @@ create_input_dialog (void) if (!inputd) { - inputd = gtk_input_dialog_new(); + inputd = gtk_input_dialog_new (); /* register this one only */ - dialog_register(inputd); + dialog_register (inputd); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area), FALSE); - hbbox = gtk_hbutton_box_new(); - gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbbox), 4); + hbbox = gtk_hbutton_box_new (); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox); GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button, @@ -170,46 +162,52 @@ create_input_dialog (void) GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button, GTK_CAN_DEFAULT); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, - FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, + FALSE, FALSE, 0); gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button); gtk_widget_show(hbbox); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button), + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button), "clicked", - GTK_SIGNAL_FUNC(devices_write_rc), NULL); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), + GTK_SIGNAL_FUNC (devices_write_rc), NULL); + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button), "clicked", - GTK_SIGNAL_FUNC(devices_close_callback), inputd); + GTK_SIGNAL_FUNC (devices_close_callback), inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "destroy", - (GtkSignalFunc)input_dialog_destroy_callback, + gtk_signal_connect (GTK_OBJECT (inputd), "destroy", + (GtkSignalFunc) input_dialog_destroy_callback, &inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "enable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); - gtk_signal_connect (GTK_OBJECT(inputd), "disable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "enable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "disable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (inputd, + gimp_standard_help_func, + "dialogs/input_devices_dialog.html"); + gtk_widget_show (inputd); } else { - if (!GTK_WIDGET_MAPPED(inputd)) - gtk_widget_show(inputd); + if (!GTK_WIDGET_MAPPED (inputd)) + gtk_widget_show (inputd); else - gdk_window_raise(inputd->window); + gdk_window_raise (inputd->window); } } void -input_dialog_able_callback (GtkWidget *w, - guint32 deviceid, +input_dialog_able_callback (GtkWidget *widget, + guint32 deviceid, gpointer data) { device_status_update (deviceid); } static void -input_dialog_destroy_callback (GtkWidget *w, +input_dialog_destroy_callback (GtkWidget *widget, gpointer call_data) { *((GtkWidget **)call_data) = NULL; @@ -223,7 +221,7 @@ devices_init (void) /* Create device info structures for present devices */ tmp_list = gdk_input_list_devices (); - + while (tmp_list) { GdkDeviceInfo *gdk_info = (GdkDeviceInfo *)tmp_list->data; @@ -528,7 +526,7 @@ devices_save_current_info (void) device_info->is_init = TRUE; device_info->device = current_device; device_info->brush = get_active_brush (); - device_info->pattern = get_active_pattern(); + device_info->pattern = get_active_pattern (); if (active_tool) device_info->tool = active_tool->type; else @@ -539,7 +537,7 @@ devices_save_current_info (void) } static void -devices_write_rc_device (DeviceInfo *device_info, +devices_write_rc_device (DeviceInfo *device_info, FILE *fp) { GdkDeviceInfo *gdk_info; @@ -552,7 +550,7 @@ devices_write_rc_device (DeviceInfo *device_info, { /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ - tmp_list = gdk_input_list_devices(); + tmp_list = gdk_input_list_devices (); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; @@ -566,7 +564,7 @@ devices_write_rc_device (DeviceInfo *device_info, } } - fprintf(fp, "(device \"%s\"",device_info->name); + fprintf (fp, "(device \"%s\"",device_info->name); switch (gdk_info ? gdk_info->mode : device_info->mode) { @@ -581,9 +579,10 @@ devices_write_rc_device (DeviceInfo *device_info, break; } - fprintf(fp, "\n (mode %s)",mode); + fprintf (fp, "\n (mode %s)", mode); - fprintf(fp, "\n (axes %d",gdk_info ? gdk_info->num_axes : device_info->num_axes); + fprintf (fp, "\n (axes %d", + gdk_info ? gdk_info->num_axes : device_info->num_axes); for (i=0; i<(gdk_info ? gdk_info->num_axes : device_info->num_axes); i++) { @@ -615,19 +614,20 @@ devices_write_rc_device (DeviceInfo *device_info, break; #endif /* GTK_HAVE_SIX_VALUATORS */ } - fprintf(fp, " %s",axis_type); + fprintf (fp, " %s",axis_type); } - fprintf(fp,")"); + fprintf (fp,")"); - fprintf(fp, "\n (keys %d", gdk_info ? gdk_info->num_keys : device_info->num_keys); + fprintf (fp, "\n (keys %d", + gdk_info ? gdk_info->num_keys : device_info->num_keys); - for (i=0; i<(gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) + for (i=0; i < (gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) { GdkModifierType modifiers = gdk_info ? gdk_info->keys[i].modifiers : device_info->keys[i].modifiers; guint keyval = gdk_info ? gdk_info->keys[i].keyval : device_info->keys[i].keyval; - + if (keyval) { /* FIXME: integrate this back with menus_install_accelerator */ @@ -650,22 +650,22 @@ devices_write_rc_device (DeviceInfo *device_info, else fprintf (fp, " \"\""); } - fprintf(fp,")"); + fprintf (fp,")"); if (device_info->is_init) { if (device_info->brush) - fprintf(fp, "\n (brush \"%s\")",device_info->brush->name); + fprintf (fp, "\n (brush \"%s\")",device_info->brush->name); if (device_info->pattern) - fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name); + fprintf (fp, "\n (pattern \"%s\")",device_info->pattern->name); /* Fixme: hard coded last tool.... see gimprc */ if (device_info->tool && device_info->tool <= LAST_TOOLBOX_TOOL) - fprintf(fp, "\n (tool \"%s\")", - tool_info[device_info->tool].tool_name); - fprintf(fp, "\n (foreground %d %d %d)", - device_info->foreground[0], - device_info->foreground[1], - device_info->foreground[2]); + fprintf (fp, "\n (tool \"%s\")", + tool_info[device_info->tool].tool_name); + fprintf (fp, "\n (foreground %d %d %d)", + device_info->foreground[0], + device_info->foreground[1], + device_info->foreground[2]); } fprintf(fp,")\n"); @@ -702,18 +702,25 @@ create_device_status (void) if (deviceD == NULL) { deviceD = g_new (DeviceInfoDialog, 1); - deviceD->shell = gtk_dialog_new (); + + deviceD->shell = + gimp_dialog_new (_("Device Status"), "device_status", + gimp_standard_help_func, + "dialogs/device_status_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, TRUE, + + _("Save"), (GtkSignalFunc) devices_write_rc, + NULL, NULL, FALSE, FALSE, + _("Close"), devices_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* register this one only */ - dialog_register(deviceD->shell); - - gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status")); - gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE); - /* don't set the dialog's size, as the number of devices may have - * changed since the last session - */ - session_set_window_geometry (deviceD->shell, - &device_status_session_info, FALSE); + dialog_register (deviceD->shell); + session_set_window_geometry (deviceD->shell, &device_status_session_info, + FALSE); deviceD->num_devices = 0; tmp_list = devices_info; @@ -723,10 +730,10 @@ create_device_status (void) deviceD->num_devices++; tmp_list = tmp_list->next; } -/* devices table */ + /* devices table */ deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE); - gtk_container_set_border_width (GTK_CONTAINER(deviceD->table), 3); - gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox), + gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox), deviceD->table); gtk_widget_realize (deviceD->table); gtk_widget_show (deviceD->table); @@ -841,9 +848,6 @@ create_device_status (void) i++; } - action_items[1].user_data = deviceD->shell; - build_action_area (GTK_DIALOG (deviceD->shell), action_items, 2, 1); - deviceD->current = 0xffffffff; /* random, but doesn't matter */ device_status_update_current (); @@ -878,7 +882,7 @@ device_status_destroy_callback (void) } static void -devices_close_callback (GtkWidget *w, +devices_close_callback (GtkWidget *widget, gpointer data) { gtk_widget_hide (GTK_WIDGET(data)); diff --git a/app/dialogs/color-dialog.c b/app/dialogs/color-dialog.c index bdb4b3739c..39976e007a 100644 --- a/app/dialogs/color-dialog.c +++ b/app/dialogs/color-dialog.c @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #define __COLOR_NOTEBOOK_C__ 1 #include "config.h" @@ -29,28 +28,17 @@ #include #include "appenv.h" -#include "actionarea.h" #include "color_notebook.h" +#include "gimpui.h" #include "libgimp/color_selector.h" #include "libgimp/gimpintl.h" - - -static void color_notebook_ok_callback (GtkWidget *, gpointer); +static void color_notebook_ok_callback (GtkWidget *, gpointer); static void color_notebook_cancel_callback (GtkWidget *, gpointer); -static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void color_notebook_update_callback (void *, int, int, int); static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint); - -static ActionAreaItem action_items[2] = -{ - { N_("OK"), color_notebook_ok_callback, NULL, NULL }, - { N_("Cancel"), color_notebook_cancel_callback, NULL, NULL }, -}; - - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo { char *name; /* label used in notebook tab */ @@ -98,28 +86,33 @@ color_notebook_new (int r, g_return_val_if_fail (selector_info != NULL, NULL); - cnp = g_malloc (sizeof (_ColorNotebook)); + cnp = g_new (_ColorNotebook, 1); - cnp->callback = callback; - cnp->client_data = client_data; + cnp->callback = callback; + cnp->client_data = client_data; cnp->wants_updates = wants_updates; - cnp->selectors = NULL; - cnp->cur_page = NULL; + cnp->selectors = NULL; + cnp->cur_page = NULL; - cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; + cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff; - cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; + cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; - /* window hints need to stay the same, so people's window manager - * setups still work */ - cnp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE); + cnp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_notebook_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event", - (GtkSignalFunc) color_notebook_delete_callback, cnp); + wants_updates ? _("Close") : _("OK"), + color_notebook_ok_callback, + cnp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_notebook_cancel_callback, + cnp, NULL, FALSE, TRUE, + + NULL); /* do we actually need a notebook? */ if (selector_info->next) @@ -179,21 +172,6 @@ color_notebook_new (int r, info = info->next; } - /* The action area */ - action_items[0].user_data = cnp; - action_items[1].user_data = cnp; - if (cnp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0); - gtk_widget_show (cnp->shell); /* this must come after showing the widget, otherwise we get a @@ -209,7 +187,6 @@ color_notebook_new (int r, return cnp; } - void color_notebook_show (ColorNotebookP cnp) { @@ -217,7 +194,6 @@ color_notebook_show (ColorNotebookP cnp) gtk_widget_show (cnp->shell); } - void color_notebook_hide (ColorNotebookP cnp) { @@ -253,13 +229,12 @@ color_notebook_free (ColorNotebookP cnp) g_free (cnp); } - void color_notebook_set_color (ColorNotebookP cnp, - int r, - int g, - int b, - int set_current) + int r, + int g, + int b, + int set_current) { ColorSelectorInstance *csel; g_return_if_fail (cnp != NULL); @@ -279,11 +254,12 @@ color_notebook_set_color (ColorNotebookP cnp, csel->info->m.setcolor (csel->selector_data, r, g, b, set_current); } - - /* Called by a colour selector on user selection of a colour */ static void -color_notebook_update_callback (void *data, int r, int g, int b) +color_notebook_update_callback (void *data, + int r, + int g, + int b) { ColorSelectorInstance *csel; ColorNotebookP cnp; @@ -307,16 +283,13 @@ color_notebook_update_callback (void *data, int r, int g, int b) } } - - - static void -color_notebook_ok_callback (GtkWidget *w, - gpointer client_data) +color_notebook_ok_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->values[RED], @@ -326,25 +299,13 @@ color_notebook_ok_callback (GtkWidget *w, cnp->client_data); } - -static gint -color_notebook_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_notebook_cancel_callback (w, client_data); - - return TRUE; -} - - static void -color_notebook_cancel_callback (GtkWidget *w, - gpointer client_data) +color_notebook_cancel_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->orig_values[RED], @@ -355,14 +316,14 @@ color_notebook_cancel_callback (GtkWidget *w, } static void -color_notebook_page_switch (GtkWidget *w, +color_notebook_page_switch (GtkWidget *widget, GtkNotebookPage *page, guint page_num) { ColorNotebookP cnp; ColorSelectorInstance *csel; - cnp = gtk_object_get_user_data (GTK_OBJECT (w)); + cnp = gtk_object_get_user_data (GTK_OBJECT (widget)); csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook"); g_return_if_fail (cnp != NULL && csel != NULL); @@ -466,5 +427,4 @@ selector_death (ColorSelectorInfo *info) g_warning ("color selector %p not found, can't happen!", info); } - /* End of color_notebook.c */ diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c index 333e6d9c5f..f23969962d 100644 --- a/app/dialogs/image-new-dialog.c +++ b/app/dialogs/image-new-dialog.c @@ -15,11 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "file_new_dialog.h" - -#include "actionarea.h" #include "gimprc.h" +#include "gimpui.h" #include "gdisplay.h" #include "libgimp/gimpchainbutton.h" @@ -27,7 +25,8 @@ #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" -typedef struct { +typedef struct +{ GtkWidget *dlg; GtkWidget *confirm_dlg; @@ -50,7 +49,6 @@ static void file_new_confirm_dialog (NewImageInfo *); static void file_new_ok_callback (GtkWidget *, gpointer); static void file_new_reset_callback (GtkWidget *, gpointer); -static gint file_new_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void file_new_cancel_callback (GtkWidget *, gpointer); static void file_new_toggle_callback (GtkWidget *, gpointer); static void file_new_resolution_callback (GtkWidget *, gpointer); @@ -136,15 +134,6 @@ file_new_reset_callback (GtkWidget *widget, (GTK_TOGGLE_BUTTON (info->fill_type_w[BACKGROUND_FILL]), TRUE); } -static gint -file_new_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - file_new_cancel_callback (widget, data); - return TRUE; -} - static void file_new_cancel_callback (GtkWidget *widget, gpointer data) @@ -185,15 +174,6 @@ file_new_confirm_dialog_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (info->dlg, TRUE); } -static gint -file_new_confirm_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - file_new_confirm_dialog_cancel_callback (widget, data); - return TRUE; -} - static void file_new_confirm_dialog (NewImageInfo *info) { @@ -202,32 +182,21 @@ file_new_confirm_dialog (NewImageInfo *info) gchar *max_size; gchar *text; - static ActionAreaItem action_items[] = - { - { N_("OK"), - (ActionCallback) file_new_confirm_dialog_ok_callback, NULL, NULL }, - { N_("Cancel"), - (ActionCallback) file_new_confirm_dialog_cancel_callback, NULL, NULL } - }; - gtk_widget_set_sensitive (info->dlg, FALSE); - info->confirm_dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (info->confirm_dlg), - "confirm_size", "Gimp"); - gtk_window_set_title (GTK_WINDOW (info->confirm_dlg), _("Confirm Image Size")); - gtk_window_set_policy (GTK_WINDOW (info->confirm_dlg), FALSE, FALSE, FALSE); - gtk_window_position (GTK_WINDOW (info->confirm_dlg), GTK_WIN_POS_MOUSE); + info->confirm_dlg = + gimp_dialog_new (_("Confirm Image Size"), "confirm_size", + gimp_standard_help_func, + "dialogs/file_new_dialog.html#confirm_size_dialog", + GTK_WIN_POS_MOUSE, + FALSE, FALSE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (info->confirm_dlg), "delete_event", - (GtkSignalFunc) file_new_confirm_dialog_delete_callback, - info); + _("OK"), file_new_confirm_dialog_ok_callback, + info, NULL, TRUE, FALSE, + _("Cancel"), file_new_confirm_dialog_cancel_callback, + info, NULL, FALSE, TRUE, - /* The action area */ - action_items[0].user_data = info; - action_items[1].user_data = info; - build_action_area (GTK_DIALOG (info->confirm_dlg), action_items, 2, 0); + NULL); size = image_new_get_size_string (info->size); max_size = image_new_get_size_string (max_new_image_size); @@ -326,15 +295,14 @@ file_new_image_size_callback (GtkWidget *widget, gpointer data) { NewImageInfo *info; - gdouble width, height; gchar *text; gchar *label; info = (NewImageInfo*) data; - width = (gdouble) (gint) + info->values->width = (gdouble) (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - height = (gdouble) (gint) + info->values->height = (gdouble) (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); info->size = image_new_calculate_size (info->values); @@ -391,35 +359,26 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) GSList *group; GList *list; - static ActionAreaItem action_items[] = - { - { N_("OK"), file_new_ok_callback, NULL, NULL }, - { N_("Reset"), file_new_reset_callback, NULL, NULL }, - { N_("Cancel"), file_new_cancel_callback, NULL, NULL } - }; - info = g_new (NewImageInfo, 1); info->values = values = image_new_values_new (values_orig); info->confirm_dlg = NULL; info->size = 0.0; - info->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (info->dlg), "new_image", "Gimp"); - gtk_window_set_title (GTK_WINDOW (info->dlg), _("New Image")); - gtk_window_set_position (GTK_WINDOW (info->dlg), GTK_WIN_POS_MOUSE); - gtk_window_set_policy(GTK_WINDOW (info->dlg), FALSE, FALSE, TRUE); + info->dlg = gimp_dialog_new (_("New Image"), "new_image", + gimp_standard_help_func, + "dialogs/file_new_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, FALSE, TRUE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (info->dlg), "delete_event", - GTK_SIGNAL_FUNC (file_new_delete_callback), - info); + _("OK"), file_new_ok_callback, + info, NULL, FALSE, FALSE, + _("Reset"), file_new_reset_callback, + info, NULL, FALSE, FALSE, + _("Cancel"), file_new_cancel_callback, + info, NULL, TRUE, TRUE, - /* The action area */ - action_items[0].user_data = info; - action_items[1].user_data = info; - action_items[2].user_data = info; - build_action_area (GTK_DIALOG (info->dlg), action_items, 3, 2); + NULL); /* vbox holding the rest of the dialog */ top_vbox = gtk_vbox_new (FALSE, 2); diff --git a/app/dialogs/info-dialog.c b/app/dialogs/info-dialog.c index 6528ffb06f..63f7870bae 100644 --- a/app/dialogs/info-dialog.c +++ b/app/dialogs/info-dialog.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -143,8 +142,10 @@ info_dialog_delete_callback (GtkWidget *widget, } static InfoDialog * -info_dialog_new_extended (gchar *title, - gboolean in_notebook) +info_dialog_new_extended (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gboolean in_notebook) { InfoDialog *idialog; GtkWidget *shell; @@ -171,7 +172,7 @@ info_dialog_new_extended (gchar *title, info_table = gtk_table_new (2, 0, FALSE); - if( in_notebook) + if (in_notebook) { info_notebook = gtk_notebook_new (); gtk_notebook_append_page (GTK_NOTEBOOK (info_notebook), @@ -196,21 +197,28 @@ info_dialog_new_extended (gchar *title, gtk_widget_show (idialog->info_table); gtk_widget_show (idialog->vbox); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (idialog->shell, help_func, help_data); + return idialog; } /* public functions */ InfoDialog * -info_dialog_notebook_new (gchar *title) +info_dialog_notebook_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data) { - return info_dialog_new_extended (title, TRUE); + return info_dialog_new_extended (title, help_func, help_data, TRUE); } InfoDialog * -info_dialog_new (gchar *title) +info_dialog_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data) { - return info_dialog_new_extended (title, FALSE); + return info_dialog_new_extended (title, help_func, help_data, FALSE); } void @@ -236,7 +244,6 @@ info_dialog_free (InfoDialog *idialog) g_free (idialog); } - void info_dialog_popup (InfoDialog *idialog) { diff --git a/app/dialogs/info-dialog.h b/app/dialogs/info-dialog.h index 8bd9e24136..afe8027d24 100644 --- a/app/dialogs/info-dialog.h +++ b/app/dialogs/info-dialog.h @@ -18,7 +18,9 @@ #ifndef __INFO_DIALOG_H__ #define __INFO_DIALOG_H__ -#include "gtk/gtk.h" +#include + +#include "gimphelp.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpunit.h" @@ -61,8 +63,12 @@ struct _InfoDialog /* Info Dialog functions */ -InfoDialog *info_dialog_new (gchar *title); -InfoDialog *info_dialog_notebook_new (gchar *title); +InfoDialog *info_dialog_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data); +InfoDialog *info_dialog_notebook_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data); void info_dialog_free (InfoDialog *idialog); void info_dialog_popup (InfoDialog *idialog); diff --git a/app/dialogs/info-window.c b/app/dialogs/info-window.c index d3c894fdb6..46ab01d1ca 100644 --- a/app/dialogs/info-window.c +++ b/app/dialogs/info-window.c @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -283,10 +283,12 @@ info_window_create (void *gdisp_ptr) /* create the info dialog */ title_buf = g_strdup_printf (_("%s: Window Info"), title); - info_win = info_dialog_notebook_new (title_buf); + info_win = info_dialog_notebook_new (title_buf, + gimp_standard_help_func, + "dialogs/info_window.html"); g_free (title_buf); - iwd = (InfoWinData *) g_malloc (sizeof (InfoWinData)); + iwd = g_new (InfoWinData, 1); info_win->user_data = iwd; iwd->dimensions_str[0] = '\0'; iwd->resolution_str[0] = '\0'; diff --git a/app/dialogs/module-dialog.c b/app/dialogs/module-dialog.c index 3f0487d9b6..a2fb3ebda5 100644 --- a/app/dialogs/module-dialog.c +++ b/app/dialogs/module-dialog.c @@ -36,10 +36,10 @@ #include "gimpsignal.h" #include "gimprc.h" #include "datafiles.h" -#include "actionarea.h" #include "gimpset.h" -#include "libgimp/gimpenv.h" +#include "gimpui.h" +#include "libgimp/gimpenv.h" #include "libgimp/gimpmodule.h" #include "libgimp/gimpintl.h" @@ -258,19 +258,21 @@ module_db_browser_new (void) GtkWidget *listbox; GtkWidget *button; browser_st *st; - ActionAreaItem action_items[] = - { - { N_("OK"), browser_popdown_callback, NULL, NULL } - }; + shell = gimp_dialog_new (_("Module DB"), "module_db_dialog", + gimp_standard_help_func, + "dialogs/module_db_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (shell), "module_db_dialog", "Gimp"); - gtk_window_set_title (GTK_WINDOW (shell), _("Module DB")); + _("OK"), browser_popdown_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 5); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox); gtk_widget_show (vbox); listbox = gtk_scrolled_window_new (NULL, NULL); @@ -333,12 +335,6 @@ module_db_browser_new (void) gtk_signal_connect (GTK_OBJECT (shell), "destroy", browser_destroy_callback, st); - action_items[0].user_data = shell; - build_action_area (GTK_DIALOG (shell), - action_items, - sizeof( action_items)/sizeof( ActionAreaItem), - 0); - return shell; } diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index af84450451..0a61751d03 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -23,6 +23,7 @@ #include "gdisplay_ops.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "lc_dialog.h" @@ -107,6 +108,7 @@ static int old_max_new_image_size; static int old_thumbnail_mode; static int old_show_indicators; static int old_trust_dirty_flag; +static int old_use_help; /* variables which can't be changed on the fly */ static int edit_stingy_memory_use; @@ -531,7 +533,12 @@ file_prefs_save_callback (GtkWidget *widget, update = g_list_append (update, "trust-dirty-flag"); remove = g_list_append (update, "dont-trust-dirty-flag"); } - + if (use_help != old_use_help) + { + update = g_list_append (update, "use-help"); + remove = g_list_append (remove, "dont-use-help"); + } + save_gimprc (&update, &remove); if (using_xserver_resolution) @@ -597,6 +604,7 @@ file_prefs_cancel_callback (GtkWidget *widget, thumbnail_mode = old_thumbnail_mode; show_indicators = old_show_indicators; trust_dirty_flag = old_trust_dirty_flag; + use_help = old_use_help; if (preview_size != old_preview_size) { @@ -703,6 +711,8 @@ file_prefs_toggle_callback (GtkWidget *widget, val = data; *val = (long) gtk_object_get_user_data (GTK_OBJECT (widget)); } + else if (data == &use_help) + use_help = GTK_TOGGLE_BUTTON (widget)->active; else { /* Are you a gimp-hacker who is getting this message? You @@ -972,360 +982,6 @@ file_prefs_monitor_resolution_callback (GtkWidget *widget, monitor_yres = yres; } -/* ******************************************************************** - * convenience constructors test site ;) - */ - -/* local callbacks of gimp_dialog_new () */ -static int -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; -} - -/* -#include "/home/mitschel/gimpfiles/wilber.xpm" - -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], - wilber_xpm); - - gdk_window_set_icon (widget->window, NULL, - wilber_pixmap, wilber_mask); -} -*/ - -/* this is an experimental one - * I tried to fold the entire dialog creation and the ActionArea stuff - * into one function. Might be not general enough. - */ -GtkWidget* -gimp_dialog_new (const gchar *title, - const gchar *wmclass_name, - GtkWindowPosition position, - gint allow_shrink, - gint allow_grow, - gint auto_shrink, - - /* specify action area buttons as va_list: - * gchar *label, - * GtkSignalFunc callback, - * gpointer data, - * gboolean default_action, - * gboolean connect_delete, - */ - - ...) -{ - GtkWidget *dialog; - GtkWidget *hbbox; - GtkWidget *button; - - /* action area variables */ - gchar *label; - GtkSignalFunc callback; - gpointer data; - gboolean default_action; - gboolean connect_delete; - - va_list args; - gboolean delete_connected = FALSE; - - 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_grow, allow_shrink, auto_shrink); - - /* prepare the action_area */ - gtk_container_set_border_width - (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (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 (GTK_DIALOG (dialog)->action_area), hbbox, - FALSE, FALSE, 0); - gtk_widget_show (hbbox); - - /* the action_area buttons */ - va_start (args, auto_shrink); - label = va_arg (args, gchar*); - while (label) - { - callback = va_arg (args, GtkSignalFunc); - data = 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 (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*); - } - va_end (args); - - /* catch the WM delete event if not already done */ - if (! delete_connected) - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - (GdkEventFunc) gimp_dialog_delete_callback, - NULL); - - /* the realize callback sets the WM icon */ - /* - gtk_signal_connect (GTK_OBJECT (dialog), "realize", - (GtkSignalFunc) gimp_dialog_realize_callback, - NULL); - - */ - return dialog; -} - -GtkWidget* -gimp_option_menu_new (GtkSignalFunc menu_item_callback, - gpointer initial, /* user_data */ - - /* specify menu items as va_list: - * gchar *label, - * gpointer data, - * gpointer user_data, - */ - - ...) -{ - GtkWidget *menu; - GtkWidget *menuitem; - GtkWidget *optionmenu; - - /* menu item variables */ - gchar *label; - gpointer data; - gpointer user_data; - - va_list args; - gint i; - gint initial_index; - - menu = gtk_menu_new (); - - /* create the menu items */ - initial_index = 0; - va_start (args, initial); - label = va_arg (args, gchar*); - for (i = 0; label; i++) - { - data = va_arg (args, gpointer); - user_data = va_arg (args, gpointer); - - menuitem = gtk_menu_item_new_with_label (label); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - menu_item_callback, data); - gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data); - gtk_widget_show (menuitem); - - /* remember the initial menu item */ - if (user_data == initial) - initial_index = i; - - label = va_arg (args, gchar*); - } - va_end (args); - - optionmenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); - - /* select the initial menu item */ - gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index); - - return optionmenu; -} - -GtkWidget* -gimp_radio_group_new (GtkSignalFunc radio_button_callback, - gpointer initial, /* user_data */ - - /* specify radio buttons as va_list: - * gchar *label, - * gpointer data, - * gpointer user_data, - */ - - ...) -{ - GtkWidget *vbox; - GtkWidget *button; - GSList *group; - - /* radio button variables */ - gchar *label; - gpointer data; - gpointer user_data; - - va_list args; - - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - group = NULL; - - /* create the radio buttons */ - va_start (args, initial); - label = va_arg (args, gchar*); - while (label) - { - data = va_arg (args, gpointer); - user_data = va_arg (args, gpointer); - - button = gtk_radio_button_new_with_label (group, label); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) radio_button_callback, - data); - gtk_object_set_user_data (GTK_OBJECT (button), user_data); - - /* press the initially active radio button */ - if (user_data == initial) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - - gtk_widget_show (button); - - label = va_arg (args, gchar*); - } - va_end (args); - - return vbox; -} - -/* this might be the standard gimp spinbutton */ -GtkWidget* -gimp_spin_button_new (GtkObject **adjustment, /* return value */ - gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - gfloat page_size, - gfloat climb_rate, - guint digits) -{ - GtkWidget *spinbutton; - - *adjustment = gtk_adjustment_new (value, lower, upper, - step_increment, page_increment, page_size); - - spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment), - climb_rate, digits); - gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), - GTK_SHADOW_NONE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); - gtk_widget_set_usize (spinbutton, 75, 0); - - return spinbutton; -} - -/* add aligned label & widget to a two-column table */ -void -gimp_table_attach_aligned (GtkTable *table, - gint row, - gchar *text, - gfloat xalign, - gfloat yalign, - GtkWidget *widget, - gboolean left_adjust) -{ - GtkWidget *label; - - label = gtk_label_new (text); - gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); - gtk_table_attach (table, GTK_WIDGET (label), 0, 1, row, row + 1, - GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - gtk_widget_show (label); - - if (left_adjust) - { - GtkWidget *alignment; - - alignment = gtk_alignment_new (0.0, 1.0, 0.0, 0.0); - gtk_table_attach_defaults (table, alignment, 1, 2, row, row + 1); - gtk_widget_show (alignment); - gtk_container_add (GTK_CONTAINER (alignment), widget); - } - else - { - gtk_table_attach_defaults (table, widget, 1, 2, row, row + 1); - } - - gtk_widget_show (widget); -} - - -/********************************************************************** - * preferences-specific GUI helpers - */ - /* create a new notebook page */ static GtkWidget* file_prefs_notebook_append_page (GtkNotebook *notebook, @@ -1492,6 +1148,7 @@ file_pref_cmd_callback (GtkWidget *widget, old_thumbnail_mode = thumbnail_mode; old_show_indicators = show_indicators; old_trust_dirty_flag = trust_dirty_flag; + old_use_help = use_help; file_prefs_strset (&old_temp_path, edit_temp_path); file_prefs_strset (&old_swap_path, edit_swap_path); @@ -1506,20 +1163,24 @@ file_pref_cmd_callback (GtkWidget *widget, /* Create the dialog */ prefs_dlg = gimp_dialog_new (_("Preferences"), "gimp_preferences", - GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, - _("OK"), file_prefs_ok_callback, NULL, - FALSE, FALSE, - _("Save"), file_prefs_save_callback, NULL, - FALSE, FALSE, - _("Cancel"), file_prefs_cancel_callback, NULL, - TRUE, TRUE, + gimp_standard_help_func, + "dialogs/preferences_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, + + _("OK"), file_prefs_ok_callback, + NULL, NULL, FALSE, FALSE, + _("Save"), file_prefs_save_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), file_prefs_cancel_callback, + NULL, NULL, TRUE, TRUE, + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (prefs_dlg)->vbox), - hbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (prefs_dlg)->vbox), hbox); gtk_widget_show (hbox); /* The categories tree */ @@ -1849,7 +1510,7 @@ file_pref_cmd_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); - button = gtk_check_button_new_with_label(_("Show Tool Tips")); + button = gtk_check_button_new_with_label (_("Show Tool Tips")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), show_tool_tips); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); @@ -1858,6 +1519,16 @@ file_pref_cmd_callback (GtkWidget *widget, &show_tool_tips); gtk_widget_show (button); + button = + gtk_check_button_new_with_label (_("Context Sensitive Help with \"F1\"")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + use_help); + gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "toggled", + (GtkSignalFunc) file_prefs_toggle_callback, + &use_help); + gtk_widget_show (button); + /* Interface / Image Windows */ vbox = file_prefs_notebook_append_page (GTK_NOTEBOOK (notebook), _("Image Windows Settings"), diff --git a/app/dialogs/preferences-dialog.h b/app/dialogs/preferences-dialog.h index de5b153e12..ed92c84cea 100644 --- a/app/dialogs/preferences-dialog.h +++ b/app/dialogs/preferences-dialog.h @@ -20,14 +20,5 @@ #define __PREFERENCES_DIALOG_H__ void file_pref_cmd_callback (GtkWidget *, gpointer); -GtkWidget* gimp_spin_button_new (GtkObject **, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - guint); #endif /* __PREFERENCES_DIALOG_H__ */ diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c index 7a0ef0f835..7e2925d1db 100644 --- a/app/dialogs/resize-dialog.c +++ b/app/dialogs/resize-dialog.c @@ -19,8 +19,8 @@ #include "config.h" #include "appenv.h" #include "resize.h" -#include "actionarea.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpchainbutton.h" #include "libgimp/gimplimits.h" @@ -91,9 +91,6 @@ resize_widget_new (ResizeType type, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, - gint (*delete_cb) (GtkWidget *, - GdkEvent *, - gpointer), gpointer user_data) { Resize *resize; @@ -110,12 +107,6 @@ resize_widget_new (ResizeType type, GtkWidget *alignment; GtkObject *adjustment; - static ActionAreaItem action_items[] = - { - { N_("OK"), NULL, NULL, NULL }, - { N_("Cancel"), NULL, NULL, NULL } - }; - alignment = NULL; frame = NULL; @@ -149,52 +140,62 @@ resize_widget_new (ResizeType type, /* dialog box */ { - const char *wmclass = NULL; - const char *window_title = NULL; + const gchar *wmclass = NULL; + const gchar *window_title = NULL; + gchar *help_page = NULL; - switch (type) { - case ScaleWidget: - switch (target) { - case ResizeLayer: + switch (type) + { + case ScaleWidget: + switch (target) + { + case ResizeLayer: wmclass = "scale_layer"; window_title = _("Scale Layer"); + help_page = "dialogs/scale_layer_dialog.html"; frame = gtk_frame_new (_("Size")); break; - case ResizeImage: + case ResizeImage: wmclass = "image_scale"; window_title = _("Image Scale"); + help_page = "dialogs/scale_image_dialog.html"; frame = gtk_frame_new (_("Pixel Dimensions")); break; - } + } break; - case ResizeWidget: - switch (target) { - case ResizeLayer: + case ResizeWidget: + switch (target) + { + case ResizeLayer: wmclass = "resize_layer"; window_title = _("Resize Layer"); + help_page = "dialogs/resize_layer_dialog.html"; break; - case ResizeImage: + case ResizeImage: wmclass = "image_resize"; window_title = _("Image Resize"); + help_page = "dialogs/resize_image_dialog.html"; break; - } + } frame = gtk_frame_new (_("Size")); break; - } + } - resize->resize_shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (resize->resize_shell), wmclass,"Gimp"); - gtk_window_set_title (GTK_WINDOW (resize->resize_shell), window_title); - gtk_window_set_policy(GTK_WINDOW (resize->resize_shell), FALSE,FALSE,TRUE); - gtk_window_position (GTK_WINDOW (resize->resize_shell), GTK_WIN_POS_MOUSE); + resize->resize_shell = + gimp_dialog_new (window_title, wmclass, + gimp_standard_help_func, help_page, + GTK_WIN_POS_MOUSE, + FALSE, FALSE, TRUE, + + _("OK"), ok_cb, + user_data, NULL, TRUE, FALSE, + _("Cancel"), cancel_cb, + user_data, NULL, FALSE, TRUE, + + NULL); } - /* handle the wm close singal */ - if (delete_cb) - gtk_signal_connect (GTK_OBJECT (resize->resize_shell), "delete_event", - GTK_SIGNAL_FUNC (delete_cb), user_data); - /* handle the image disappearing under our feet */ if (object) { @@ -203,16 +204,9 @@ resize_widget_new (ResizeType type, signame = (target == ResizeLayer) ? "removed" : "destroy"; private->object = object; private->object_destroy_handler = - gtk_signal_connect(GTK_OBJECT (object), signame, cancel_cb, user_data); + gtk_signal_connect (GTK_OBJECT (object), signame, cancel_cb, user_data); } - /* the action area */ - action_items[0].user_data = user_data; - action_items[0].callback = ok_cb; - action_items[1].user_data = user_data; - action_items[1].callback = cancel_cb; - build_action_area (GTK_DIALOG (resize->resize_shell), action_items, 2, 0); - /* the main vbox */ vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); diff --git a/app/dialogs/resize-dialog.h b/app/dialogs/resize-dialog.h index 8163f142ba..7a9dced007 100644 --- a/app/dialogs/resize-dialog.h +++ b/app/dialogs/resize-dialog.h @@ -73,9 +73,6 @@ Resize * resize_widget_new (ResizeType type, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, - gint (*delete_cb) (GtkWidget *, - GdkEvent *, - gpointer), gpointer user_data); void resize_widget_free (Resize * resize); diff --git a/app/dialogs/user-install-dialog.c b/app/dialogs/user-install-dialog.c index 1ae0bc2571..2c6233c258 100644 --- a/app/dialogs/user-install-dialog.c +++ b/app/dialogs/user-install-dialog.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,9 +28,9 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "install.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" #include "libgimp/gimpenv.h" @@ -49,13 +48,13 @@ # define USER_INSTALL "user_install.bat" #endif -static void install_run (InstallCallback); -static void install_help (InstallCallback); -static void help_install_callback (GtkWidget *, gpointer); -static void help_ignore_callback (GtkWidget *, gpointer); -static void help_quit_callback (GtkWidget *, gpointer); +static void install_run (InstallCallback); +static void install_help (InstallCallback); +static void help_install_callback (GtkWidget *, gpointer); +static void help_ignore_callback (GtkWidget *, gpointer); +static void help_quit_callback (GtkWidget *, gpointer); static void install_continue_callback (GtkWidget *, gpointer); -static void install_quit_callback (GtkWidget *, gpointer); +static void install_quit_callback (GtkWidget *, gpointer); static GtkWidget *help_widget; static GtkWidget *install_widget; @@ -100,12 +99,6 @@ install_verify (InstallCallback install_callback) static void install_help (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Install"), help_install_callback, NULL, NULL }, - { N_("Ignore"), help_ignore_callback, NULL, NULL }, - { N_("Quit"), help_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -175,7 +168,7 @@ install_help (InstallCallback callback) { 1, N_("generated_brushes\n") }, { 0, N_("\t\tThis is a subdirectory which is used to store brushes\n" "\t\tthat are created with the brush editor. The default\n" - "\t\gimprc file checks this subdirectory when searching for\n" + "\t\tgimprc file checks this subdirectory when searching for\n" "\t\tgenerated brushes.\n") }, { 1, N_("gradients\n") }, @@ -254,13 +247,24 @@ install_help (InstallCallback callback) gint nhelp_lines = sizeof (help_lines) / sizeof (help_lines[0]); gint i; - help_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (help_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (help_widget), "gimp_installation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (help_widget), _("GIMP Installation")); - gtk_window_position (GTK_WINDOW (help_widget), GTK_WIN_POS_CENTER); + help_widget = gimp_dialog_new (_("GIMP Installation"), "gimp_installation", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Install"), help_install_callback, + callback, NULL, TRUE, FALSE, + _("Ignore"), help_ignore_callback, + callback, NULL, FALSE, FALSE, + _("Quit"), help_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (help_widget)->vbox), table); vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); @@ -268,25 +272,12 @@ install_help (InstallCallback callback) gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_widget_set_usize (text, 450, 475); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - action_items[2].user_data = (void *) callback; - build_action_area (GTK_DIALOG (help_widget), action_items, 3, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (help_widget)->vbox), table, - TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, 0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font_emphasis = gdk_font_load ("-*-helvetica-medium-o-normal-*-*-100-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*"); @@ -392,11 +383,6 @@ quote_spaces (char *string) static void install_run (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Continue"), install_continue_callback, NULL, NULL }, - { N_("Quit"), install_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -409,27 +395,28 @@ install_run (InstallCallback callback) int err; int executable = TRUE; - install_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (install_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (install_widget), "installation_log", "Gimp"); - gtk_window_set_title (GTK_WINDOW (install_widget), _("Installation Log")); - gtk_window_position (GTK_WINDOW (install_widget), GTK_WIN_POS_CENTER); + install_widget = gimp_dialog_new (_("Installation Log"), "installation_log", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Continue"), install_continue_callback, + callback, NULL, TRUE, FALSE, + _("Quit"), install_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (install_widget)->vbox), table); + vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); text = gtk_text_new (NULL, vadj); gtk_widget_set_usize (text, 384, 356); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - build_action_area (GTK_DIALOG (install_widget), action_items, 2, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (install_widget)->vbox), table, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, @@ -437,8 +424,6 @@ install_run (InstallCallback callback) GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"); diff --git a/app/display/gimpdisplay-ops.c b/app/display/gimpdisplay-ops.c index c5ebe520b4..884b7352d9 100644 --- a/app/display/gimpdisplay-ops.c +++ b/app/display/gimpdisplay-ops.c @@ -18,14 +18,13 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "colormaps.h" #include "cursorutil.h" #include "fileops.h" #include "gdisplay_ops.h" #include "gimage.h" +#include "gimpui.h" #include "gximage.h" -#include "interface.h" #include "menus.h" #include "scale.h" #include "gimprc.h" @@ -320,16 +319,6 @@ gdisplay_cancel_warning_callback (GtkWidget *widget, gtk_widget_destroy (mbox); } -static gint -gdisplay_delete_warning_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - gdisplay_cancel_warning_callback (widget, client_data); - - return TRUE; -} - static void gdisplay_destroy_warning_callback (GtkWidget *widget, gpointer client_data) @@ -346,12 +335,6 @@ gdisplay_close_warning_dialog (char *image_name, GtkWidget *label; gchar *warning_buf; - static ActionAreaItem action_items[] = - { - { N_("Close"), gdisplay_close_warning_callback, NULL, NULL }, - { N_("Cancel"), gdisplay_cancel_warning_callback, NULL, NULL } - }; - /* FIXUP this will raise any prexsisting close dialogs, which can be a a bit confusing if you tried to close a new window because you had forgotten the old dialog was still around */ @@ -364,16 +347,21 @@ gdisplay_close_warning_dialog (char *image_name, menus_set_sensitive_glue ("", N_("/File/Close"), FALSE); - warning_dialog = mbox = gtk_dialog_new (); - /* should this be image_window or the actual image name??? */ - gtk_window_set_wmclass (GTK_WINDOW (mbox), "really_close", "Gimp"); - gtk_window_set_title (GTK_WINDOW (mbox), image_name); - gtk_window_set_position (GTK_WINDOW (mbox), GTK_WIN_POS_MOUSE); - gtk_object_set_user_data (GTK_OBJECT (mbox), gdisp); + warning_dialog = mbox = + gimp_dialog_new (image_name, "really_close", + gimp_standard_help_func, + "dialogs/really_close_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (mbox), "delete_event", - GTK_SIGNAL_FUNC (gdisplay_delete_warning_callback), - mbox); + _("Close"), gdisplay_close_warning_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), gdisplay_cancel_warning_callback, + NULL, NULL, TRUE, TRUE, + + NULL); + + gtk_object_set_user_data (GTK_OBJECT (mbox), gdisp); gtk_signal_connect (GTK_OBJECT (mbox), "destroy", GTK_SIGNAL_FUNC (gdisplay_destroy_warning_callback), @@ -392,9 +380,5 @@ gdisplay_close_warning_dialog (char *image_name, gtk_widget_show (label); g_free (warning_buf); - action_items[0].user_data = mbox; - action_items[1].user_data = mbox; - build_action_area (GTK_DIALOG (mbox), action_items, 2, 1); - gtk_widget_show (mbox); } diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 7a5450b845..05c4875d05 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -20,7 +20,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "app_procs.h" #include "colormaps.h" #include "color_area.h" @@ -34,7 +33,9 @@ #include "gdisplay_ops.h" #include "gimage.h" #include "gimpdnd.h" +#include "gimphelp.h" #include "gimprc.h" +#include "gimpui.h" #include "gtkhwrapbox.h" #include "gtkvwrapbox.h" #include "indicator_area.h" @@ -50,7 +51,6 @@ #include "pixmaps/qmasknosel.xpm" #include "pixmaps/navbutton.xpm" -#include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" /* local functions */ @@ -305,9 +305,10 @@ create_color_area (GtkWidget *parent) col_area = color_area_create (54, 42, default_pixmap, swap_pixmap); gtk_container_add (GTK_CONTAINER (alignment), col_area); - gtk_tooltips_set_tip (tool_tips, col_area, _("Foreground & background colors. The black " - "and white squares reset colors. The arrows swap colors. Double " - "click to select a color from a colorrequester."), + gtk_tooltips_set_tip (tool_tips, col_area, + _("Foreground & background colors. The black " + "and white squares reset colors. The arrows swap colors. Double " + "click to select a color from a colorrequester."), NULL); gtk_widget_show (col_area); gtk_widget_show (alignment); @@ -524,7 +525,7 @@ create_toolbox (void) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* Register dialog */ - dialog_register_toolbox(window); + dialog_register_toolbox (window); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp"); gtk_window_set_title (GTK_WINDOW (window), _("The GIMP")); @@ -587,6 +588,11 @@ create_toolbox (void) /* Install the accelerator table in the main window */ gtk_window_add_accel_group (GTK_WINDOW (window), table); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, + gimp_standard_help_func, + "dialogs/toolbox.html"); + wbox = gtk_vwrap_box_new (FALSE); gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_FILL); gtk_container_set_border_width (GTK_CONTAINER (wbox), 0); @@ -626,7 +632,7 @@ void toolbox_raise_callback (GtkWidget *widget, gpointer client_data) { - gdk_window_raise(toolbox_shell->window); + gdk_window_raise (toolbox_shell->window); } void @@ -873,7 +879,7 @@ create_display_shell (GDisplay* gdisp, gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); - /* sneak in an extra table here */ + /* sneak in an extra table here */ gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1, GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -939,12 +945,17 @@ create_display_shell (GDisplay* gdisp, gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton, FALSE, TRUE, 0); gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE); - /* the popup menu */ + /* the popup menu */ gdisp->popup = image_popup_menu; - /* the accelerator table for images */ + /* The accelerator table for images */ gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (gdisp->shell, + gimp_standard_help_func, + "dialogs/image_window.html"); + gtk_widget_show (arrow); gtk_widget_show (gdisp->qmaskon); gtk_widget_show (gdisp->qmaskoff); @@ -981,492 +992,12 @@ create_display_shell (GDisplay* gdisp, #warning DODGY? #endif /*__GNUC__ */ gtk_widget_realize (gdisp->canvas); - gdk_window_set_back_pixmap(gdisp->canvas->window, NULL, 0); + gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, 0); /* set the focus to the canvas area */ gtk_widget_grab_focus (gdisp->canvas); - } - -/* - * String, integer, double and size query boxes - */ - -typedef struct _QueryBox QueryBox; - -struct _QueryBox -{ - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *entry; - GtkWidget *ok_button; - GtkObject *object; - QueryFunc callback; - gpointer data; -}; - -static QueryBox * create_query_box (gchar *, gchar *, GtkObject *, gchar *, - QueryFunc, gpointer); -static gint query_box_delete_callback (GtkWidget *, GdkEvent *, gpointer); -static void query_box_cancel_callback (GtkWidget *, gpointer); -static void string_query_box_ok_callback (GtkWidget *, gpointer); -static void int_query_box_ok_callback (GtkWidget *, gpointer); -static void double_query_box_ok_callback (GtkWidget *, gpointer); -static void size_query_box_ok_callback (GtkWidget *, gpointer); - -/* create a generic query box without any entry widget */ -static QueryBox * -create_query_box (gchar *title, - gchar *message, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *label; - - static ActionAreaItem action_items[] = - { - { N_("OK"), (ActionCallback) NULL, NULL, NULL }, - { N_("Cancel"), (ActionCallback) query_box_cancel_callback, NULL, NULL } - }; - - query_box = (QueryBox *) g_malloc (sizeof (QueryBox)); - - qbox = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (qbox), title); - gtk_window_set_wmclass (GTK_WINDOW (qbox), "query_box", "Gimp"); - gtk_window_position (GTK_WINDOW (qbox), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (qbox), "delete_event", - (GtkSignalFunc) query_box_delete_callback, - query_box); - - /* if we are associated with an object, connect to the provided signal */ - if (object && GTK_IS_OBJECT (object) && signal) - gtk_signal_connect (GTK_OBJECT (object), signal, - (GtkSignalFunc) query_box_cancel_callback, - query_box); - else - object = NULL; - - /* The action area */ - action_items[1].user_data = query_box; - build_action_area (GTK_DIALOG (qbox), action_items, 2, 0); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (qbox)->vbox), vbox); - gtk_widget_show (vbox); - - label = gtk_label_new (message); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - query_box->qbox = qbox; - query_box->vbox = vbox; - query_box->entry = NULL; - query_box->ok_button = action_items[0].widget; - query_box->object = object; - query_box->callback = callback; - query_box->data = data; - - return query_box; -} - -GtkWidget * -query_string_box (gchar *title, - gchar *message, - gchar *initial, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *entry; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) string_query_box_ok_callback, - query_box); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); - if (initial) - gtk_entry_set_text (GTK_ENTRY (entry), initial); - gtk_widget_grab_focus (entry); - gtk_widget_show (entry); - - query_box->entry = entry; - - return query_box->qbox; -} - -GtkWidget * -query_int_box (gchar *title, - gchar *message, - gint initial, - gint lower, - gint upper, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkAdjustment* adjustment; - GtkWidget *spinbutton; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) int_query_box_ok_callback, - query_box); - adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); - spinbutton = gtk_spin_button_new (adjustment, 1.0, 0); - gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); - gtk_widget_grab_focus (spinbutton); - gtk_widget_show (spinbutton); - - query_box->entry = spinbutton; - - return query_box->qbox; -} - -GtkWidget * -query_double_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkAdjustment* adjustment; - GtkWidget *spinbutton; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) double_query_box_ok_callback, - query_box); - adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); - spinbutton = gtk_spin_button_new (adjustment, 1.0, digits); - gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); - gtk_widget_grab_focus (spinbutton); - gtk_widget_show (spinbutton); - - query_box->entry = spinbutton; - - return query_box->qbox; -} - -GtkWidget * -query_size_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GUnit unit, - gdouble resolution, - gint dot_for_dot, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *sizeentry; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) size_query_box_ok_callback, - query_box); - - sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, - GIMP_SIZE_ENTRY_UPDATE_SIZE); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, - resolution, FALSE); - gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); - gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0, - lower, upper); - gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial); - - gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0); - gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry)); - gtk_widget_show (sizeentry); - - query_box->entry = sizeentry; - - return query_box->qbox; -} - -static gint -query_box_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - query_box_cancel_callback (widget, client_data); - - return TRUE; -} - -static void -query_box_cancel_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - - query_box = (QueryBox *) client_data; - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -string_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gchar *string; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the entry data */ - string = g_strdup (gtk_entry_get_text (GTK_ENTRY (query_box->entry))); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, (gpointer) string); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -int_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gint *integer_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the spinbutton data */ - integer_value = g_malloc (sizeof (gint)); - *integer_value = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry)); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) integer_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -double_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gdouble *double_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the spinbutton data */ - double_value = g_malloc (sizeof (gdouble)); - *double_value = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (query_box->entry)); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) double_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -size_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gdouble *double_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the sizeentry data */ - double_value = g_malloc (sizeof (gdouble)); - *double_value = - gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0); - - /* Pass the selected unit to the callback */ - gtk_object_set_data - (GTK_OBJECT (widget), "size_query_unit", - (gpointer) gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry))); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) double_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - - -/* - * Message Boxes... - */ - -typedef struct _MessageBox MessageBox; - -struct _MessageBox -{ - GtkWidget *mbox; - GtkCallback callback; - gpointer data; -}; - -static void message_box_close_callback (GtkWidget *, gpointer); -static gint message_box_delete_callback (GtkWidget *, GdkEvent *, gpointer); - -GtkWidget * -message_box (gchar *message, - GtkCallback callback, - gpointer data) -{ - MessageBox *msg_box; - GtkWidget *mbox; - GtkWidget *vbox; - GtkWidget *label; - GtkWidget *button; - - if (! message) - return NULL; - - msg_box = (MessageBox *) g_malloc (sizeof (MessageBox)); - - mbox = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (mbox), "gimp_message", "Gimp"); - gtk_window_set_title (GTK_WINDOW (mbox), _("GIMP Message")); - gtk_window_position (GTK_WINDOW (mbox), GTK_WIN_POS_MOUSE); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (mbox)->action_area), 2); - - gtk_signal_connect (GTK_OBJECT (mbox), "delete_event", - GTK_SIGNAL_FUNC (message_box_delete_callback), - msg_box); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) message_box_close_callback, - msg_box); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (mbox)->action_area), button, - TRUE, TRUE, 0); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (mbox)->vbox), vbox); - gtk_widget_show (vbox); - - label = gtk_label_new (message); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); - gtk_widget_show (label); - - msg_box->mbox = mbox; - msg_box->callback = callback; - msg_box->data = data; - - gtk_widget_show (mbox); - - return mbox; -} - -static gint -message_box_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - message_box_close_callback (widget, client_data); - - return TRUE; -} - -static void -message_box_close_callback (GtkWidget *widget, - gpointer client_data) -{ - MessageBox *msg_box; - - msg_box = (MessageBox *) client_data; - - /* If there is a valid callback, invoke it */ - if (msg_box->callback) - (* msg_box->callback) (widget, msg_box->data); - - /* Destroy the box */ - gtk_widget_destroy (msg_box->mbox); - - g_free (msg_box); -} - - /* DnD functions */ static void toolbox_set_drag_dest (GtkWidget *object) diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h index d0cb420d0f..3c9828fc03 100644 --- a/app/display/gimpdisplayshell-draw.h +++ b/app/display/gimpdisplayshell-draw.h @@ -20,85 +20,30 @@ #include "toolsF.h" #include "gdisplayF.h" -#include "libgimp/gimpunit.h" - -/* typedefs */ -typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer); /* externed variables */ extern GtkWidget * tool_widgets[]; extern GtkTooltips * tool_tips; /* function declarations */ -GtkWidget * create_pixmap_widget (GdkWindow *parent, - gchar **data, - gint width, - gint height); +GtkWidget * create_pixmap_widget (GdkWindow *parent, + gchar **data, + gint width, + gint height); -GdkPixmap * create_tool_pixmap (GtkWidget *parent, - ToolType type); +GdkPixmap * create_tool_pixmap (GtkWidget *parent, + ToolType type); void create_toolbox (void); void toolbox_free (void); -void toolbox_raise_callback (GtkWidget *widget, - gpointer client_data); +void toolbox_raise_callback (GtkWidget *widget, + gpointer client_data); -void create_display_shell (GDisplay *gdisp, - gint width, - gint height, - gchar *title, - gint type); - -/* some simple query dialogs - * if object != NULL then the query boxes will connect their cancel callback - * to the provided signal of this object - * - * it's the caller's job to show the returned widgets - */ -GtkWidget * query_string_box (gchar *title, - gchar *message, - gchar *initial, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_int_box (gchar *title, - char *message, - gint initial, - gint lower, - gint upper, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_double_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_size_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GUnit unit, - gdouble resolution, - gint dot_for_dot, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); - -/* a simple message box */ -GtkWidget * message_box (gchar *message, - GtkCallback callback, - gpointer data); +void create_display_shell (GDisplay *gdisp, + gint width, + gint height, + gchar *title, + gint type); #endif /* __INTERFACE_H__ */ diff --git a/app/display/gimpdisplayshell-filter-dialog.c b/app/display/gimpdisplayshell-filter-dialog.c index 8a95e96136..3e85750e10 100644 --- a/app/display/gimpdisplayshell-filter-dialog.c +++ b/app/display/gimpdisplayshell-filter-dialog.c @@ -15,12 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "actionarea.h" #include "gdisplay.h" #include "gdisplay_color.h" #include "gdisplay_color_ui.h" #include "gimpimageP.h" +#include "gimpui.h" #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" #include @@ -48,7 +47,6 @@ struct _ButtonInfo static void color_display_ok_callback (GtkWidget *, gpointer); static void color_display_cancel_callback (GtkWidget *, gpointer); -static gint color_display_delete_callback (GtkWidget *, gpointer); static gint color_display_destroy_callback (GtkWidget *, gpointer); static void color_display_add_callback (GtkWidget *, gpointer); static void color_display_remove_callback (GtkWidget *, gpointer); @@ -68,12 +66,6 @@ make_dialog (void) char *titles[2]; int i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_display_ok_callback, NULL, NULL }, - { N_("Cancel"), color_display_cancel_callback, NULL, NULL } - }; - static ButtonInfo buttons[] = { { N_("Add"), color_display_add_callback }, @@ -83,13 +75,18 @@ make_dialog (void) { N_("Configure"), color_display_configure_callback } }; - cdd.shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cdd.shell), "display_color", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cdd.shell), _("Color Display Filters")); + cdd.shell = gimp_dialog_new (_("Color Display Filters"), "display_color", + gimp_standard_help_func, + "dialogs/color_diaplsy_filters_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (cdd.shell), "delete_event", - GTK_SIGNAL_FUNC (color_display_delete_callback), - NULL); + _("OK"), color_display_ok_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), color_display_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); hbox = gtk_hbox_new (FALSE, 4); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cdd.shell)->vbox), hbox, @@ -139,10 +136,6 @@ make_dialog (void) } gtk_widget_show_all (hbox); - - action_items[0].user_data = cdd.shell; - action_items[1].user_data = cdd.shell; - build_action_area (GTK_DIALOG (cdd.shell), action_items, 2, 0); } static void @@ -159,14 +152,6 @@ color_display_cancel_callback (GtkWidget *widget, gtk_widget_hide (GTK_WIDGET (data)); } -static gint -color_display_delete_callback (GtkWidget *widget, - gpointer data) -{ - color_display_cancel_callback (widget, data); - return TRUE; -} - static gint color_display_destroy_callback (GtkWidget *widget, gpointer data) diff --git a/app/display/gimpdisplayshell-filter.c b/app/display/gimpdisplayshell-filter.c index 47d77abb07..de711cb160 100644 --- a/app/display/gimpdisplayshell-filter.c +++ b/app/display/gimpdisplayshell-filter.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -23,6 +22,7 @@ #include "gdisplay_color.h" #include "gdisplay.h" #include "gimpimageP.h" +#include "gimpui.h" #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" @@ -75,9 +75,6 @@ static void gamma_configure_ok_callback (GtkWidget *widget, gpointer data); static void gamma_configure_cancel_callback (GtkWidget *widget, gpointer data); -static gint gamma_configure_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); static void gamma_configure (gpointer cd_ID); void @@ -400,15 +397,6 @@ gamma_configure_cancel_callback (GtkWidget *widget, gtk_widget_hide (widget); } -static gint -gamma_configure_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gamma_configure_cancel_callback (widget, data); - return TRUE; -} - static void gamma_configure (gpointer cd_ID) { @@ -417,19 +405,23 @@ gamma_configure (gpointer cd_ID) GtkWidget *hbox; GtkWidget *label; GtkWidget *entry; - GtkWidget *hbbox; - GtkWidget *button; GtkObject *adjustment; if (!context->shell) { - context->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (context->shell), "gamma", "Gimp"); - gtk_window_set_title (GTK_WINDOW (context->shell), _("Gamma")); + context->shell = + gimp_dialog_new (_("Gamma"), "gamma", + gimp_standard_help_func, + "dialogs/gamma_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (context->shell), "delete_event", - GTK_SIGNAL_FUNC (gamma_configure_delete_callback), - NULL); + _("OK"), gamma_configure_ok_callback, + cd_ID, NULL, FALSE, FALSE, + _("Cancel"), gamma_configure_cancel_callback, + cd_ID, NULL, TRUE, TRUE, + + NULL); hbox = gtk_hbox_new (TRUE, 2); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (context->shell)->vbox), @@ -446,27 +438,6 @@ gamma_configure (gpointer cd_ID) gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); gtk_widget_show_all (hbox); - - hbbox = gtk_hbutton_box_new (); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (context->shell)->action_area), - hbbox, FALSE, FALSE, 0); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (gamma_configure_ok_callback), - cd_ID); - - button = gtk_button_new_with_label (_("Cancel")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (gamma_configure_cancel_callback), - cd_ID); - - gtk_widget_show_all (hbbox); } gtk_widget_show (context->shell); diff --git a/app/display/gimpdisplayshell-qmask.c b/app/display/gimpdisplayshell-qmask.c index 29c2706729..5dea7de4c1 100644 --- a/app/display/gimpdisplayshell-qmask.c +++ b/app/display/gimpdisplayshell-qmask.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 7a5450b845..05c4875d05 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -20,7 +20,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "app_procs.h" #include "colormaps.h" #include "color_area.h" @@ -34,7 +33,9 @@ #include "gdisplay_ops.h" #include "gimage.h" #include "gimpdnd.h" +#include "gimphelp.h" #include "gimprc.h" +#include "gimpui.h" #include "gtkhwrapbox.h" #include "gtkvwrapbox.h" #include "indicator_area.h" @@ -50,7 +51,6 @@ #include "pixmaps/qmasknosel.xpm" #include "pixmaps/navbutton.xpm" -#include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" /* local functions */ @@ -305,9 +305,10 @@ create_color_area (GtkWidget *parent) col_area = color_area_create (54, 42, default_pixmap, swap_pixmap); gtk_container_add (GTK_CONTAINER (alignment), col_area); - gtk_tooltips_set_tip (tool_tips, col_area, _("Foreground & background colors. The black " - "and white squares reset colors. The arrows swap colors. Double " - "click to select a color from a colorrequester."), + gtk_tooltips_set_tip (tool_tips, col_area, + _("Foreground & background colors. The black " + "and white squares reset colors. The arrows swap colors. Double " + "click to select a color from a colorrequester."), NULL); gtk_widget_show (col_area); gtk_widget_show (alignment); @@ -524,7 +525,7 @@ create_toolbox (void) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* Register dialog */ - dialog_register_toolbox(window); + dialog_register_toolbox (window); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp"); gtk_window_set_title (GTK_WINDOW (window), _("The GIMP")); @@ -587,6 +588,11 @@ create_toolbox (void) /* Install the accelerator table in the main window */ gtk_window_add_accel_group (GTK_WINDOW (window), table); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, + gimp_standard_help_func, + "dialogs/toolbox.html"); + wbox = gtk_vwrap_box_new (FALSE); gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_FILL); gtk_container_set_border_width (GTK_CONTAINER (wbox), 0); @@ -626,7 +632,7 @@ void toolbox_raise_callback (GtkWidget *widget, gpointer client_data) { - gdk_window_raise(toolbox_shell->window); + gdk_window_raise (toolbox_shell->window); } void @@ -873,7 +879,7 @@ create_display_shell (GDisplay* gdisp, gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); - /* sneak in an extra table here */ + /* sneak in an extra table here */ gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1, GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -939,12 +945,17 @@ create_display_shell (GDisplay* gdisp, gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton, FALSE, TRUE, 0); gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE); - /* the popup menu */ + /* the popup menu */ gdisp->popup = image_popup_menu; - /* the accelerator table for images */ + /* The accelerator table for images */ gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (gdisp->shell, + gimp_standard_help_func, + "dialogs/image_window.html"); + gtk_widget_show (arrow); gtk_widget_show (gdisp->qmaskon); gtk_widget_show (gdisp->qmaskoff); @@ -981,492 +992,12 @@ create_display_shell (GDisplay* gdisp, #warning DODGY? #endif /*__GNUC__ */ gtk_widget_realize (gdisp->canvas); - gdk_window_set_back_pixmap(gdisp->canvas->window, NULL, 0); + gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, 0); /* set the focus to the canvas area */ gtk_widget_grab_focus (gdisp->canvas); - } - -/* - * String, integer, double and size query boxes - */ - -typedef struct _QueryBox QueryBox; - -struct _QueryBox -{ - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *entry; - GtkWidget *ok_button; - GtkObject *object; - QueryFunc callback; - gpointer data; -}; - -static QueryBox * create_query_box (gchar *, gchar *, GtkObject *, gchar *, - QueryFunc, gpointer); -static gint query_box_delete_callback (GtkWidget *, GdkEvent *, gpointer); -static void query_box_cancel_callback (GtkWidget *, gpointer); -static void string_query_box_ok_callback (GtkWidget *, gpointer); -static void int_query_box_ok_callback (GtkWidget *, gpointer); -static void double_query_box_ok_callback (GtkWidget *, gpointer); -static void size_query_box_ok_callback (GtkWidget *, gpointer); - -/* create a generic query box without any entry widget */ -static QueryBox * -create_query_box (gchar *title, - gchar *message, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *label; - - static ActionAreaItem action_items[] = - { - { N_("OK"), (ActionCallback) NULL, NULL, NULL }, - { N_("Cancel"), (ActionCallback) query_box_cancel_callback, NULL, NULL } - }; - - query_box = (QueryBox *) g_malloc (sizeof (QueryBox)); - - qbox = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (qbox), title); - gtk_window_set_wmclass (GTK_WINDOW (qbox), "query_box", "Gimp"); - gtk_window_position (GTK_WINDOW (qbox), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (qbox), "delete_event", - (GtkSignalFunc) query_box_delete_callback, - query_box); - - /* if we are associated with an object, connect to the provided signal */ - if (object && GTK_IS_OBJECT (object) && signal) - gtk_signal_connect (GTK_OBJECT (object), signal, - (GtkSignalFunc) query_box_cancel_callback, - query_box); - else - object = NULL; - - /* The action area */ - action_items[1].user_data = query_box; - build_action_area (GTK_DIALOG (qbox), action_items, 2, 0); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (qbox)->vbox), vbox); - gtk_widget_show (vbox); - - label = gtk_label_new (message); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - query_box->qbox = qbox; - query_box->vbox = vbox; - query_box->entry = NULL; - query_box->ok_button = action_items[0].widget; - query_box->object = object; - query_box->callback = callback; - query_box->data = data; - - return query_box; -} - -GtkWidget * -query_string_box (gchar *title, - gchar *message, - gchar *initial, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *entry; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) string_query_box_ok_callback, - query_box); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); - if (initial) - gtk_entry_set_text (GTK_ENTRY (entry), initial); - gtk_widget_grab_focus (entry); - gtk_widget_show (entry); - - query_box->entry = entry; - - return query_box->qbox; -} - -GtkWidget * -query_int_box (gchar *title, - gchar *message, - gint initial, - gint lower, - gint upper, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkAdjustment* adjustment; - GtkWidget *spinbutton; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) int_query_box_ok_callback, - query_box); - adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); - spinbutton = gtk_spin_button_new (adjustment, 1.0, 0); - gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); - gtk_widget_grab_focus (spinbutton); - gtk_widget_show (spinbutton); - - query_box->entry = spinbutton; - - return query_box->qbox; -} - -GtkWidget * -query_double_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkAdjustment* adjustment; - GtkWidget *spinbutton; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) double_query_box_ok_callback, - query_box); - adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); - spinbutton = gtk_spin_button_new (adjustment, 1.0, digits); - gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); - gtk_widget_grab_focus (spinbutton); - gtk_widget_show (spinbutton); - - query_box->entry = spinbutton; - - return query_box->qbox; -} - -GtkWidget * -query_size_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GUnit unit, - gdouble resolution, - gint dot_for_dot, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *sizeentry; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) size_query_box_ok_callback, - query_box); - - sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, - GIMP_SIZE_ENTRY_UPDATE_SIZE); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, - resolution, FALSE); - gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); - gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0, - lower, upper); - gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial); - - gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0); - gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry)); - gtk_widget_show (sizeentry); - - query_box->entry = sizeentry; - - return query_box->qbox; -} - -static gint -query_box_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - query_box_cancel_callback (widget, client_data); - - return TRUE; -} - -static void -query_box_cancel_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - - query_box = (QueryBox *) client_data; - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -string_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gchar *string; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the entry data */ - string = g_strdup (gtk_entry_get_text (GTK_ENTRY (query_box->entry))); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, (gpointer) string); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -int_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gint *integer_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the spinbutton data */ - integer_value = g_malloc (sizeof (gint)); - *integer_value = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry)); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) integer_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -double_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gdouble *double_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the spinbutton data */ - double_value = g_malloc (sizeof (gdouble)); - *double_value = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (query_box->entry)); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) double_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -size_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gdouble *double_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the sizeentry data */ - double_value = g_malloc (sizeof (gdouble)); - *double_value = - gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0); - - /* Pass the selected unit to the callback */ - gtk_object_set_data - (GTK_OBJECT (widget), "size_query_unit", - (gpointer) gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry))); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) double_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - - -/* - * Message Boxes... - */ - -typedef struct _MessageBox MessageBox; - -struct _MessageBox -{ - GtkWidget *mbox; - GtkCallback callback; - gpointer data; -}; - -static void message_box_close_callback (GtkWidget *, gpointer); -static gint message_box_delete_callback (GtkWidget *, GdkEvent *, gpointer); - -GtkWidget * -message_box (gchar *message, - GtkCallback callback, - gpointer data) -{ - MessageBox *msg_box; - GtkWidget *mbox; - GtkWidget *vbox; - GtkWidget *label; - GtkWidget *button; - - if (! message) - return NULL; - - msg_box = (MessageBox *) g_malloc (sizeof (MessageBox)); - - mbox = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (mbox), "gimp_message", "Gimp"); - gtk_window_set_title (GTK_WINDOW (mbox), _("GIMP Message")); - gtk_window_position (GTK_WINDOW (mbox), GTK_WIN_POS_MOUSE); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (mbox)->action_area), 2); - - gtk_signal_connect (GTK_OBJECT (mbox), "delete_event", - GTK_SIGNAL_FUNC (message_box_delete_callback), - msg_box); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) message_box_close_callback, - msg_box); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (mbox)->action_area), button, - TRUE, TRUE, 0); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (mbox)->vbox), vbox); - gtk_widget_show (vbox); - - label = gtk_label_new (message); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); - gtk_widget_show (label); - - msg_box->mbox = mbox; - msg_box->callback = callback; - msg_box->data = data; - - gtk_widget_show (mbox); - - return mbox; -} - -static gint -message_box_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - message_box_close_callback (widget, client_data); - - return TRUE; -} - -static void -message_box_close_callback (GtkWidget *widget, - gpointer client_data) -{ - MessageBox *msg_box; - - msg_box = (MessageBox *) client_data; - - /* If there is a valid callback, invoke it */ - if (msg_box->callback) - (* msg_box->callback) (widget, msg_box->data); - - /* Destroy the box */ - gtk_widget_destroy (msg_box->mbox); - - g_free (msg_box); -} - - /* DnD functions */ static void toolbox_set_drag_dest (GtkWidget *object) diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index d0cb420d0f..3c9828fc03 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -20,85 +20,30 @@ #include "toolsF.h" #include "gdisplayF.h" -#include "libgimp/gimpunit.h" - -/* typedefs */ -typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer); /* externed variables */ extern GtkWidget * tool_widgets[]; extern GtkTooltips * tool_tips; /* function declarations */ -GtkWidget * create_pixmap_widget (GdkWindow *parent, - gchar **data, - gint width, - gint height); +GtkWidget * create_pixmap_widget (GdkWindow *parent, + gchar **data, + gint width, + gint height); -GdkPixmap * create_tool_pixmap (GtkWidget *parent, - ToolType type); +GdkPixmap * create_tool_pixmap (GtkWidget *parent, + ToolType type); void create_toolbox (void); void toolbox_free (void); -void toolbox_raise_callback (GtkWidget *widget, - gpointer client_data); +void toolbox_raise_callback (GtkWidget *widget, + gpointer client_data); -void create_display_shell (GDisplay *gdisp, - gint width, - gint height, - gchar *title, - gint type); - -/* some simple query dialogs - * if object != NULL then the query boxes will connect their cancel callback - * to the provided signal of this object - * - * it's the caller's job to show the returned widgets - */ -GtkWidget * query_string_box (gchar *title, - gchar *message, - gchar *initial, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_int_box (gchar *title, - char *message, - gint initial, - gint lower, - gint upper, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_double_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_size_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GUnit unit, - gdouble resolution, - gint dot_for_dot, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); - -/* a simple message box */ -GtkWidget * message_box (gchar *message, - GtkCallback callback, - gpointer data); +void create_display_shell (GDisplay *gdisp, + gint width, + gint height, + gchar *title, + gint type); #endif /* __INTERFACE_H__ */ diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c index 9df75642b8..d6e08dd238 100644 --- a/app/display/gimpnavigationeditor.c +++ b/app/display/gimpnavigationeditor.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,6 +28,7 @@ #include "info_window.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimphelp.h" #include "gximage.h" #include "interface.h" #include "scroll.h" @@ -1144,19 +1144,21 @@ nav_window_create (void *gdisp_ptr) /* create the info dialog */ title_buf = g_strdup_printf (_("%s: Window Navigation"), title); - info_win = info_dialog_new (title_buf); - dialog_register(info_win->shell); + info_win = info_dialog_new (title_buf, + gimp_standard_help_func, + "dialogs/navigation_window.html"); + dialog_register (info_win->shell); gtk_signal_connect (GTK_OBJECT (info_win->shell), "destroy", (GtkSignalFunc) nav_window_destroy_callback, info_win); g_free (title_buf); - - iwd = create_dummy_iwd(gdisp_ptr,NAV_WINDOW); + + iwd = create_dummy_iwd (gdisp_ptr, NAV_WINDOW); info_win->user_data = iwd; iwd->info_win = info_win; /* Add preview */ - container = info_window_image_preview_new(info_win); + container = info_window_image_preview_new (info_win); gtk_table_attach_defaults (GTK_TABLE (info_win->info_table), container, 0, 2, 0, 1); /* Create the action area */ diff --git a/app/display/gimpnavigationview.c b/app/display/gimpnavigationview.c index 9df75642b8..d6e08dd238 100644 --- a/app/display/gimpnavigationview.c +++ b/app/display/gimpnavigationview.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,6 +28,7 @@ #include "info_window.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimphelp.h" #include "gximage.h" #include "interface.h" #include "scroll.h" @@ -1144,19 +1144,21 @@ nav_window_create (void *gdisp_ptr) /* create the info dialog */ title_buf = g_strdup_printf (_("%s: Window Navigation"), title); - info_win = info_dialog_new (title_buf); - dialog_register(info_win->shell); + info_win = info_dialog_new (title_buf, + gimp_standard_help_func, + "dialogs/navigation_window.html"); + dialog_register (info_win->shell); gtk_signal_connect (GTK_OBJECT (info_win->shell), "destroy", (GtkSignalFunc) nav_window_destroy_callback, info_win); g_free (title_buf); - - iwd = create_dummy_iwd(gdisp_ptr,NAV_WINDOW); + + iwd = create_dummy_iwd (gdisp_ptr, NAV_WINDOW); info_win->user_data = iwd; iwd->info_win = info_win; /* Add preview */ - container = info_window_image_preview_new(info_win); + container = info_window_image_preview_new (info_win); gtk_table_attach_defaults (GTK_TABLE (info_win->info_table), container, 0, 2, 0, 1); /* Create the action area */ diff --git a/app/display/gimpprogress.c b/app/display/gimpprogress.c index 9cdc7a0b7e..a1832b69c7 100644 --- a/app/display/gimpprogress.c +++ b/app/display/gimpprogress.c @@ -15,13 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - #include "appenv.h" #include "gdisplay.h" #include "libgimp/gimpintl.h" #include "gimpprogress.h" - +#include "gimpui.h" struct gimp_progress_pvt { GDisplay *gdisp; /* gdisp in use, or NULL*/ @@ -63,14 +61,17 @@ static void progress_signal_setup (gimp_progress *, GtkSignalFunc, gpointer); * shown to the user if it would mean creating a new window. */ gimp_progress * -progress_start (GDisplay *gdisp, const char *message, gboolean important, - GtkSignalFunc cancel_callback, gpointer cancel_data) +progress_start (GDisplay *gdisp, + const char *message, + gboolean important, + GtkSignalFunc cancel_callback, + gpointer cancel_data) { gimp_progress *p; guint cid; GtkWidget *vbox; - p = g_malloc (sizeof (*p)); + p = g_new (gimp_progress, 1); p->gdisp = gdisp; p->dialog = NULL; @@ -105,23 +106,22 @@ progress_start (GDisplay *gdisp, const char *message, gboolean important, } p->gdisp = NULL; - p->dialog = gtk_dialog_new (); + p->dialog = gimp_dialog_new (_("Progress"), "plug_in_progress", + NULL, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* not strictly true anymore, but needed in case anyone's window - * manager knows about WMCLASS "plug_in_progress" */ - gtk_window_set_wmclass (GTK_WINDOW (p->dialog), - "plug_in_progress", "Gimp"); + _("Cancel"), NULL, + NULL, &p->cancelbutton, TRUE, TRUE, - gtk_window_set_title (GTK_WINDOW (p->dialog), _("Progress")); - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (p->dialog)->action_area), 2); + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (p->dialog)->vbox), vbox); gtk_widget_show (vbox); - p->dialog_label = gtk_label_new (message? message : + p->dialog_label = gtk_label_new (message ? message : DEFAULT_PROGRESS_MESSAGE); gtk_misc_set_alignment (GTK_MISC (p->dialog_label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), p->dialog_label, FALSE, TRUE, 0); @@ -132,13 +132,6 @@ progress_start (GDisplay *gdisp, const char *message, gboolean important, gtk_box_pack_start (GTK_BOX (vbox), p->progressbar, TRUE, TRUE, 0); gtk_widget_show (p->progressbar); - p->cancelbutton = gtk_button_new_with_label (_("Cancel")); - GTK_WIDGET_SET_FLAGS (p->cancelbutton, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->action_area), - p->cancelbutton, TRUE, TRUE, 0); - gtk_widget_grab_default (p->cancelbutton); - gtk_widget_show (p->cancelbutton); - gtk_widget_show (p->dialog); } @@ -151,8 +144,10 @@ progress_start (GDisplay *gdisp, const char *message, gboolean important, /* Update the message and/or the callbacks for a progress and reset * the bar to zero, with the minimum of disturbance to the user. */ gimp_progress * -progress_restart (gimp_progress *p, const char *message, - GtkSignalFunc cancel_callback, gpointer cancel_data) +progress_restart (gimp_progress *p, + const char *message, + GtkSignalFunc cancel_callback, + gpointer cancel_data) { int cid; GtkWidget *bar; @@ -174,7 +169,7 @@ progress_restart (gimp_progress *p, const char *message, else { gtk_label_set_text (GTK_LABEL (p->dialog_label), - message? message : DEFAULT_PROGRESS_MESSAGE); + message ? message : DEFAULT_PROGRESS_MESSAGE); bar = p->progressbar; } @@ -189,7 +184,8 @@ progress_restart (gimp_progress *p, const char *message, void -progress_update (gimp_progress *progress, float percentage) +progress_update (gimp_progress *progress, + float percentage) { GtkWidget *bar; @@ -210,7 +206,10 @@ progress_update (gimp_progress *progress, float percentage) /* This function's prototype is conveniently the same as progress_func_t */ void -progress_update_and_flush (int ymin, int ymax, int curr_y, gpointer data) +progress_update_and_flush (int ymin, + int ymax, + int curr_y, + gpointer data) { progress_update ((gimp_progress *)data, (float)(curr_y - ymin) / (float)(ymax - ymin)); @@ -275,12 +274,11 @@ progress_end (gimp_progress *p) } - /* Helper function to add or remove signals */ static void progress_signal_setup (gimp_progress *p, - GtkSignalFunc cancel_callback, - gpointer cancel_data) + GtkSignalFunc cancel_callback, + gpointer cancel_data) { GtkWidget *button; GtkWidget *dialog; @@ -322,11 +320,10 @@ progress_signal_setup (gimp_progress *p, } gtk_widget_set_sensitive (GTK_WIDGET (button), - cancel_callback? TRUE : FALSE); + cancel_callback ? TRUE : FALSE); p->cancel_callback = cancel_callback; p->cancel_data = cancel_data; } - /* End of gimpprogress.c */ diff --git a/app/errorconsole.c b/app/errorconsole.c index 13a7341b0c..ebad88615c 100644 --- a/app/errorconsole.c +++ b/app/errorconsole.c @@ -18,7 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -47,12 +46,11 @@ #endif #endif -#include "actionarea.h" - #include #include "appenv.h" #include "commands.h" +#include "gimpui.h" #include "session.h" #include "dialog_handler.h" @@ -83,16 +81,6 @@ error_console_clear_callback (GtkWidget *widget, (GTK_EDITABLE (text), 0, gtk_text_get_length (GTK_TEXT (text))); } -static gint -error_console_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - error_console_close_callback (NULL, NULL); - - return TRUE; -} - void error_console_free (void) { @@ -104,13 +92,13 @@ gint error_console_write_file (gchar *path, gint textscope) { - gint fd; - gint text_length; - gint bytes_written; + gint fd; + gint text_length; + gint bytes_written; gchar *text_contents; - GtkText *gtext; - - gtext = GTK_TEXT(text); + GtkText *gtext; + + gtext = GTK_TEXT (text); fd = open (path, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); @@ -165,9 +153,9 @@ static void error_console_file_ok_callback (GtkWidget *widget, gpointer data) { - GtkWidget *filesel; - gchar *filename; - gint textscope; + GtkWidget *filesel; + gchar *filename; + gint textscope; filesel = (GtkWidget *) data; filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)); @@ -179,7 +167,8 @@ error_console_file_ok_callback (GtkWidget *widget, GString *string; string = g_string_new (""); - g_string_sprintf (string, _("Error opening file %s: %s"), filename, g_strerror (errno)); + g_string_sprintf (string, _("Error opening file %s: %s"), + filename, g_strerror (errno)); g_message (string->str); g_string_free (string, TRUE); } @@ -190,9 +179,10 @@ error_console_file_ok_callback (GtkWidget *widget, static void error_console_menu_callback (gint textscope) { - GtkWidget *filesel; + GtkWidget *filesel; - if (!(GTK_TEXT (text)->editable.has_selection) && (textscope == ERRORS_SELECTION)) + if (!(GTK_TEXT (text)->editable.has_selection) && + (textscope == ERRORS_SELECTION)) { g_message (_("Can't save, nothing selected!")); return; @@ -213,16 +203,22 @@ error_console_menu_callback (gint textscope) gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button), "delete_event", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (filesel)); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (filesel, + gimp_standard_help_func, + "dialogs/error_console.html"); + gtk_widget_show (filesel); } static gint -text_clicked_callback (GtkWidget *widget, - GdkEventButton *event, - gpointer data) +text_clicked_callback (GtkWidget *widget, + GdkEventButton *event, + gpointer data) { - GtkMenu *menu = (GtkMenu *) data; - GtkText *gtext; + GtkMenu *menu = (GtkMenu *) data; + GtkText *gtext; gtext = GTK_TEXT (text); @@ -262,35 +258,40 @@ text_clicked_callback (GtkWidget *widget, return TRUE; } -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Clear"), error_console_clear_callback, NULL, NULL }, - { N_("Close"), error_console_close_callback, NULL, NULL } -}; - static void error_console_create_window (void) { - GtkWidget *table; - GtkWidget *vscrollbar; - GtkWidget *menu; - GtkWidget *menuitem; + GtkWidget *table; + GtkWidget *vscrollbar; + GtkWidget *menu; + GtkWidget *menuitem; - error_console = gtk_dialog_new (); + error_console = gimp_dialog_new (_("GIMP Error Console"), "error_console", + gimp_standard_help_func, + "dialogs/error_console.html", + GTK_WIN_POS_NONE, + TRUE, TRUE, FALSE, + _("Clear"), error_console_clear_callback, + NULL, NULL, FALSE, FALSE, + _("Close"), error_console_close_callback, + text, NULL, TRUE, TRUE, + + NULL); /* register this one only */ dialog_register (error_console); + session_set_window_geometry (error_console, &error_console_session_info, + TRUE); - gtk_window_set_wmclass (GTK_WINDOW (error_console), "error_console", "Gimp"); - gtk_window_set_title (GTK_WINDOW (error_console), _("GIMP Error console")); - session_set_window_geometry (error_console, &error_console_session_info, TRUE); /* The next line should disappear when setting the size works in SM */ gtk_widget_set_usize (error_console, 250, 300); - gtk_window_set_policy (GTK_WINDOW(error_console), TRUE, TRUE, FALSE); - gtk_signal_connect (GTK_OBJECT (error_console), "delete_event", - (GdkEventFunc) error_console_delete_callback, NULL); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (error_console)->vbox), 2); + + table = gtk_table_new (2, 2, FALSE); + gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (error_console)->vbox), table); + gtk_widget_show (table); menu = gtk_menu_new (); @@ -308,13 +309,6 @@ error_console_create_window (void) (gpointer) ERRORS_SELECTION); gtk_widget_show (menuitem); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - gtk_container_set_border_width (GTK_CONTAINER (table), 0); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (error_console)->vbox), table, TRUE, TRUE, 0); - gtk_widget_show (table); - /* The output text widget */ text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), FALSE); @@ -334,11 +328,6 @@ error_console_create_window (void) GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (vscrollbar); - /* Action area */ - action_items[0].user_data = error_console; - action_items[1].user_data = text; - build_action_area (GTK_DIALOG (error_console), action_items, 2, 0); - gtk_widget_show (error_console); } diff --git a/app/errors.c b/app/errors.c index 612abcc926..46d0ebe819 100644 --- a/app/errors.c +++ b/app/errors.c @@ -36,9 +36,10 @@ #include #include "appenv.h" #include "app_procs.h" -#include "interface.h" #include "errorconsole.h" #include "errors.h" +#include "gimpui.h" + #include "libgimp/gimpintl.h" #ifdef NATIVE_WIN32 @@ -54,7 +55,7 @@ gimp_message_func (gchar *str) switch (message_handler) { case MESSAGE_BOX: - message_box (str, NULL, NULL); + gimp_message_box (str, NULL, NULL); break; case ERROR_CONSOLE: diff --git a/app/file_new_dialog.c b/app/file_new_dialog.c index 333e6d9c5f..f23969962d 100644 --- a/app/file_new_dialog.c +++ b/app/file_new_dialog.c @@ -15,11 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "file_new_dialog.h" - -#include "actionarea.h" #include "gimprc.h" +#include "gimpui.h" #include "gdisplay.h" #include "libgimp/gimpchainbutton.h" @@ -27,7 +25,8 @@ #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" -typedef struct { +typedef struct +{ GtkWidget *dlg; GtkWidget *confirm_dlg; @@ -50,7 +49,6 @@ static void file_new_confirm_dialog (NewImageInfo *); static void file_new_ok_callback (GtkWidget *, gpointer); static void file_new_reset_callback (GtkWidget *, gpointer); -static gint file_new_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void file_new_cancel_callback (GtkWidget *, gpointer); static void file_new_toggle_callback (GtkWidget *, gpointer); static void file_new_resolution_callback (GtkWidget *, gpointer); @@ -136,15 +134,6 @@ file_new_reset_callback (GtkWidget *widget, (GTK_TOGGLE_BUTTON (info->fill_type_w[BACKGROUND_FILL]), TRUE); } -static gint -file_new_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - file_new_cancel_callback (widget, data); - return TRUE; -} - static void file_new_cancel_callback (GtkWidget *widget, gpointer data) @@ -185,15 +174,6 @@ file_new_confirm_dialog_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (info->dlg, TRUE); } -static gint -file_new_confirm_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - file_new_confirm_dialog_cancel_callback (widget, data); - return TRUE; -} - static void file_new_confirm_dialog (NewImageInfo *info) { @@ -202,32 +182,21 @@ file_new_confirm_dialog (NewImageInfo *info) gchar *max_size; gchar *text; - static ActionAreaItem action_items[] = - { - { N_("OK"), - (ActionCallback) file_new_confirm_dialog_ok_callback, NULL, NULL }, - { N_("Cancel"), - (ActionCallback) file_new_confirm_dialog_cancel_callback, NULL, NULL } - }; - gtk_widget_set_sensitive (info->dlg, FALSE); - info->confirm_dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (info->confirm_dlg), - "confirm_size", "Gimp"); - gtk_window_set_title (GTK_WINDOW (info->confirm_dlg), _("Confirm Image Size")); - gtk_window_set_policy (GTK_WINDOW (info->confirm_dlg), FALSE, FALSE, FALSE); - gtk_window_position (GTK_WINDOW (info->confirm_dlg), GTK_WIN_POS_MOUSE); + info->confirm_dlg = + gimp_dialog_new (_("Confirm Image Size"), "confirm_size", + gimp_standard_help_func, + "dialogs/file_new_dialog.html#confirm_size_dialog", + GTK_WIN_POS_MOUSE, + FALSE, FALSE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (info->confirm_dlg), "delete_event", - (GtkSignalFunc) file_new_confirm_dialog_delete_callback, - info); + _("OK"), file_new_confirm_dialog_ok_callback, + info, NULL, TRUE, FALSE, + _("Cancel"), file_new_confirm_dialog_cancel_callback, + info, NULL, FALSE, TRUE, - /* The action area */ - action_items[0].user_data = info; - action_items[1].user_data = info; - build_action_area (GTK_DIALOG (info->confirm_dlg), action_items, 2, 0); + NULL); size = image_new_get_size_string (info->size); max_size = image_new_get_size_string (max_new_image_size); @@ -326,15 +295,14 @@ file_new_image_size_callback (GtkWidget *widget, gpointer data) { NewImageInfo *info; - gdouble width, height; gchar *text; gchar *label; info = (NewImageInfo*) data; - width = (gdouble) (gint) + info->values->width = (gdouble) (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - height = (gdouble) (gint) + info->values->height = (gdouble) (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); info->size = image_new_calculate_size (info->values); @@ -391,35 +359,26 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) GSList *group; GList *list; - static ActionAreaItem action_items[] = - { - { N_("OK"), file_new_ok_callback, NULL, NULL }, - { N_("Reset"), file_new_reset_callback, NULL, NULL }, - { N_("Cancel"), file_new_cancel_callback, NULL, NULL } - }; - info = g_new (NewImageInfo, 1); info->values = values = image_new_values_new (values_orig); info->confirm_dlg = NULL; info->size = 0.0; - info->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (info->dlg), "new_image", "Gimp"); - gtk_window_set_title (GTK_WINDOW (info->dlg), _("New Image")); - gtk_window_set_position (GTK_WINDOW (info->dlg), GTK_WIN_POS_MOUSE); - gtk_window_set_policy(GTK_WINDOW (info->dlg), FALSE, FALSE, TRUE); + info->dlg = gimp_dialog_new (_("New Image"), "new_image", + gimp_standard_help_func, + "dialogs/file_new_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, FALSE, TRUE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (info->dlg), "delete_event", - GTK_SIGNAL_FUNC (file_new_delete_callback), - info); + _("OK"), file_new_ok_callback, + info, NULL, FALSE, FALSE, + _("Reset"), file_new_reset_callback, + info, NULL, FALSE, FALSE, + _("Cancel"), file_new_cancel_callback, + info, NULL, TRUE, TRUE, - /* The action area */ - action_items[0].user_data = info; - action_items[1].user_data = info; - action_items[2].user_data = info; - build_action_area (GTK_DIALOG (info->dlg), action_items, 3, 2); + NULL); /* vbox holding the rest of the dialog */ top_vbox = gtk_vbox_new (FALSE, 2); diff --git a/app/fileops.c b/app/fileops.c index c2e1e746d3..530f2114a6 100644 --- a/app/fileops.c +++ b/app/fileops.c @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #ifdef HAVE_SYS_PARAM_H @@ -42,14 +41,13 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "cursorutil.h" #include "gdisplay.h" #include "general.h" #include "gimage.h" #include "gimpcontext.h" +#include "gimpui.h" #include "fileops.h" -#include "interface.h" #include "menus.h" #include "layer.h" #include "channel.h" @@ -73,54 +71,42 @@ struct _OverwriteBox static void file_overwrite (char *filename, char* raw_filename); -static void file_overwrite_yes_callback (GtkWidget *w, - gpointer client_data); -static void file_overwrite_no_callback (GtkWidget *w, - gpointer client_data); - -static gint file_overwrite_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data); +static void file_overwrite_yes_callback (GtkWidget *, gpointer); +static void file_overwrite_no_callback (GtkWidget *, gpointer); static GimpImage* file_open_image (char *filename, char *raw_filename, RunModeType runmode); -static void genbutton_callback (GtkWidget *w, - gpointer client_data); +static void genbutton_callback (GtkWidget *, gpointer); -static void file_open_clistrow_callback (GtkWidget *w, - int client_data); -static void file_open_ok_callback (GtkWidget *w, - gpointer client_data); -static void file_save_ok_callback (GtkWidget *w, - gpointer client_data); +static void file_open_clistrow_callback (GtkWidget *, gint); +static void file_open_ok_callback (GtkWidget *, gpointer); +static void file_save_ok_callback (GtkWidget *, gpointer); static void file_dialog_show (GtkWidget *filesel); static int file_dialog_hide (GtkWidget *filesel); static void file_update_name (PlugInProcDef *proc, GtkWidget *filesel); -static void file_load_type_callback (GtkWidget *w, - gpointer client_data); -static void file_save_type_callback (GtkWidget *w, - gpointer client_data); +static void file_load_type_callback (GtkWidget *, gpointer); +static void file_save_type_callback (GtkWidget *, gpointer); static void file_convert_string (char *instr, char *outmem, - int maxmem, - int *nmem); + int maxmem, + int *nmem); -static int file_check_single_magic (char *offset, - char *type, - char *value, - int headsize, - unsigned char *file_head, - FILE *ifp); +static int file_check_single_magic (char *offset, + char *type, + char *value, + int headsize, + guchar *file_head, + FILE *ifp); static int file_check_magic_list (GSList *magics_list, - int headsize, - unsigned char *head, - FILE *ifp); + int headsize, + guchar *head, + FILE *ifp); static void file_update_menus (GSList *procs, int image_type); @@ -149,20 +135,20 @@ static GimpImage *the_gimage = NULL; extern GSList *display_list; /* from gdisplay.c */ -#define FILE_ERR_MESSAGE(str) G_STMT_START{ \ - if (message_handler == MESSAGE_BOX) \ - message_box ((str), file_message_box_close_callback, (void *) fs); \ - else \ - g_message (str); \ +#define FILE_ERR_MESSAGE(str) G_STMT_START{ \ + if (message_handler == MESSAGE_BOX) \ + gimp_message_box ((str), file_message_box_close_callback, (void *) fs); \ + else \ + g_message (str); \ gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE); }G_STMT_END static void -file_message_box_close_callback (GtkWidget *w, - gpointer client_data) +file_message_box_close_callback (GtkWidget *widget, + gpointer data) { GtkFileSelection *fs; - fs = (GtkFileSelection *) client_data; + fs = (GtkFileSelection *) data; gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE); } @@ -212,8 +198,8 @@ file_ops_post_init (void) } void -file_open_callback (GtkWidget *w, - gpointer client_data) +file_open_callback (GtkWidget *widget, + gpointer data) { GtkWidget *hbox; GtkWidget *vbox; @@ -244,6 +230,11 @@ file_open_callback (GtkWidget *w, /* Catch file-clist clicks so we can update the preview thumbnail */ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (fileload)->file_list), "select_row", (GtkSignalFunc) file_open_clistrow_callback, fileload); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (fileload, + gimp_standard_help_func, + "dialogs/file_load_dialog.html"); } else { @@ -408,8 +399,8 @@ file_open_callback (GtkWidget *w, } void -file_save_callback (GtkWidget *w, - gpointer client_data) +file_save_callback (GtkWidget *widget, + gpointer data) { GDisplay *gdisplay; @@ -421,7 +412,7 @@ file_save_callback (GtkWidget *w, { if (gdisplay->gimage->has_filename == FALSE) { - file_save_as_callback (w, client_data); + file_save_as_callback (widget, data); } else { @@ -432,8 +423,8 @@ file_save_callback (GtkWidget *w, } void -file_save_as_callback (GtkWidget *w, - gpointer client_data) +file_save_as_callback (GtkWidget *widget, + gpointer data) { GtkWidget *hbox; GtkWidget *label; @@ -466,6 +457,11 @@ file_save_as_callback (GtkWidget *w, gtk_file_selection_set_filename (GTK_FILE_SELECTION(filesave), "." G_DIR_SEPARATOR_S); gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image")); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (filesave, + gimp_standard_help_func, + "dialogs/file_save_dialog.html"); } gdisplay = gdisplay_active (); @@ -515,12 +511,12 @@ file_save_as_callback (GtkWidget *w, } void -file_revert_callback (GtkWidget *w, - gpointer client_data) +file_revert_callback (GtkWidget *widget, + gpointer data) { GDisplay *gdisplay; GimpImage *gimage; - char *filename, *raw_filename; + gchar *filename = NULL, *raw_filename = NULL; gdisplay = gdisplay_active (); if (!gdisplay) return; @@ -546,21 +542,22 @@ file_revert_callback (GtkWidget *w, } void -file_load_by_extension_callback (GtkWidget *w, - gpointer client_data) +file_load_by_extension_callback (GtkWidget *widget, + gpointer data) { load_file_proc = NULL; } void -file_save_by_extension_callback (GtkWidget *w, - gpointer client_data) +file_save_by_extension_callback (GtkWidget *widget, + gpointer data) { save_file_proc = NULL; } static void -file_update_name (PlugInProcDef *proc, GtkWidget *filesel) +file_update_name (PlugInProcDef *proc, + GtkWidget *filesel) { if (proc->extensions_list) { @@ -586,10 +583,10 @@ file_update_name (PlugInProcDef *proc, GtkWidget *filesel) } static void -file_load_type_callback (GtkWidget *w, - gpointer client_data) +file_load_type_callback (GtkWidget *widget, + gpointer data) { - PlugInProcDef* proc = (PlugInProcDef *) client_data; + PlugInProcDef* proc = (PlugInProcDef *) data; file_update_name (proc, fileload); @@ -597,10 +594,10 @@ file_load_type_callback (GtkWidget *w, } static void -file_save_type_callback (GtkWidget *w, - gpointer client_data) +file_save_type_callback (GtkWidget *widget, + gpointer data) { - PlugInProcDef* proc = (PlugInProcDef *) client_data; + PlugInProcDef* proc = (PlugInProcDef *) data; file_update_name (proc, filesave); @@ -608,7 +605,9 @@ file_save_type_callback (GtkWidget *w, } static GimpImage* -file_open_image (char *filename, char *raw_filename, RunModeType runmode) +file_open_image (char *filename, + char *raw_filename, + RunModeType runmode) { PlugInProcDef *file_proc; ProcRecord *proc; @@ -658,7 +657,8 @@ file_open_image (char *filename, char *raw_filename, RunModeType runmode) } int -file_open (char *filename, char *raw_filename) +file_open (char *filename, + char *raw_filename) { GimpImage *gimage; GDisplay *gdisplay; @@ -687,8 +687,7 @@ file_open (char *filename, char *raw_filename) return FALSE; } - -static TempBuf* +static TempBuf * make_thumb_tempbuf (GimpImage* gimage) { gint w,h; @@ -722,9 +721,10 @@ make_thumb_tempbuf (GimpImage* gimage) return (gimp_image_composite_preview (gimage, GRAY_CHANNEL, w, h)); } - -static guchar* -make_RGBbuf_from_tempbuf (TempBuf* tempbuf, gint* width_rtn, gint* height_rtn) +static guchar * +make_RGBbuf_from_tempbuf (TempBuf *tempbuf, + gint *width_rtn, + gint *height_rtn) { int i,j,w,h; guchar* tbd; @@ -794,9 +794,9 @@ make_RGBbuf_from_tempbuf (TempBuf* tempbuf, gint* width_rtn, gint* height_rtn) static gboolean -file_save_thumbnail (GimpImage* gimage, +file_save_thumbnail (GimpImage * gimage, const char *full_source_filename, - TempBuf* tempbuf) + TempBuf *tempbuf) { gint i,j; gint w,h; @@ -944,12 +944,11 @@ file_save_thumbnail (GimpImage* gimage, return (TRUE); } - int -file_save (GimpImage* gimage, - char *filename, - char *raw_filename, - gint mode) +file_save (GimpImage *gimage, + char *filename, + char *raw_filename, + gint mode) { PlugInProcDef *file_proc; ProcRecord *proc; @@ -1029,9 +1028,10 @@ file_save (GimpImage* gimage, /* The readXVThumb function source may be re-used under the XFree86-style license. */ static guchar* -readXVThumb(const gchar *fnam, - gint* w, gint* h, - gchar** imginfo /* caller frees if != NULL */) +readXVThumb(const gchar *fnam, + gint *w, + gint *h, + gchar **imginfo /* caller frees if != NULL */) { FILE *fp; const gchar *P7_332 = "P7 332"; @@ -1112,10 +1112,12 @@ readXVThumb(const gchar *fnam, return(buf); } - /* don't call with preview_fullname as parameter! will be clobbered! */ static void -set_preview (const gchar* fullfname, guchar* RGB_source, gint RGB_w, gint RGB_h) +set_preview (const gchar *fullfname, + guchar *RGB_source, + gint RGB_w, + gint RGB_h) { guchar *thumb_rgb; guchar *raw_thumb; @@ -1255,23 +1257,21 @@ set_preview (const gchar* fullfname, guchar* RGB_source, gint RGB_w, gint RGB_h) } } - static void -file_open_clistrow_callback (GtkWidget *w, - int client_data) +file_open_clistrow_callback (GtkWidget *widget, + int data) { gchar *fullfname = NULL; - fullfname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(fileload)); + fullfname = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fileload)); - gtk_widget_set_sensitive (GTK_WIDGET(open_options_frame), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (open_options_frame), TRUE); set_preview (fullfname, NULL, 0, 0); } - static void -genbutton_callback (GtkWidget *w, - gpointer client_data) +genbutton_callback (GtkWidget *widget, + gpointer data) { GimpImage* gimage_to_be_thumbed; gchar* filename; @@ -1282,9 +1282,9 @@ genbutton_callback (GtkWidget *w, return; } - filename = g_strdup(preview_fullname); + filename = g_strdup (preview_fullname); - gimp_add_busy_cursors(); + gimp_add_busy_cursors (); gtk_widget_set_sensitive (GTK_WIDGET (fileload), FALSE); if ((gimage_to_be_thumbed = file_open_image (filename, g_basename(filename), @@ -1322,10 +1322,9 @@ genbutton_callback (GtkWidget *w, g_free (filename); } - static void -file_open_ok_callback (GtkWidget *w, - gpointer client_data) +file_open_ok_callback (GtkWidget *widget, + gpointer data) { GtkFileSelection *fs; char* filename, *raw_filename, *mfilename; @@ -1334,7 +1333,7 @@ file_open_ok_callback (GtkWidget *w, int err; GString *s; - fs = GTK_FILE_SELECTION (client_data); + fs = GTK_FILE_SELECTION (data); filename = gtk_file_selection_get_filename (fs); raw_filename = gtk_entry_get_text (GTK_ENTRY(fs->selection_entry)); @@ -1364,7 +1363,7 @@ file_open_ok_callback (GtkWidget *w, if (file_open (filename, raw_filename)) { - file_dialog_hide (client_data); + file_dialog_hide (data); gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE); } else @@ -1454,7 +1453,7 @@ file_open_ok_callback (GtkWidget *w, if (file_open (mfilename, temp)) { - file_dialog_hide (client_data); + file_dialog_hide (data); gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE); } else @@ -1490,8 +1489,8 @@ file_open_ok_callback (GtkWidget *w, } static void -file_save_ok_callback (GtkWidget *w, - gpointer client_data) +file_save_ok_callback (GtkWidget *widget, + gpointer data) { GtkFileSelection *fs; char* filename, *raw_filename; @@ -1499,7 +1498,7 @@ file_save_ok_callback (GtkWidget *w, struct stat buf; int err; - fs = GTK_FILE_SELECTION (client_data); + fs = GTK_FILE_SELECTION (data); filename = gtk_file_selection_get_filename (fs); raw_filename = gtk_entry_get_text (GTK_ENTRY(fs->selection_entry)); err = stat (filename, &buf); @@ -1533,7 +1532,7 @@ file_save_ok_callback (GtkWidget *w, gimage_set_save_proc(the_gimage, save_file_proc); if (file_save (the_gimage, filename, raw_filename, 0)) { - file_dialog_hide (client_data); + file_dialog_hide (data); gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE); return; } @@ -1577,45 +1576,41 @@ file_dialog_hide (GtkWidget *filesel) } static void -file_overwrite (char *filename, char* raw_filename) +file_overwrite (char *filename, + char *raw_filename) { - static ActionAreaItem obox_action_items[2] = - { - { N_("Yes"), file_overwrite_yes_callback, NULL, NULL }, - { N_("No"), file_overwrite_no_callback, NULL, NULL } - }; - OverwriteBox *overwrite_box; GtkWidget *vbox; GtkWidget *label; char *overwrite_text; - overwrite_box = (OverwriteBox *) g_malloc (sizeof (OverwriteBox)); + overwrite_box = g_new (OverwriteBox, 1); overwrite_text = g_strdup_printf (_("%s exists, overwrite?"), filename); overwrite_box->full_filename = filename; overwrite_box->raw_filename = raw_filename; - overwrite_box->obox = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (overwrite_box->obox), "file_exists", "Gimp"); - gtk_window_set_title (GTK_WINDOW (overwrite_box->obox), _("File Exists!")); - gtk_window_set_position (GTK_WINDOW (overwrite_box->obox), GTK_WIN_POS_MOUSE); + overwrite_box->obox = + gimp_dialog_new (_("File Exists!"), "file_exists", + gimp_standard_help_func, + "dialogs/file_exists_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (overwrite_box->obox), - "delete_event", - (GtkSignalFunc) file_overwrite_delete_callback, - overwrite_box); + _("Yes"), file_overwrite_yes_callback, + overwrite_box, NULL, TRUE, FALSE, + _("No"), file_overwrite_no_callback, + overwrite_box, NULL, FALSE, TRUE, - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (overwrite_box->obox)->vbox), vbox, TRUE, TRUE, 0); + NULL); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (overwrite_box->obox)->vbox), + vbox); label = gtk_label_new (overwrite_text); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); - obox_action_items[0].user_data = overwrite_box; - obox_action_items[1].user_data = overwrite_box; - build_action_area (GTK_DIALOG (overwrite_box->obox), obox_action_items, 2, 0); - gtk_widget_show (label); gtk_widget_show (vbox); gtk_widget_show (overwrite_box->obox); @@ -1624,13 +1619,13 @@ file_overwrite (char *filename, char* raw_filename) } static void -file_overwrite_yes_callback (GtkWidget *w, - gpointer client_data) +file_overwrite_yes_callback (GtkWidget *widget, + gpointer data) { OverwriteBox *overwrite_box; GImage *gimage; - overwrite_box = (OverwriteBox *) client_data; + overwrite_box = (OverwriteBox *) data; gtk_widget_destroy (overwrite_box->obox); @@ -1657,23 +1652,13 @@ file_overwrite_yes_callback (GtkWidget *w, g_free (overwrite_box); } -static gint -file_overwrite_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - file_overwrite_no_callback (w, client_data); - - return TRUE; -} - static void -file_overwrite_no_callback (GtkWidget *w, - gpointer client_data) +file_overwrite_no_callback (GtkWidget *widget, + gpointer data) { OverwriteBox *overwrite_box; - overwrite_box = (OverwriteBox *) client_data; + overwrite_box = (OverwriteBox *) data; gtk_widget_destroy (overwrite_box->obox); g_free (overwrite_box->full_filename); @@ -2017,6 +2002,7 @@ file_update_menus (GSList *procs, procs = procs->next; if (file_proc->db_info.proc_type != PDB_EXTENSION) - menus_set_sensitive (file_proc->menu_path, (file_proc->image_types_val & image_type)); + menus_set_sensitive (file_proc->menu_path, + (file_proc->image_types_val & image_type)); } } diff --git a/app/gdisplay_color.c b/app/gdisplay_color.c index 47d77abb07..de711cb160 100644 --- a/app/gdisplay_color.c +++ b/app/gdisplay_color.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -23,6 +22,7 @@ #include "gdisplay_color.h" #include "gdisplay.h" #include "gimpimageP.h" +#include "gimpui.h" #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" @@ -75,9 +75,6 @@ static void gamma_configure_ok_callback (GtkWidget *widget, gpointer data); static void gamma_configure_cancel_callback (GtkWidget *widget, gpointer data); -static gint gamma_configure_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); static void gamma_configure (gpointer cd_ID); void @@ -400,15 +397,6 @@ gamma_configure_cancel_callback (GtkWidget *widget, gtk_widget_hide (widget); } -static gint -gamma_configure_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gamma_configure_cancel_callback (widget, data); - return TRUE; -} - static void gamma_configure (gpointer cd_ID) { @@ -417,19 +405,23 @@ gamma_configure (gpointer cd_ID) GtkWidget *hbox; GtkWidget *label; GtkWidget *entry; - GtkWidget *hbbox; - GtkWidget *button; GtkObject *adjustment; if (!context->shell) { - context->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (context->shell), "gamma", "Gimp"); - gtk_window_set_title (GTK_WINDOW (context->shell), _("Gamma")); + context->shell = + gimp_dialog_new (_("Gamma"), "gamma", + gimp_standard_help_func, + "dialogs/gamma_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (context->shell), "delete_event", - GTK_SIGNAL_FUNC (gamma_configure_delete_callback), - NULL); + _("OK"), gamma_configure_ok_callback, + cd_ID, NULL, FALSE, FALSE, + _("Cancel"), gamma_configure_cancel_callback, + cd_ID, NULL, TRUE, TRUE, + + NULL); hbox = gtk_hbox_new (TRUE, 2); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (context->shell)->vbox), @@ -446,27 +438,6 @@ gamma_configure (gpointer cd_ID) gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); gtk_widget_show_all (hbox); - - hbbox = gtk_hbutton_box_new (); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (context->shell)->action_area), - hbbox, FALSE, FALSE, 0); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (gamma_configure_ok_callback), - cd_ID); - - button = gtk_button_new_with_label (_("Cancel")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (gamma_configure_cancel_callback), - cd_ID); - - gtk_widget_show_all (hbbox); } gtk_widget_show (context->shell); diff --git a/app/gdisplay_color_ui.c b/app/gdisplay_color_ui.c index 8a95e96136..3e85750e10 100644 --- a/app/gdisplay_color_ui.c +++ b/app/gdisplay_color_ui.c @@ -15,12 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "actionarea.h" #include "gdisplay.h" #include "gdisplay_color.h" #include "gdisplay_color_ui.h" #include "gimpimageP.h" +#include "gimpui.h" #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" #include @@ -48,7 +47,6 @@ struct _ButtonInfo static void color_display_ok_callback (GtkWidget *, gpointer); static void color_display_cancel_callback (GtkWidget *, gpointer); -static gint color_display_delete_callback (GtkWidget *, gpointer); static gint color_display_destroy_callback (GtkWidget *, gpointer); static void color_display_add_callback (GtkWidget *, gpointer); static void color_display_remove_callback (GtkWidget *, gpointer); @@ -68,12 +66,6 @@ make_dialog (void) char *titles[2]; int i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_display_ok_callback, NULL, NULL }, - { N_("Cancel"), color_display_cancel_callback, NULL, NULL } - }; - static ButtonInfo buttons[] = { { N_("Add"), color_display_add_callback }, @@ -83,13 +75,18 @@ make_dialog (void) { N_("Configure"), color_display_configure_callback } }; - cdd.shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cdd.shell), "display_color", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cdd.shell), _("Color Display Filters")); + cdd.shell = gimp_dialog_new (_("Color Display Filters"), "display_color", + gimp_standard_help_func, + "dialogs/color_diaplsy_filters_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (cdd.shell), "delete_event", - GTK_SIGNAL_FUNC (color_display_delete_callback), - NULL); + _("OK"), color_display_ok_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), color_display_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); hbox = gtk_hbox_new (FALSE, 4); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cdd.shell)->vbox), hbox, @@ -139,10 +136,6 @@ make_dialog (void) } gtk_widget_show_all (hbox); - - action_items[0].user_data = cdd.shell; - action_items[1].user_data = cdd.shell; - build_action_area (GTK_DIALOG (cdd.shell), action_items, 2, 0); } static void @@ -159,14 +152,6 @@ color_display_cancel_callback (GtkWidget *widget, gtk_widget_hide (GTK_WIDGET (data)); } -static gint -color_display_delete_callback (GtkWidget *widget, - gpointer data) -{ - color_display_cancel_callback (widget, data); - return TRUE; -} - static gint color_display_destroy_callback (GtkWidget *widget, gpointer data) diff --git a/app/gdisplay_ops.c b/app/gdisplay_ops.c index c5ebe520b4..884b7352d9 100644 --- a/app/gdisplay_ops.c +++ b/app/gdisplay_ops.c @@ -18,14 +18,13 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "colormaps.h" #include "cursorutil.h" #include "fileops.h" #include "gdisplay_ops.h" #include "gimage.h" +#include "gimpui.h" #include "gximage.h" -#include "interface.h" #include "menus.h" #include "scale.h" #include "gimprc.h" @@ -320,16 +319,6 @@ gdisplay_cancel_warning_callback (GtkWidget *widget, gtk_widget_destroy (mbox); } -static gint -gdisplay_delete_warning_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - gdisplay_cancel_warning_callback (widget, client_data); - - return TRUE; -} - static void gdisplay_destroy_warning_callback (GtkWidget *widget, gpointer client_data) @@ -346,12 +335,6 @@ gdisplay_close_warning_dialog (char *image_name, GtkWidget *label; gchar *warning_buf; - static ActionAreaItem action_items[] = - { - { N_("Close"), gdisplay_close_warning_callback, NULL, NULL }, - { N_("Cancel"), gdisplay_cancel_warning_callback, NULL, NULL } - }; - /* FIXUP this will raise any prexsisting close dialogs, which can be a a bit confusing if you tried to close a new window because you had forgotten the old dialog was still around */ @@ -364,16 +347,21 @@ gdisplay_close_warning_dialog (char *image_name, menus_set_sensitive_glue ("", N_("/File/Close"), FALSE); - warning_dialog = mbox = gtk_dialog_new (); - /* should this be image_window or the actual image name??? */ - gtk_window_set_wmclass (GTK_WINDOW (mbox), "really_close", "Gimp"); - gtk_window_set_title (GTK_WINDOW (mbox), image_name); - gtk_window_set_position (GTK_WINDOW (mbox), GTK_WIN_POS_MOUSE); - gtk_object_set_user_data (GTK_OBJECT (mbox), gdisp); + warning_dialog = mbox = + gimp_dialog_new (image_name, "really_close", + gimp_standard_help_func, + "dialogs/really_close_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (mbox), "delete_event", - GTK_SIGNAL_FUNC (gdisplay_delete_warning_callback), - mbox); + _("Close"), gdisplay_close_warning_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), gdisplay_cancel_warning_callback, + NULL, NULL, TRUE, TRUE, + + NULL); + + gtk_object_set_user_data (GTK_OBJECT (mbox), gdisp); gtk_signal_connect (GTK_OBJECT (mbox), "destroy", GTK_SIGNAL_FUNC (gdisplay_destroy_warning_callback), @@ -392,9 +380,5 @@ gdisplay_close_warning_dialog (char *image_name, gtk_widget_show (label); g_free (warning_buf); - action_items[0].user_data = mbox; - action_items[1].user_data = mbox; - build_action_area (GTK_DIALOG (mbox), action_items, 2, 1); - gtk_widget_show (mbox); } diff --git a/app/gimpdrawable-offset.c b/app/gimpdrawable-offset.c index a0309e5502..c61e6748ee 100644 --- a/app/gimpdrawable-offset.c +++ b/app/gimpdrawable-offset.c @@ -18,12 +18,12 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "channel_ops.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" @@ -53,7 +53,6 @@ struct _OffsetDialog /* Forward declarations */ static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static gint offset_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void offset_wraparound_update (GtkWidget *, gpointer); static void offset_fill_type_update (GtkWidget *, gpointer); @@ -77,12 +76,6 @@ channel_ops_offset (GimpImage* gimage) GimpDrawable *drawable; - static ActionAreaItem action_items[] = - { - { N_("OK"), offset_ok_callback, NULL, NULL }, - { N_("Cancel"), offset_cancel_callback, NULL, NULL } - }; - drawable = gimage_active_drawable (gimage); off_d = g_new (OffsetDialog, 1); @@ -90,15 +83,19 @@ channel_ops_offset (GimpImage* gimage) off_d->fill_type = drawable_has_alpha (drawable); off_d->gimage = gimage; - off_d->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (off_d->dlg), "offset", "Gimp"); - gtk_window_set_title (GTK_WINDOW (off_d->dlg), _("Offset")); + off_d->dlg = gimp_dialog_new (_("Offset"), "offset", + gimp_standard_help_func, + "dialogs/offset_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (off_d->dlg), "delete_event", - GTK_SIGNAL_FUNC (offset_delete_callback), - off_d); + _("OK"), offset_ok_callback, + off_d, NULL, TRUE, FALSE, + _("Cancel"), offset_cancel_callback, + off_d, NULL, FALSE, TRUE, + NULL); + /* The vbox for first column of options */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -221,15 +218,10 @@ channel_ops_offset (GimpImage* gimage) (GtkSignalFunc) offset_halfheight_callback, off_d); - action_items[0].user_data = off_d; - action_items[1].user_data = off_d; - build_action_area (GTK_DIALOG (off_d->dlg), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (off_d->dlg); } - void offset (GimpImage *gimage, GimpDrawable *drawable, @@ -495,16 +487,6 @@ offset_ok_callback (GtkWidget *widget, g_free (off_d); } -static gint -offset_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - offset_cancel_callback (widget, data); - - return TRUE; -} - static void offset_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/gimphelp.c b/app/gimphelp.c new file mode 100644 index 0000000000..77e4ae427a --- /dev/null +++ b/app/gimphelp.c @@ -0,0 +1,132 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimphelp.c + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include + +#include "gimphelp.h" +#include "gimprc.h" +#include "plug_in.h" +#include "procedural_db.h" + +#include "libgimp/gimpintl.h" + +/* The standard help function */ +void +gimp_standard_help_func (gpointer help_data) +{ + gchar *help_page; + + help_page = (gchar *) help_data; + gimp_help (help_page); +} + +static void +gimp_help_callback (GtkWidget *widget, + gpointer data) +{ + GimpHelpFunc help_function; + gpointer help_data; + + help_function = (GimpHelpFunc) data; + help_data = gtk_object_get_data (GTK_OBJECT (widget), + "gimp_help_data"); + + if (help_function && use_help) + (* help_function) (help_data); +} + +void +gimp_help_connect_help_accel (GtkWidget *widget, + GimpHelpFunc help_func, + gpointer help_data) +{ + GtkAccelGroup *accel_group; + static guint help_signal_id = 0; + + /* create the help signal if not already done */ + if (! help_signal_id) + { + help_signal_id = + gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass, + "help", + GTK_RUN_LAST, + gtk_signal_default_marshaller, + GTK_TYPE_NONE, + 0, + NULL); + } + + if (help_data) + { + gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", + help_data); + } + + gtk_signal_connect (GTK_OBJECT (widget), "help", + GTK_SIGNAL_FUNC (gimp_help_callback), + (gpointer) help_func); + + /* a new accelerator group for this widget */ + accel_group = gtk_accel_group_new (); + gtk_accel_group_add (accel_group, GDK_F1, 0, 0, + GTK_OBJECT (widget), "help"); + gtk_accel_group_attach (accel_group, GTK_OBJECT (widget)); +} + +/* the main help function */ +void +gimp_help (gchar *help_page) +{ + ProcRecord *proc_rec; + Argument *return_vals; + gint nreturn_vals; + + /* Check if a help browser is already running */ + proc_rec = procedural_db_lookup ("extension_gimp_help_browser_temp"); + if (proc_rec == NULL) + { + proc_rec = procedural_db_lookup ("extension_gimp_help_browser"); + if (proc_rec == NULL) + { + g_message (_("Could not find the GIMP Help Browser procedure\n" + "Note that you still have to compile this plugin " + "manually")); + return; + } + + return_vals = + procedural_db_run_proc ("extension_gimp_help_browser", + &nreturn_vals, + PDB_INT32, RUN_INTERACTIVE, + PDB_STRING, help_page, + PDB_END); + } + else + { + return_vals = + procedural_db_run_proc ("extension_gimp_help_browser_temp", + &nreturn_vals, + PDB_STRING, help_page, + PDB_END); + } + + procedural_db_destroy_args (return_vals, nreturn_vals); +} diff --git a/app/gimphelp.h b/app/gimphelp.h new file mode 100644 index 0000000000..0725084c3a --- /dev/null +++ b/app/gimphelp.h @@ -0,0 +1,39 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimphelp.h + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMP_HELP_H__ +#define __GIMP_HELP_H__ + +#include + +typedef void (* GimpHelpFunc) (gpointer); + +/* the standard help function */ +void gimp_standard_help_func (gpointer help_data); + +/* connect the "F1" accelerator of a window */ +void gimp_help_connect_help_accel (GtkWidget *widget, + GimpHelpFunc help_func, + gpointer help_data); + +/* the main help function */ +void gimp_help (gchar *help_page); + +#endif /* __GIMP_HELP_H__ */ diff --git a/app/gimpimage-convert.c b/app/gimpimage-convert.c index 0df5f9247a..7525cc7742 100644 --- a/app/gimpimage-convert.c +++ b/app/gimpimage-convert.c @@ -86,17 +86,16 @@ #include #include "appenv.h" -#include "actionarea.h" #include "convert.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "fsdither.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "undo.h" #include "palette.h" -#include "preferences_dialog.h" /* ick. */ #include "libgimp/gimpintl.h" #include "libgimp/gimpmath.h" @@ -393,7 +392,6 @@ typedef struct static void indexed_ok_callback (GtkWidget *, gpointer); static void indexed_cancel_callback (GtkWidget *, gpointer); -static gint indexed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void indexed_num_cols_update (GtkWidget *, gpointer); static void indexed_radio_update (GtkWidget *, gpointer); static void frame_sensitivity_update (GtkWidget *, gpointer); @@ -457,13 +455,6 @@ convert_to_grayscale (GimpImage* gimage) gdisplays_flush (); } -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("OK"), indexed_ok_callback, NULL, NULL }, - { N_("Cancel"), indexed_cancel_callback, NULL, NULL } -}; - void convert_to_indexed (GimpImage *gimage) { @@ -478,7 +469,7 @@ convert_to_indexed (GimpImage *gimage) GSList *group = NULL; gint maxval; - dialog = g_new(IndexedDialog, 1); + dialog = g_new (IndexedDialog, 1); dialog->gimage = gimage; dialog->custom_frame = NULL; @@ -496,21 +487,31 @@ convert_to_indexed (GimpImage *gimage) dialog->monopal_flag = smonopal_flag; dialog->reusepal_flag = sreusepal_flag; - dialog->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog->shell), "indexed_color_conversion", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog->shell), _("Indexed Color Conversion")); - gtk_signal_connect (GTK_OBJECT (dialog->shell), "delete_event", - GTK_SIGNAL_FUNC (indexed_delete_callback), - dialog); + dialog->shell = + gimp_dialog_new (_("Indexed Color Conversion"), "indexed_color_conversion", + gimp_standard_help_func, + "dialogs/indexed_color_conversion_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), indexed_ok_callback, + dialog, NULL, TRUE, FALSE, + _("Cancel"), indexed_cancel_callback, + dialog, NULL, FALSE, TRUE, + + NULL); frame = gtk_frame_new (_("General Palette Options")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); gtk_container_set_border_width (GTK_CONTAINER (frame), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox), frame, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox), frame, + TRUE, TRUE, 0); + gtk_widget_show(frame); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_container_set_border_width (GTK_CONTAINER (GTK_BOX (GTK_DIALOG (dialog->shell)->vbox)), 4); + /* put the vbox in the frame */ gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show(vbox); @@ -823,11 +824,6 @@ convert_to_indexed (GimpImage *gimage) gtk_widget_show(frame); } - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (dialog->shell); } @@ -957,16 +953,6 @@ indexed_ok_callback (GtkWidget *widget, dialog = NULL; } -static gint -indexed_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - indexed_cancel_callback (w, client_data); - - return TRUE; -} - static void indexed_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/gimpimage-duplicate.c b/app/gimpimage-duplicate.c index a0309e5502..c61e6748ee 100644 --- a/app/gimpimage-duplicate.c +++ b/app/gimpimage-duplicate.c @@ -18,12 +18,12 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "channel_ops.h" #include "cursorutil.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" @@ -53,7 +53,6 @@ struct _OffsetDialog /* Forward declarations */ static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static gint offset_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void offset_wraparound_update (GtkWidget *, gpointer); static void offset_fill_type_update (GtkWidget *, gpointer); @@ -77,12 +76,6 @@ channel_ops_offset (GimpImage* gimage) GimpDrawable *drawable; - static ActionAreaItem action_items[] = - { - { N_("OK"), offset_ok_callback, NULL, NULL }, - { N_("Cancel"), offset_cancel_callback, NULL, NULL } - }; - drawable = gimage_active_drawable (gimage); off_d = g_new (OffsetDialog, 1); @@ -90,15 +83,19 @@ channel_ops_offset (GimpImage* gimage) off_d->fill_type = drawable_has_alpha (drawable); off_d->gimage = gimage; - off_d->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (off_d->dlg), "offset", "Gimp"); - gtk_window_set_title (GTK_WINDOW (off_d->dlg), _("Offset")); + off_d->dlg = gimp_dialog_new (_("Offset"), "offset", + gimp_standard_help_func, + "dialogs/offset_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (off_d->dlg), "delete_event", - GTK_SIGNAL_FUNC (offset_delete_callback), - off_d); + _("OK"), offset_ok_callback, + off_d, NULL, TRUE, FALSE, + _("Cancel"), offset_cancel_callback, + off_d, NULL, FALSE, TRUE, + NULL); + /* The vbox for first column of options */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -221,15 +218,10 @@ channel_ops_offset (GimpImage* gimage) (GtkSignalFunc) offset_halfheight_callback, off_d); - action_items[0].user_data = off_d; - action_items[1].user_data = off_d; - build_action_area (GTK_DIALOG (off_d->dlg), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (off_d->dlg); } - void offset (GimpImage *gimage, GimpDrawable *drawable, @@ -495,16 +487,6 @@ offset_ok_callback (GtkWidget *widget, g_free (off_d); } -static gint -offset_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - offset_cancel_callback (widget, data); - - return TRUE; -} - static void offset_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/gimpprogress.c b/app/gimpprogress.c index 9cdc7a0b7e..a1832b69c7 100644 --- a/app/gimpprogress.c +++ b/app/gimpprogress.c @@ -15,13 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - #include "appenv.h" #include "gdisplay.h" #include "libgimp/gimpintl.h" #include "gimpprogress.h" - +#include "gimpui.h" struct gimp_progress_pvt { GDisplay *gdisp; /* gdisp in use, or NULL*/ @@ -63,14 +61,17 @@ static void progress_signal_setup (gimp_progress *, GtkSignalFunc, gpointer); * shown to the user if it would mean creating a new window. */ gimp_progress * -progress_start (GDisplay *gdisp, const char *message, gboolean important, - GtkSignalFunc cancel_callback, gpointer cancel_data) +progress_start (GDisplay *gdisp, + const char *message, + gboolean important, + GtkSignalFunc cancel_callback, + gpointer cancel_data) { gimp_progress *p; guint cid; GtkWidget *vbox; - p = g_malloc (sizeof (*p)); + p = g_new (gimp_progress, 1); p->gdisp = gdisp; p->dialog = NULL; @@ -105,23 +106,22 @@ progress_start (GDisplay *gdisp, const char *message, gboolean important, } p->gdisp = NULL; - p->dialog = gtk_dialog_new (); + p->dialog = gimp_dialog_new (_("Progress"), "plug_in_progress", + NULL, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* not strictly true anymore, but needed in case anyone's window - * manager knows about WMCLASS "plug_in_progress" */ - gtk_window_set_wmclass (GTK_WINDOW (p->dialog), - "plug_in_progress", "Gimp"); + _("Cancel"), NULL, + NULL, &p->cancelbutton, TRUE, TRUE, - gtk_window_set_title (GTK_WINDOW (p->dialog), _("Progress")); - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (p->dialog)->action_area), 2); + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (p->dialog)->vbox), vbox); gtk_widget_show (vbox); - p->dialog_label = gtk_label_new (message? message : + p->dialog_label = gtk_label_new (message ? message : DEFAULT_PROGRESS_MESSAGE); gtk_misc_set_alignment (GTK_MISC (p->dialog_label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), p->dialog_label, FALSE, TRUE, 0); @@ -132,13 +132,6 @@ progress_start (GDisplay *gdisp, const char *message, gboolean important, gtk_box_pack_start (GTK_BOX (vbox), p->progressbar, TRUE, TRUE, 0); gtk_widget_show (p->progressbar); - p->cancelbutton = gtk_button_new_with_label (_("Cancel")); - GTK_WIDGET_SET_FLAGS (p->cancelbutton, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->action_area), - p->cancelbutton, TRUE, TRUE, 0); - gtk_widget_grab_default (p->cancelbutton); - gtk_widget_show (p->cancelbutton); - gtk_widget_show (p->dialog); } @@ -151,8 +144,10 @@ progress_start (GDisplay *gdisp, const char *message, gboolean important, /* Update the message and/or the callbacks for a progress and reset * the bar to zero, with the minimum of disturbance to the user. */ gimp_progress * -progress_restart (gimp_progress *p, const char *message, - GtkSignalFunc cancel_callback, gpointer cancel_data) +progress_restart (gimp_progress *p, + const char *message, + GtkSignalFunc cancel_callback, + gpointer cancel_data) { int cid; GtkWidget *bar; @@ -174,7 +169,7 @@ progress_restart (gimp_progress *p, const char *message, else { gtk_label_set_text (GTK_LABEL (p->dialog_label), - message? message : DEFAULT_PROGRESS_MESSAGE); + message ? message : DEFAULT_PROGRESS_MESSAGE); bar = p->progressbar; } @@ -189,7 +184,8 @@ progress_restart (gimp_progress *p, const char *message, void -progress_update (gimp_progress *progress, float percentage) +progress_update (gimp_progress *progress, + float percentage) { GtkWidget *bar; @@ -210,7 +206,10 @@ progress_update (gimp_progress *progress, float percentage) /* This function's prototype is conveniently the same as progress_func_t */ void -progress_update_and_flush (int ymin, int ymax, int curr_y, gpointer data) +progress_update_and_flush (int ymin, + int ymax, + int curr_y, + gpointer data) { progress_update ((gimp_progress *)data, (float)(curr_y - ymin) / (float)(ymax - ymin)); @@ -275,12 +274,11 @@ progress_end (gimp_progress *p) } - /* Helper function to add or remove signals */ static void progress_signal_setup (gimp_progress *p, - GtkSignalFunc cancel_callback, - gpointer cancel_data) + GtkSignalFunc cancel_callback, + gpointer cancel_data) { GtkWidget *button; GtkWidget *dialog; @@ -322,11 +320,10 @@ progress_signal_setup (gimp_progress *p, } gtk_widget_set_sensitive (GTK_WIDGET (button), - cancel_callback? TRUE : FALSE); + cancel_callback ? TRUE : FALSE); p->cancel_callback = cancel_callback; p->cancel_data = cancel_data; } - /* End of gimpprogress.c */ diff --git a/app/gimprc.c b/app/gimprc.c index 5577d2817d..111fb89ec4 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -157,6 +157,7 @@ int show_indicators = TRUE; int max_new_image_size = 33554432; /* 32 MB */ int thumbnail_mode = 1; int trust_dirty_flag = FALSE; +int use_help = FALSE; extern char * module_db_load_inhibit; @@ -307,7 +308,9 @@ static ParseFunc funcs[] = { "max-new-image-size", TT_MEMSIZE, &max_new_image_size, NULL }, { "thumbnail-mode", TT_INT, &thumbnail_mode, NULL }, { "trust-dirty-flag", TT_BOOLEAN, &trust_dirty_flag, NULL }, - { "dont-trust-dirty-flag", TT_BOOLEAN, NULL, &trust_dirty_flag } + { "dont-trust-dirty-flag", TT_BOOLEAN, NULL, &trust_dirty_flag }, + { "use-help", TT_BOOLEAN, &use_help, NULL }, + { "dont-use-help", TT_BOOLEAN, NULL, &use_help } }; static int nfuncs = sizeof (funcs) / sizeof (funcs[0]); diff --git a/app/gimprc.h b/app/gimprc.h index 18a196505b..282b2a443e 100644 --- a/app/gimprc.h +++ b/app/gimprc.h @@ -81,7 +81,7 @@ extern int show_indicators; extern int max_new_image_size; extern int thumbnail_mode; extern int trust_dirty_flag; - +extern int use_help; /* function prototypes */ void parse_buffers_init (); /* this has to be called before any file diff --git a/app/gimpui.c b/app/gimpui.c new file mode 100644 index 0000000000..d5380d3ceb --- /dev/null +++ b/app/gimpui.c @@ -0,0 +1,857 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpui.c + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include "gimpui.h" + +#include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpintl.h" + +/* + * 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; +} + +/* +#include "/home/mitschel/gimpfiles/wilber.xpm" + +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], + wilber_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, + gpointer 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, + * 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, + gpointer help_data, + GtkWindowPosition position, + gint allow_shrink, + gint allow_grow, + gint auto_shrink, + va_list args) +{ + GtkWidget *dialog; + 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_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 */ + gtk_container_set_border_width + (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2); + gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (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 (GTK_DIALOG (dialog)->action_area), hbbox, + FALSE, FALSE, 0); + gtk_widget_show (hbbox); + + /* the action_area buttons */ + label = va_arg (args, gchar*); + 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*); + } + + /* catch the WM delete event if not already done */ + if (! delete_connected) + gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", + (GdkEventFunc) gimp_dialog_delete_callback, + NULL); + + /* 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; +} + +GtkWidget * +gimp_option_menu_new (GtkSignalFunc menu_item_callback, + gpointer initial, /* user_data */ + + /* specify menu items as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...) +{ + GtkWidget *menu; + GtkWidget *menuitem; + GtkWidget *optionmenu; + + /* menu item variables */ + gchar *label; + gpointer data; + gpointer user_data; + + va_list args; + gint i; + gint initial_index; + + menu = gtk_menu_new (); + + /* create the menu items */ + initial_index = 0; + va_start (args, initial); + label = va_arg (args, gchar*); + for (i = 0; label; i++) + { + data = va_arg (args, gpointer); + user_data = va_arg (args, gpointer); + + menuitem = gtk_menu_item_new_with_label (label); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_signal_connect (GTK_OBJECT (menuitem), "activate", + menu_item_callback, data); + gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data); + gtk_widget_show (menuitem); + + /* remember the initial menu item */ + if (user_data == initial) + initial_index = i; + + label = va_arg (args, gchar*); + } + va_end (args); + + optionmenu = gtk_option_menu_new (); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + + /* select the initial menu item */ + gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index); + + return optionmenu; +} + +GtkWidget * +gimp_radio_group_new (GtkSignalFunc radio_button_callback, + gpointer initial, /* user_data */ + + /* specify radio buttons as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...) +{ + GtkWidget *vbox; + GtkWidget *button; + GSList *group; + + /* radio button variables */ + gchar *label; + gpointer data; + gpointer user_data; + + va_list args; + + vbox = gtk_vbox_new (FALSE, 1); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + group = NULL; + + /* create the radio buttons */ + va_start (args, initial); + label = va_arg (args, gchar*); + while (label) + { + data = va_arg (args, gpointer); + user_data = va_arg (args, gpointer); + + button = gtk_radio_button_new_with_label (group, label); + group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "toggled", + (GtkSignalFunc) radio_button_callback, + data); + gtk_object_set_user_data (GTK_OBJECT (button), user_data); + + /* press the initially active radio button */ + if (user_data == initial) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); + + gtk_widget_show (button); + + label = va_arg (args, gchar*); + } + va_end (args); + + return vbox; +} + +GtkWidget * +gimp_spin_button_new (GtkObject **adjustment, /* return value */ + gfloat value, + gfloat lower, + gfloat upper, + gfloat step_increment, + gfloat page_increment, + gfloat page_size, + gfloat climb_rate, + guint digits) +{ + GtkWidget *spinbutton; + + *adjustment = gtk_adjustment_new (value, lower, upper, + step_increment, page_increment, page_size); + + spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment), + climb_rate, digits); + gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), + GTK_SHADOW_NONE); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + gtk_widget_set_usize (spinbutton, 75, 0); + + return spinbutton; +} + + +/* + * String, integer, double and size query boxes + */ + +typedef struct _QueryBox QueryBox; + +struct _QueryBox +{ + GtkWidget *qbox; + GtkWidget *vbox; + GtkWidget *entry; + GtkObject *object; + GimpQueryFunc callback; + gpointer data; +}; + +static QueryBox * create_query_box (gchar *, GimpHelpFunc, gpointer, + GtkSignalFunc, + gchar *, GtkObject *, gchar *, + GimpQueryFunc, gpointer); +static void query_box_cancel_callback (GtkWidget *, gpointer); +static void string_query_box_ok_callback (GtkWidget *, gpointer); +static void int_query_box_ok_callback (GtkWidget *, gpointer); +static void double_query_box_ok_callback (GtkWidget *, gpointer); +static void size_query_box_ok_callback (GtkWidget *, gpointer); + +/* create a generic query box without any entry widget */ +static QueryBox * +create_query_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + GtkSignalFunc ok_callback, + gchar *message, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkWidget *qbox; + GtkWidget *vbox; + GtkWidget *label; + + query_box = g_new (QueryBox, 1); + + qbox = gimp_dialog_new (title, "query_box", + help_func, help_data, + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, + + _("OK"), ok_callback, + query_box, NULL, TRUE, FALSE, + _("Cancel"), query_box_cancel_callback, + query_box, NULL, FALSE, TRUE, + + NULL); + + /* if we are associated with an object, connect to the provided signal */ + if (object && GTK_IS_OBJECT (object) && signal) + gtk_signal_connect (GTK_OBJECT (object), signal, + (GtkSignalFunc) query_box_cancel_callback, + query_box); + else + object = NULL; + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (qbox)->vbox), vbox); + gtk_widget_show (vbox); + + label = gtk_label_new (message); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + query_box->qbox = qbox; + query_box->vbox = vbox; + query_box->entry = NULL; + query_box->object = object; + query_box->callback = callback; + query_box->data = data; + + return query_box; +} + +GtkWidget * +gimp_query_string_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gchar *initial, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkWidget *entry; + + query_box = create_query_box (title, help_func, help_data, + string_query_box_ok_callback, + message, object, signal, callback, data); + + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); + if (initial) + gtk_entry_set_text (GTK_ENTRY (entry), initial); + gtk_widget_grab_focus (entry); + gtk_widget_show (entry); + + query_box->entry = entry; + + return query_box->qbox; +} + +GtkWidget * +gimp_query_int_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gint initial, + gint lower, + gint upper, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkAdjustment* adjustment; + GtkWidget *spinbutton; + + query_box = create_query_box (title, help_func, help_data, + int_query_box_ok_callback, + message, object, signal, callback, data); + + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); + spinbutton = gtk_spin_button_new (adjustment, 1.0, 0); + gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_grab_focus (spinbutton); + gtk_widget_show (spinbutton); + + query_box->entry = spinbutton; + + return query_box->qbox; +} + +GtkWidget * +gimp_query_double_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkAdjustment* adjustment; + GtkWidget *spinbutton; + + query_box = create_query_box (title, help_func, help_data, + double_query_box_ok_callback, + message, object, signal, callback, data); + + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); + spinbutton = gtk_spin_button_new (adjustment, 1.0, digits); + gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_grab_focus (spinbutton); + gtk_widget_show (spinbutton); + + query_box->entry = spinbutton; + + return query_box->qbox; +} + +GtkWidget * +gimp_query_size_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GUnit unit, + gdouble resolution, + gboolean dot_for_dot, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkWidget *sizeentry; + + query_box = create_query_box (title, help_func, help_data, + size_query_box_ok_callback, + message, object, signal, callback, data); + + sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, + GIMP_SIZE_ENTRY_UPDATE_SIZE); + if (dot_for_dot) + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, + resolution, FALSE); + gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); + gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0, + lower, upper); + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial); + + gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0); + gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry)); + gtk_widget_show (sizeentry); + + query_box->entry = sizeentry; + + return query_box->qbox; +} + +static void +query_box_cancel_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + + query_box = (QueryBox *) data; + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +string_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gchar *string; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the entry data */ + string = g_strdup (gtk_entry_get_text (GTK_ENTRY (query_box->entry))); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, (gpointer) string); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +int_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gint *integer_value; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the spinbutton data */ + integer_value = g_malloc (sizeof (gint)); + *integer_value = + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry)); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, + (gpointer) integer_value); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +double_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gdouble *double_value; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the spinbutton data */ + double_value = g_malloc (sizeof (gdouble)); + *double_value = + gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (query_box->entry)); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, + (gpointer) double_value); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +size_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gdouble *double_value; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the sizeentry data */ + double_value = g_malloc (sizeof (gdouble)); + *double_value = + gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0); + + /* Pass the selected unit to the callback */ + gtk_object_set_data + (GTK_OBJECT (widget), "size_query_unit", + (gpointer) gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry))); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, + (gpointer) double_value); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + + +/* + * Message Boxes... + */ + +typedef struct _MessageBox MessageBox; + +struct _MessageBox +{ + GtkWidget *mbox; + GtkCallback callback; + gpointer data; +}; + +static void gimp_message_box_close_callback (GtkWidget *, gpointer); + +GtkWidget * +gimp_message_box (gchar *message, + GtkCallback callback, + gpointer data) +{ + MessageBox *msg_box; + GtkWidget *mbox; + GtkWidget *vbox; + GtkWidget *label; + + if (! message) + return NULL; + + msg_box = g_new (MessageBox, 1); + + mbox = gimp_dialog_new (_("GIMP Message"), "gimp_message", + NULL, NULL, + GTK_WIN_POS_MOUSE, + FALSE, FALSE, FALSE, + + _("OK"), gimp_message_box_close_callback, + msg_box, NULL, TRUE, TRUE, + + NULL); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (mbox)->vbox), vbox); + gtk_widget_show (vbox); + + label = gtk_label_new (message); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); + gtk_widget_show (label); + + msg_box->mbox = mbox; + msg_box->callback = callback; + msg_box->data = data; + + gtk_widget_show (mbox); + + return mbox; +} + +static void +gimp_message_box_close_callback (GtkWidget *widget, + gpointer data) +{ + MessageBox *msg_box; + + msg_box = (MessageBox *) data; + + /* If there is a valid callback, invoke it */ + if (msg_box->callback) + (* msg_box->callback) (widget, msg_box->data); + + /* Destroy the box */ + gtk_widget_destroy (msg_box->mbox); + + g_free (msg_box); +} + + +/* + * Helper Functions... + */ + +/* add aligned label & widget to a two-column table */ +void +gimp_table_attach_aligned (GtkTable *table, + gint row, + gchar *text, + gfloat xalign, + gfloat yalign, + GtkWidget *widget, + gboolean left_adjust) +{ + GtkWidget *label; + + label = gtk_label_new (text); + gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); + gtk_table_attach (table, GTK_WIDGET (label), 0, 1, row, row + 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (label); + + if (left_adjust) + { + GtkWidget *alignment; + + alignment = gtk_alignment_new (0.0, 1.0, 0.0, 0.0); + gtk_table_attach_defaults (table, alignment, 1, 2, row, row + 1); + gtk_widget_show (alignment); + gtk_container_add (GTK_CONTAINER (alignment), widget); + } + else + { + gtk_table_attach_defaults (table, widget, 1, 2, row, row + 1); + } + + gtk_widget_show (widget); +} diff --git a/app/gimpui.h b/app/gimpui.h new file mode 100644 index 0000000000..781fde1448 --- /dev/null +++ b/app/gimpui.h @@ -0,0 +1,175 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpui.h + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMP_UI_H__ +#define __GIMP_UI_H__ + +#include + +#include "gimphelp.h" + +#include "libgimp/gimpunit.h" + +/* typedefs */ +typedef void (* GimpQueryFunc) (GtkWidget *, gpointer, gpointer); + + +/* widget constructors */ + +GtkWidget * gimp_dialog_new (const gchar *title, + const gchar *wmclass_name, + GimpHelpFunc help_func, + gpointer 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, + gpointer help_data, + GtkWindowPosition position, + gint allow_shrink, + gint allow_grow, + gint auto_shrink, + va_list args); + +GtkWidget * gimp_option_menu_new (GtkSignalFunc menu_item_callback, + gpointer initial, /* user_data */ + + /* specify menu items as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...); + +GtkWidget * gimp_radio_group_new (GtkSignalFunc radio_button_callback, + gpointer initial, /* user_data */ + + /* specify radio buttons as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...); + +GtkWidget * gimp_spin_button_new (/* return value: */ + GtkObject **adjustment, + + gfloat value, + gfloat lower, + gfloat upper, + gfloat step_increment, + gfloat page_increment, + gfloat page_size, + gfloat climb_rate, + guint digits); + +/* some simple query dialogs + * if object != NULL then the query boxes will connect their cancel callback + * to the provided signal of this object + * + * it's the caller's job to show the returned widgets + */ + +GtkWidget * gimp_query_string_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gchar *initial, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +GtkWidget * gimp_query_int_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + char *message, + gint initial, + gint lower, + gint upper, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +GtkWidget * gimp_query_double_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +GtkWidget * gimp_query_size_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GUnit unit, + gdouble resolution, + gboolean dot_for_dot, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +/* a simple message box */ + +GtkWidget * gimp_message_box (gchar *message, + GtkCallback callback, + gpointer data); + +/* helper functions */ + +/* add aligned label & widget to a two-column table */ +void gimp_table_attach_aligned (GtkTable *table, + gint row, + gchar *text, + gfloat xalign, + gfloat yalign, + GtkWidget *widget, + gboolean left_adjust); + +#endif /* __GIMP_UI_H__ */ diff --git a/app/global_edit.c b/app/global_edit.c index 3c521ef96c..2aa1d78983 100644 --- a/app/global_edit.c +++ b/app/global_edit.c @@ -24,8 +24,8 @@ #include "gdisplay.h" #include "gimage.h" #include "gimage_mask.h" +#include "gimpui.h" #include "global_edit.h" -#include "interface.h" #include "layer.h" #include "paint_funcs.h" #include "tools.h" @@ -666,12 +666,12 @@ named_buffer_delete_callback (GtkWidget *w, } static void -named_buffer_cancel_callback (GtkWidget *w, - gpointer client_data) +named_buffer_cancel_callback (GtkWidget *widget, + gpointer data) { PasteNamedDlg *pn_dlg; - pn_dlg = (PasteNamedDlg *) client_data; + pn_dlg = (PasteNamedDlg *) data; /* Destroy the box */ gtk_widget_destroy (pn_dlg->shell); @@ -679,16 +679,6 @@ named_buffer_cancel_callback (GtkWidget *w, g_free (pn_dlg); } -static gint -named_buffer_dialog_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - named_buffer_cancel_callback (w, client_data); - - return TRUE; -} - static void paste_named_buffer (GDisplay *gdisp) { @@ -706,27 +696,27 @@ paste_named_buffer (GDisplay *gdisp) { N_("Paste Into"), named_buffer_paste_into_callback, NULL, NULL }, { N_("Paste As New"), named_buffer_paste_as_new_callback, NULL, NULL } }; - static ActionAreaItem other_action_items[] = - { - { N_("Delete"), named_buffer_delete_callback, NULL, NULL }, - { N_("Cancel"), named_buffer_cancel_callback, NULL, NULL } - }; - pn_dlg = (PasteNamedDlg *) g_malloc (sizeof (PasteNamedDlg)); + pn_dlg = g_new (PasteNamedDlg, 1); pn_dlg->gdisp = gdisp; - - pn_dlg->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (pn_dlg->shell), "paste_named_buffer", "Gimp"); - gtk_window_set_title (GTK_WINDOW (pn_dlg->shell), _("Paste Named Buffer")); - gtk_window_position (GTK_WINDOW (pn_dlg->shell), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (pn_dlg->shell), "delete_event", - GTK_SIGNAL_FUNC (named_buffer_dialog_delete_callback), - pn_dlg); + pn_dlg->shell = + gimp_dialog_new (_("Paste Named Buffer"), "paste_named_buffer", + gimp_standard_help_func, + "dialogs/paste_named_buffer_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, + _("Delete"), named_buffer_delete_callback, + pn_dlg, NULL, FALSE, FALSE, + _("Cancel"), named_buffer_cancel_callback, + pn_dlg, NULL, TRUE, TRUE, + + NULL); + vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pn_dlg->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pn_dlg->shell)->vbox), vbox); gtk_widget_show (vbox); label = gtk_label_new (_("Select a buffer to paste:")); @@ -763,10 +753,6 @@ paste_named_buffer (GDisplay *gdisp) } gtk_widget_show (bbox); - other_action_items[0].user_data = pn_dlg; - other_action_items[1].user_data = pn_dlg; - build_action_area (GTK_DIALOG (pn_dlg->shell), other_action_items, 2, 1); - gtk_widget_show (pn_dlg->shell); } @@ -791,7 +777,7 @@ new_named_buffer (TileManager *tiles, } static void -cut_named_buffer_callback (GtkWidget *w, +cut_named_buffer_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { @@ -811,22 +797,27 @@ cut_named_buffer_callback (GtkWidget *w, int named_edit_cut (void *gdisp_ptr) { - GDisplay *gdisp; + GtkWidget *qbox; + GDisplay *gdisp; /* stop any active tool */ gdisp = (GDisplay *) gdisp_ptr; active_tool_control (HALT, gdisp_ptr); - gtk_widget_show (query_string_box (_("Cut Named"), - _("Enter a name for this buffer"), - NULL, - GTK_OBJECT (gdisp->gimage), "destroy", - cut_named_buffer_callback, gdisp)); + qbox = gimp_query_string_box (_("Cut Named"), + gimp_standard_help_func, + "dialogs/cut_named_dialog.html", + _("Enter a name for this buffer"), + NULL, + GTK_OBJECT (gdisp->gimage), "destroy", + cut_named_buffer_callback, gdisp); + gtk_widget_show (qbox); + return TRUE; } static void -copy_named_buffer_callback (GtkWidget *w, +copy_named_buffer_callback (GtkWidget *widget, gpointer client_data, gpointer call_data) { @@ -845,15 +836,20 @@ copy_named_buffer_callback (GtkWidget *w, int named_edit_copy (void *gdisp_ptr) { - GDisplay *gdisp; + GtkWidget *qbox; + GDisplay *gdisp; gdisp = (GDisplay *) gdisp_ptr; - - gtk_widget_show (query_string_box (_("Copy Named"), - _("Enter a name for this buffer"), - NULL, - GTK_OBJECT (gdisp->gimage), "destroy", - copy_named_buffer_callback, gdisp)); + + qbox = gimp_query_string_box (_("Copy Named"), + gimp_standard_help_func, + "dialogs/copy_named_dialog.html", + _("Enter a name for this buffer"), + NULL, + GTK_OBJECT (gdisp->gimage), "destroy", + copy_named_buffer_callback, gdisp); + gtk_widget_show (qbox); + return TRUE; } diff --git a/app/gradient.c b/app/gradient.c index c5c8a84b84..0274f668a0 100644 --- a/app/gradient.c +++ b/app/gradient.c @@ -150,7 +150,6 @@ #include #endif -#include "actionarea.h" #include "appenv.h" #include "colormaps.h" #include "cursorutil.h" @@ -158,8 +157,8 @@ #include "errors.h" #include "general.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "session.h" #include "gradient_header.h" @@ -209,8 +208,6 @@ static void ed_do_copy_gradient_callback (GtkWidget *, gpointer , gpointer); static void ed_delete_gradient_callback (GtkWidget *, gpointer); static void ed_do_delete_gradient_callback (GtkWidget *, gpointer); static void ed_cancel_delete_gradient_callback (GtkWidget *, gpointer); -static gint ed_delete_delete_gradient_callback (GtkWidget *, GdkEvent *, - gpointer); static void ed_rename_gradient_callback (GtkWidget *, gpointer); static void ed_do_rename_gradient_callback (GtkWidget *, gpointer, gpointer); @@ -222,8 +219,6 @@ static gint ed_delete_save_pov_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_save_grads_callback (GtkWidget *, gpointer); static void ed_refresh_grads_callback (GtkWidget *, gpointer); - -static gint ed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_close_callback (GtkWidget *, gpointer); /* Zoom, scrollbar & instant update callbacks */ @@ -248,27 +243,29 @@ static void prev_fill_image (int width, int height, /* Gradient control functions */ -static gint control_events (GtkWidget *, GdkEvent *, gpointer); -static void control_do_hint (gint x, gint y); -static void control_button_press (gint x, gint y, - guint button, guint state); -static int control_point_in_handle (gint x, gint y, grad_segment_t *seg, - control_drag_mode_t handle); -static void control_select_single_segment (grad_segment_t *seg); -static void control_extend_selection (grad_segment_t *seg, double pos); -static void control_motion (gint x); +static gint control_events (GtkWidget *, GdkEvent *, + gpointer); +static void control_do_hint (gint x, gint y); +static void control_button_press (gint x, gint y, + guint button, guint state); +static gboolean control_point_in_handle (gint x, gint y, + grad_segment_t *seg, + control_drag_mode_t handle); +static void control_select_single_segment (grad_segment_t *seg); +static void control_extend_selection (grad_segment_t *seg, double pos); +static void control_motion (gint x); -static void control_compress_left (grad_segment_t *range_l, - grad_segment_t *range_r, - grad_segment_t *drag_seg, +static void control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, double pos); -static void control_compress_range (grad_segment_t *range_l, - grad_segment_t *range_r, - double new_l, double new_r); +static void control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, double new_r); -static double control_move (grad_segment_t *range_l, - grad_segment_t *range_r, - double delta); +static double control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta); /* Control update/redraw functions */ @@ -379,8 +376,6 @@ static void cpopup_split_uniform_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_scale_update (GtkAdjustment *, gpointer); static void cpopup_split_uniform_split_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_split_uniform_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_split_uniform (grad_segment_t *lseg, int parts, grad_segment_t **newl, grad_segment_t **newr); @@ -398,8 +393,6 @@ static void cpopup_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_scale_update (GtkAdjustment *, gpointer); static void cpopup_do_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_replicate_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_blend_colors (GtkWidget *, gpointer); static void cpopup_blend_opacity (GtkWidget *, gpointer); @@ -668,13 +661,6 @@ grad_create_gradient_editor_init (gint need_show) gint i; gint select_pos; - static ActionAreaItem action_items[] = - { - { N_("Save"), ed_save_grads_callback, NULL, NULL }, - { N_("Refresh"), ed_refresh_grads_callback, NULL, NULL }, - { N_("Close"), ed_close_callback, NULL, NULL } - }; - /* If the editor already exists, just show it */ if (g_editor) { @@ -698,15 +684,20 @@ grad_create_gradient_editor_init (gint need_show) g_editor = g_new (gradient_editor_t, 1); /* Shell and main vbox */ - g_editor->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_editor", "Gimp"); - gtk_window_set_title (GTK_WINDOW (g_editor->shell), _("Gradient Editor")); + g_editor->shell = gimp_dialog_new (_("Gradient Editor"), "gradient_editor", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_callback), - NULL); + _("Save"), ed_save_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Refresh"), ed_refresh_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Close"), ed_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -881,7 +872,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (gvbox); /* Gradient preview */ - g_editor->preview_rows[0] = NULL; g_editor->preview_rows[1] = NULL; g_editor->preview_last_x = 0; @@ -905,7 +895,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (g_editor->preview); /* Gradient control */ - g_editor->control_pixmap = NULL; g_editor->control_drag_segment = NULL; g_editor->control_sel_l = NULL; @@ -967,9 +956,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_box_pack_start (GTK_BOX (vbox), g_editor->hint_label, FALSE, FALSE, 0); gtk_widget_show (g_editor->hint_label); - /* The action area */ - build_action_area (GTK_DIALOG (g_editor->shell), action_items, 3, 2); - /* Initialize other data */ g_editor->left_color_preview = NULL; g_editor->left_saved_segments = NULL; @@ -995,11 +981,8 @@ grad_create_gradient_editor_init (gint need_show) gtk_clist_moveto (GTK_CLIST (g_editor->clist), select_pos, 0, 0.0, 0.0); } - /***** Gradient editor functions *****/ -/*****/ - static void ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) { @@ -1319,17 +1302,20 @@ ed_initialize_saved_colors(void) /***** the "new gradient" dialog functions *****/ -/*****/ - static void ed_new_gradient_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box(_("New gradient"), - _("Enter a name for the new gradient"), - _("untitled"), - NULL, NULL, - ed_do_new_gradient_callback, NULL)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the new gradient"), + _("untitled"), + NULL, NULL, + ed_do_new_gradient_callback, NULL); + gtk_widget_show (qbox); } static void @@ -1373,12 +1359,11 @@ ed_do_new_gradient_callback (GtkWidget *widget, /***** The "copy gradient" dialog functions *****/ -/*****/ - static void ed_copy_gradient_callback (GtkWidget *widget, gpointer data) { + GtkWidget *qbox; gchar *name; if (curr_gradient == NULL) @@ -1386,13 +1371,16 @@ ed_copy_gradient_callback (GtkWidget *widget, name = g_strdup_printf (_("%s copy"), curr_gradient->name); - gtk_widget_show (query_string_box (_("Copy gradient"), - _("Enter a name for the copied gradient"), - name, - NULL, NULL, - ed_do_copy_gradient_callback, NULL)); + qbox = gimp_query_string_box (_("Copy gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the copied gradient"), + name, + NULL, NULL, + ed_do_copy_gradient_callback, NULL); + gtk_widget_show (qbox); - g_free(name); + g_free (name); } static void @@ -1460,21 +1448,24 @@ ed_do_copy_gradient_callback (GtkWidget *widget, /***** The "rename gradient" dialog functions *****/ -/*****/ - static void ed_rename_gradient_callback (GtkWidget *widget, - gpointer data) + gpointer data) { + GtkWidget *qbox; + if (curr_gradient == NULL) return; - gtk_widget_show (query_string_box (_("Rename gradient"), - _("Enter a new name for the gradient"), - curr_gradient->name, - NULL, NULL, - ed_do_rename_gradient_callback, - curr_gradient)); + qbox = gimp_query_string_box (_("Rename gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a new name for the gradient"), + curr_gradient->name, + NULL, NULL, + ed_do_rename_gradient_callback, + curr_gradient); + gtk_widget_show (qbox); } static void @@ -1536,8 +1527,6 @@ ed_do_rename_gradient_callback (GtkWidget *widget, /***** The "delete gradient" dialog functions *****/ -/*****/ - static void ed_delete_gradient_callback (GtkWidget *widget, gpointer data) @@ -1547,24 +1536,21 @@ ed_delete_gradient_callback (GtkWidget *widget, GtkWidget *label; gchar *str; - static ActionAreaItem action_items[] = - { - { N_("Delete"), ed_do_delete_gradient_callback, NULL, NULL }, - { N_("Cancel"), ed_cancel_delete_gradient_callback, NULL, NULL } - }; - if (num_gradients <= 1) return; - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "delete_gradient", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Delete gradient")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = gimp_dialog_new (_("Delete gradient"), "delete_gradient", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_delete_gradient_callback), - dialog); + _("Delete"), ed_do_delete_gradient_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), ed_cancel_delete_gradient_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -1572,9 +1558,9 @@ ed_delete_gradient_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); gtk_widget_show (vbox); - str = g_strdup_printf(_("Are you sure you want to delete\n" - "\"%s\" from the list and from disk?"), - curr_gradient->name); + str = g_strdup_printf (_("Are you sure you want to delete\n" + "\"%s\" from the list and from disk?"), + curr_gradient->name); label = gtk_label_new (str); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); @@ -1582,11 +1568,6 @@ ed_delete_gradient_callback (GtkWidget *widget, g_free (str); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1658,20 +1639,8 @@ ed_cancel_delete_gradient_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -ed_delete_delete_gradient_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_cancel_delete_gradient_callback (widget, data); - - return TRUE; -} - /***** The "save as pov" dialog functions *****/ -/*****/ - static void ed_save_pov_callback (GtkWidget *widget, gpointer data) @@ -1682,7 +1651,7 @@ ed_save_pov_callback (GtkWidget *widget, return; window = gtk_file_selection_new (_("Save as POV-Ray")); - gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); + gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button), "clicked", (GtkSignalFunc) ed_do_save_pov_callback, @@ -1696,6 +1665,10 @@ ed_save_pov_callback (GtkWidget *widget, (GdkEventFunc) ed_delete_save_pov_callback, window); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html"); + gtk_widget_show (window); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1771,8 +1744,6 @@ ed_delete_save_pov_callback (GtkWidget *widget, /***** The main dialog action area button callbacks *****/ -/*****/ - static void ed_save_grads_callback (GtkWidget *widget, gpointer data) @@ -1815,20 +1786,8 @@ ed_close_callback (GtkWidget *widget, gtk_widget_hide (g_editor->shell); } -static gint -ed_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_close_callback (widget, data); - - return TRUE; -} - /***** Zoom, scrollbar & instant update callbacks *****/ -/*****/ - static void ed_scrollbar_update (GtkAdjustment *adjustment, gpointer data) @@ -1942,8 +1901,6 @@ ed_instant_update_update (GtkWidget *widget, /***** Gradient preview functions *****/ -/*****/ - static gint prev_events (GtkWidget *widget, GdkEvent *event, @@ -2103,7 +2060,7 @@ prev_set_foreground (gint x) palette_set_foreground (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Foreground color set to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2126,7 +2083,7 @@ prev_set_background (gint x) palette_set_background (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Background color to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2229,54 +2186,58 @@ prev_update (gboolean recalculate) /*****/ static void -prev_fill_image(int width, int height, double left, double right) +prev_fill_image (int width, + int height, + double left, + double right) { - guchar *p0, *p1; - int x, y; - double dx, cur_x; - double r, g, b, a; - double c0, c1; + guchar *p0, *p1; + int x, y; + double dx, cur_x; + double r, g, b, a; + double c0, c1; - dx = (right - left) / (width - 1); - cur_x = left; - p0 = g_editor->preview_rows[0]; - p1 = g_editor->preview_rows[1]; + dx = (right - left) / (width - 1); + cur_x = left; + p0 = g_editor->preview_rows[0]; + p1 = g_editor->preview_rows[1]; - /* Create lines to fill the image */ + /* Create lines to fill the image */ + for (x = 0; x < width; x++) + { + grad_get_color_at (cur_x, &r, &g, &b, &a); - for (x = 0; x < width; x++) { - grad_get_color_at(cur_x, &r, &g, &b, &a); + if ((x / GRAD_CHECK_SIZE) & 1) + { + c0 = GRAD_CHECK_LIGHT; + c1 = GRAD_CHECK_DARK; + } + else + { + c0 = GRAD_CHECK_DARK; + c1 = GRAD_CHECK_LIGHT; + } - if ((x / GRAD_CHECK_SIZE) & 1) { - c0 = GRAD_CHECK_LIGHT; - c1 = GRAD_CHECK_DARK; - } else { - c0 = GRAD_CHECK_DARK; - c1 = GRAD_CHECK_LIGHT; - } /* else */ + *p0++ = (c0 + (r - c0) * a) * 255.0; + *p0++ = (c0 + (g - c0) * a) * 255.0; + *p0++ = (c0 + (b - c0) * a) * 255.0; - *p0++ = (c0 + (r - c0) * a) * 255.0; - *p0++ = (c0 + (g - c0) * a) * 255.0; - *p0++ = (c0 + (b - c0) * a) * 255.0; + *p1++ = (c1 + (r - c1) * a) * 255.0; + *p1++ = (c1 + (g - c1) * a) * 255.0; + *p1++ = (c1 + (b - c1) * a) * 255.0; - *p1++ = (c1 + (r - c1) * a) * 255.0; - *p1++ = (c1 + (g - c1) * a) * 255.0; - *p1++ = (c1 + (b - c1) * a) * 255.0; - - cur_x += dx; - } /* for */ - - /* Fill image */ - - for (y = 0; y < height; y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[1], 0, y, width); - else - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[0], 0, y, width); -} /* prev_fill_image */ + cur_x += dx; + } + /* Fill image */ + for (y = 0; y < height; y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[1], 0, y, width); + else + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[0], 0, y, width); +} /***** Gradient control functions *****/ @@ -2288,8 +2249,6 @@ prev_fill_image(int width, int height, double left, double right) * them yourself ;-) */ -/*****/ - static gint control_events (GtkWidget *widget, GdkEvent *event, @@ -2395,51 +2354,56 @@ control_events (GtkWidget *widget, /*****/ static void -control_do_hint(gint x, gint y) +control_do_hint (gint x, + gint y) { - grad_segment_t *seg; - control_drag_mode_t handle; - int in_handle; - double pos; + grad_segment_t *seg; + control_drag_mode_t handle; + gboolean in_handle; + double pos; - pos = control_calc_g_pos(x); + pos = control_calc_g_pos (x); - if ((pos < 0.0) || (pos > 1.0)) - return; + if ((pos < 0.0) || (pos > 1.0)) + return; - seg_get_closest_handle(curr_gradient, pos, &seg, &handle); + seg_get_closest_handle (curr_gradient, pos, &seg, &handle); - in_handle = control_point_in_handle(x, y, seg, handle); + in_handle = control_point_in_handle (x, y, seg, handle); - if (in_handle) { - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg != NULL) { - if (seg->prev != NULL) - ed_set_hint(_("Drag: move Shift+drag: move & compress")); - else - ed_set_hint(_("Click: select Shift+click: extend selection")); - } else - ed_set_hint(_("Click: select Shift+click: extend selection")); + if (in_handle) + { + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg != NULL) + { + if (seg->prev != NULL) + ed_set_hint (_("Drag: move Shift+drag: move & compress")); + else + ed_set_hint (_("Click: select Shift+click: extend selection")); + } + else + ed_set_hint (_("Click: select Shift+click: extend selection")); - break; + break; - case GRAD_DRAG_MIDDLE: - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move")); + case GRAD_DRAG_MIDDLE: + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move")); - break; - - default: - g_message ("control_do_hint: oops, in_handle is true " - "yet we got handle type %d", (int) handle); - break; - } /* switch */ - } else - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move Shift+drag: move & compress")); -} /* control_do_hint */ + break; + default: + g_message ("control_do_hint: oops, in_handle is true " + "yet we got handle type %d", (int) handle); + break; + } + } + else + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move Shift+drag: move & compress")); +} /*****/ @@ -2452,7 +2416,7 @@ control_button_press (gint x, grad_segment_t *seg; control_drag_mode_t handle; double xpos; - gint in_handle; + gboolean in_handle; /* See which button was pressed */ @@ -2592,343 +2556,370 @@ control_button_press (gint x, /*****/ -static int -control_point_in_handle(gint x, gint y, grad_segment_t *seg, control_drag_mode_t handle) +static gboolean +control_point_in_handle (gint x, + gint y, + grad_segment_t *seg, + control_drag_mode_t handle) { - gint handle_pos; + gint handle_pos; - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - handle_pos = control_calc_p_pos(seg->left); - else { - seg = seg_get_last_segment(curr_gradient->segments); + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + handle_pos = control_calc_p_pos (seg->left); + else + { + seg = seg_get_last_segment (curr_gradient->segments); - handle_pos = control_calc_p_pos(seg->right); - } /* else */ + handle_pos = control_calc_p_pos (seg->right); + } - break; + break; - case GRAD_DRAG_MIDDLE: - handle_pos = control_calc_p_pos(seg->middle); - break; + case GRAD_DRAG_MIDDLE: + handle_pos = control_calc_p_pos (seg->middle); + break; - default: - g_message ("control_point_in_handle(): oops, can not handle drag mode %d", - (int) handle); - return 0; - } /* switch */ + default: + g_message ("control_point_in_handle(): oops, can not handle drag mode %d", + (int) handle); + return FALSE; + } - y /= 2; - - if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) - return 1; - else - return 0; -} /* control_point_in_handle */ + y /= 2; + if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) + return TRUE; + else + return FALSE; +} /*****/ static void -control_select_single_segment(grad_segment_t *seg) +control_select_single_segment (grad_segment_t *seg) { - g_editor->control_sel_l = seg; - g_editor->control_sel_r = seg; -} /* control_select_single_segment */ - + g_editor->control_sel_l = seg; + g_editor->control_sel_r = seg; +} /*****/ static void -control_extend_selection(grad_segment_t *seg, double pos) +control_extend_selection (grad_segment_t *seg, + double pos) { - if (fabs(pos - g_editor->control_sel_l->left) < fabs(pos - g_editor->control_sel_r->right)) - g_editor->control_sel_l = seg; - else - g_editor->control_sel_r = seg; -} /* control_extend_selection */ - + if (fabs (pos - g_editor->control_sel_l->left) < + fabs(pos - g_editor->control_sel_r->right)) + g_editor->control_sel_l = seg; + else + g_editor->control_sel_r = seg; +} /*****/ static void -control_motion(gint x) +control_motion (gint x) { - grad_segment_t *seg; - double pos; - double delta; - char str[256]; + grad_segment_t *seg; + double pos; + double delta; + char str[256]; - seg = g_editor->control_drag_segment; + seg = g_editor->control_drag_segment; - switch (g_editor->control_drag_mode) { - case GRAD_DRAG_LEFT: - pos = control_calc_g_pos(x); + switch (g_editor->control_drag_mode) + { + case GRAD_DRAG_LEFT: + pos = control_calc_g_pos (x); - if (!g_editor->control_compress) - seg->prev->right = seg->left = BOUNDS(pos, - seg->prev->middle + EPSILON, - seg->middle - EPSILON); - else - control_compress_left(g_editor->control_sel_l, - g_editor->control_sel_r, - seg, pos); + if (!g_editor->control_compress) + seg->prev->right = seg->left = BOUNDS (pos, + seg->prev->middle + EPSILON, + seg->middle - EPSILON); + else + control_compress_left (g_editor->control_sel_l, + g_editor->control_sel_r, + seg, pos); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->left); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->left); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_MIDDLE: - pos = control_calc_g_pos(x); - seg->middle = BOUNDS(pos, seg->left + EPSILON, seg->right - EPSILON); + case GRAD_DRAG_MIDDLE: + pos = control_calc_g_pos (x); + seg->middle = BOUNDS (pos, seg->left + EPSILON, seg->right - EPSILON); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->middle); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->middle); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_ALL: - pos = control_calc_g_pos(x); - delta = pos - g_editor->control_last_gx; + case GRAD_DRAG_ALL: + pos = control_calc_g_pos (x); + delta = pos - g_editor->control_last_gx; - if ((seg->left >= g_editor->control_sel_l->left) && - (seg->right <= g_editor->control_sel_r->right)) - delta = control_move(g_editor->control_sel_l, g_editor->control_sel_r, delta); - else - delta = control_move(seg, seg, delta); + if ((seg->left >= g_editor->control_sel_l->left) && + (seg->right <= g_editor->control_sel_r->right)) + delta = control_move (g_editor->control_sel_l, + g_editor->control_sel_r, delta); + else + delta = control_move (seg, seg, delta); - g_editor->control_last_gx += delta; + g_editor->control_last_gx += delta; - g_snprintf(str, sizeof(str), _("Distance: %0.6f"), - g_editor->control_last_gx - g_editor->control_orig_pos); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Distance: %0.6f"), + g_editor->control_last_gx - g_editor->control_orig_pos); + ed_set_hint (str); - break; + break; - default: - gimp_fatal_error(_("control_motion(): Attempt to move bogus handle %d"), - (int) g_editor->control_drag_mode); - break; - } /* switch */ + default: + gimp_fatal_error (_("control_motion(): Attempt to move bogus handle %d"), + (int) g_editor->control_drag_mode); + break; + } - curr_gradient->dirty = 1; - - if (g_editor->instant_update) - ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); - else - ed_update_editor(GRAD_UPDATE_CONTROL); -} /* control_motion */ + curr_gradient->dirty = 1; + if (g_editor->instant_update) + ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); + else + ed_update_editor (GRAD_UPDATE_CONTROL); +} /*****/ static void -control_compress_left(grad_segment_t *range_l, grad_segment_t *range_r, - grad_segment_t *drag_seg, double pos) +control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, + double pos) { - grad_segment_t *seg; - double lbound, rbound; - int k; + grad_segment_t *seg; + double lbound, rbound; + int k; - /* Check what we have to compress */ + /* Check what we have to compress */ - if (!((drag_seg->left >= range_l->left) && - ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) { - /* We are compressing a segment outside the selection */ + if (!((drag_seg->left >= range_l->left) && + ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) + { + /* We are compressing a segment outside the selection */ - range_l = range_r = drag_seg; - } /* else */ + range_l = range_r = drag_seg; + } - /* Calculate left bound for dragged hadle */ + /* Calculate left bound for dragged hadle */ - if (drag_seg == range_l) - lbound = range_l->prev->left + 2.0 * EPSILON; - else { - /* Count number of segments to the left of the dragged handle */ + if (drag_seg == range_l) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + { + /* Count number of segments to the left of the dragged handle */ - seg = drag_seg; - k = 0; + seg = drag_seg; + k = 0; - while (seg != range_l) { - k++; - seg = seg->prev; - } /* while */ + while (seg != range_l) + { + k++; + seg = seg->prev; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - lbound = range_l->left + 2.0 * k * EPSILON; - } /* else */ + lbound = range_l->left + 2.0 * k * EPSILON; + } - /* Calculate right bound for dragged handle */ + /* Calculate right bound for dragged handle */ - if (drag_seg == range_r->next) - rbound = range_r->next->right - 2.0 * EPSILON; - else { - /* Count number of segments to the right of the dragged handle */ + if (drag_seg == range_r->next) + rbound = range_r->next->right - 2.0 * EPSILON; + else + { + /* Count number of segments to the right of the dragged handle */ - seg = drag_seg; - k = 1; + seg = drag_seg; + k = 1; - while (seg != range_r) { - k++; - seg = seg->next; - } /* while */ + while (seg != range_r) + { + k++; + seg = seg->next; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - rbound = range_r->right - 2.0 * k * EPSILON; - } /* else */ + rbound = range_r->right - 2.0 * k * EPSILON; + } - /* Calculate position */ + /* Calculate position */ - pos = BOUNDS(pos, lbound, rbound); + pos = BOUNDS (pos, lbound, rbound); - /* Compress segments to the left of the handle */ + /* Compress segments to the left of the handle */ - if (drag_seg == range_l) - control_compress_range(range_l->prev, range_l->prev, range_l->prev->left, pos); - else - control_compress_range(range_l, drag_seg->prev, range_l->left, pos); + if (drag_seg == range_l) + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, pos); + else + control_compress_range (range_l, drag_seg->prev, range_l->left, pos); - /* Compress segments to the right of the handle */ - - if (drag_seg != range_r->next) - control_compress_range(drag_seg, range_r, pos, range_r->right); - else - control_compress_range(drag_seg, drag_seg, pos, drag_seg->right); -} /* control_compress_left */ + /* Compress segments to the right of the handle */ + if (drag_seg != range_r->next) + control_compress_range (drag_seg, range_r, pos, range_r->right); + else + control_compress_range (drag_seg, drag_seg, pos, drag_seg->right); +} /*****/ static void -control_compress_range(grad_segment_t *range_l, grad_segment_t *range_r, - double new_l, double new_r) +control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, + double new_r) { - double orig_l, orig_r; - double scale; - grad_segment_t *seg, *aseg; + double orig_l, orig_r; + double scale; + grad_segment_t *seg, *aseg; - orig_l = range_l->left; - orig_r = range_r->right; + orig_l = range_l->left; + orig_r = range_r->right; - scale = (new_r - new_l) / (orig_r - orig_l); + scale = (new_r - new_l) / (orig_r - orig_l); - seg = range_l; + seg = range_l; - do { - seg->left = new_l + (seg->left - orig_l) * scale; - seg->middle = new_l + (seg->middle - orig_l) * scale; - seg->right = new_l + (seg->right - orig_l) * scale; + do + { + seg->left = new_l + (seg->left - orig_l) * scale; + seg->middle = new_l + (seg->middle - orig_l) * scale; + seg->right = new_l + (seg->right - orig_l) * scale; - /* Next */ - - aseg = seg; - seg = seg->next; - } while (aseg != range_r); -} /* control_compress_range */ + /* Next */ + aseg = seg; + seg = seg->next; + } while (aseg != range_r); +} /*****/ static double -control_move(grad_segment_t *range_l, grad_segment_t *range_r, double delta) +control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta) { - double lbound, rbound; - int is_first, is_last; - grad_segment_t *seg, *aseg; + double lbound, rbound; + int is_first, is_last; + grad_segment_t *seg, *aseg; - /* First or last segments in gradient? */ + /* First or last segments in gradient? */ - is_first = (range_l->prev == NULL); - is_last = (range_r->next == NULL); + is_first = (range_l->prev == NULL); + is_last = (range_r->next == NULL); - /* Calculate drag bounds */ + /* Calculate drag bounds */ - if (!g_editor->control_compress) { - if (!is_first) - lbound = range_l->prev->middle + EPSILON; - else - lbound = range_l->left + EPSILON; + if (!g_editor->control_compress) + { + if (!is_first) + lbound = range_l->prev->middle + EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->middle - EPSILON; - else - rbound = range_r->right - EPSILON; - } else { - if (!is_first) - lbound = range_l->prev->left + 2.0 * EPSILON; - else - lbound = range_l->left + EPSILON; + if (!is_last) + rbound = range_r->next->middle - EPSILON; + else + rbound = range_r->right - EPSILON; + } + else + { + if (!is_first) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->right - 2.0 * EPSILON; - else - rbound = range_r->right - EPSILON; - } /* if */ + if (!is_last) + rbound = range_r->next->right - 2.0 * EPSILON; + else + rbound = range_r->right - EPSILON; + } - /* Fix the delta if necessary */ + /* Fix the delta if necessary */ - if (delta < 0.0) { - if (!is_first) { - if (range_l->left + delta < lbound) - delta = lbound - range_l->left; - } else - if (range_l->middle + delta < lbound) - delta = lbound - range_l->middle; - } else { - if (!is_last) { - if (range_r->right + delta > rbound) - delta = rbound - range_r->right; - } else - if (range_r->middle + delta > rbound) - delta = rbound - range_r->middle; - } /* else */ + if (delta < 0.0) + { + if (!is_first) + { + if (range_l->left + delta < lbound) + delta = lbound - range_l->left; + } + else + if (range_l->middle + delta < lbound) + delta = lbound - range_l->middle; + } + else + { + if (!is_last) + { + if (range_r->right + delta > rbound) + delta = rbound - range_r->right; + } + else + if (range_r->middle + delta > rbound) + delta = rbound - range_r->middle; + } - /* Move all the segments inside the range */ + /* Move all the segments inside the range */ - seg = range_l; + seg = range_l; - do { - if (!((seg == range_l) && is_first)) - seg->left += delta; + do + { + if (!((seg == range_l) && is_first)) + seg->left += delta; - seg->middle += delta; + seg->middle += delta; - if (!((seg == range_r) && is_last)) - seg->right += delta; + if (!((seg == range_r) && is_last)) + seg->right += delta; - /* Next */ + /* Next */ - aseg = seg; - seg = seg->next; - } while (aseg != range_r); + aseg = seg; + seg = seg->next; + } + while (aseg != range_r); - /* Fix the segments that surround the range */ + /* Fix the segments that surround the range */ - if (!is_first) - { - if (!g_editor->control_compress) - range_l->prev->right = range_l->left; - else - control_compress_range(range_l->prev, range_l->prev, - range_l->prev->left, range_l->left); - } + if (!is_first) + { + if (!g_editor->control_compress) + range_l->prev->right = range_l->left; + else + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, range_l->left); + } - if (!is_last) - { - if (!g_editor->control_compress) - range_r->next->left = range_r->right; - else - control_compress_range(range_r->next, range_r->next, - range_r->right, range_r->next->right); - } - - return delta; -} /* control_move */ + if (!is_last) + { + if (!g_editor->control_compress) + range_r->next->left = range_r->right; + else + control_compress_range (range_r->next, range_r->next, + range_r->right, range_r->next->right); + } + return delta; +} /*****/ @@ -2990,158 +2981,162 @@ control_update (gboolean recalculate) /*****/ static void -control_draw(GdkPixmap *pixmap, int width, int height, double left, double right) +control_draw (GdkPixmap *pixmap, + int width, + int height, + double left, + double right) { - int sel_l, sel_r; - double g_pos; - grad_segment_t *seg; - control_drag_mode_t handle; + int sel_l, sel_r; + double g_pos; + grad_segment_t *seg; + control_drag_mode_t handle; - /* Clear the pixmap */ + /* Clear the pixmap */ - gdk_draw_rectangle(pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], - TRUE, 0, 0, width, height); + gdk_draw_rectangle (pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], + TRUE, 0, 0, width, height); - /* Draw selection */ + /* Draw selection */ - sel_l = control_calc_p_pos(g_editor->control_sel_l->left); - sel_r = control_calc_p_pos(g_editor->control_sel_r->right); + sel_l = control_calc_p_pos (g_editor->control_sel_l->left); + sel_r = control_calc_p_pos (g_editor->control_sel_r->right); - gdk_draw_rectangle(pixmap, g_editor->control->style->dark_gc[GTK_STATE_NORMAL], - TRUE, sel_l, 0, sel_r - sel_l + 1, height); + gdk_draw_rectangle (pixmap, + g_editor->control->style->dark_gc[GTK_STATE_NORMAL], + TRUE, sel_l, 0, sel_r - sel_l + 1, height); - /* Draw handles */ + /* Draw handles */ - seg = curr_gradient->segments; + seg = curr_gradient->segments; - while (seg) { - control_draw_normal_handle(pixmap, seg->left, height); - control_draw_middle_handle(pixmap, seg->middle, height); + while (seg) + { + control_draw_normal_handle (pixmap, seg->left, height); + control_draw_middle_handle (pixmap, seg->middle, height); - /* Draw right handle only if this is the last segment */ + /* Draw right handle only if this is the last segment */ - if (seg->next == NULL) - control_draw_normal_handle(pixmap, seg->right, height); + if (seg->next == NULL) + control_draw_normal_handle (pixmap, seg->right, height); - /* Next! */ + /* Next! */ - seg = seg->next; - } /* while */ + seg = seg->next; + } - /* Draw the handle which is closest to the mouse position */ + /* Draw the handle which is closest to the mouse position */ - g_pos = control_calc_g_pos(g_editor->control_last_x); + g_pos = control_calc_g_pos (g_editor->control_last_x); - seg_get_closest_handle(curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); + seg_get_closest_handle (curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - control_draw_normal_handle(pixmap, seg->left, height); - else { - seg = seg_get_last_segment(curr_gradient->segments); - control_draw_normal_handle(pixmap, seg->right, height); - } /* else */ + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + control_draw_normal_handle (pixmap, seg->left, height); + else + { + seg = seg_get_last_segment (curr_gradient->segments); + control_draw_normal_handle (pixmap, seg->right, height); + } - break; + break; - case GRAD_DRAG_MIDDLE: - control_draw_middle_handle(pixmap, seg->middle, height); - break; - - default: - break; - } /* switch */ -} /* control_draw */ + case GRAD_DRAG_MIDDLE: + control_draw_middle_handle (pixmap, seg->middle, height); + break; + default: + break; + } +} /*****/ static void -control_draw_normal_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_normal_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->black_gc, - control_calc_p_pos(pos), height); -} /* control_draw_normal_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->black_gc, + control_calc_p_pos (pos), height); +} static void -control_draw_middle_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_middle_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], - control_calc_p_pos(pos), height); -} /* control_draw_middle_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], + control_calc_p_pos(pos), height); +} static void -control_draw_handle(GdkPixmap *pixmap, GdkGC *border_gc, GdkGC *fill_gc, int xpos, int height) +control_draw_handle (GdkPixmap *pixmap, + GdkGC *border_gc, + GdkGC *fill_gc, + int xpos, + int height) { - int y; - int left, right, bottom; + int y; + int left, right, bottom; - for (y = 0; y < height; y++) - gdk_draw_line(pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); + for (y = 0; y < height; y++) + gdk_draw_line (pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); - bottom = height - 1; - left = xpos - bottom / 2; - right = xpos + bottom / 2; - - gdk_draw_line(pixmap, border_gc, xpos, 0, left, bottom); - gdk_draw_line(pixmap, border_gc, xpos, 0, right, bottom); - gdk_draw_line(pixmap, border_gc, left, bottom, right, bottom); -} /* control_draw_handle */ + bottom = height - 1; + left = xpos - bottom / 2; + right = xpos + bottom / 2; + gdk_draw_line (pixmap, border_gc, xpos, 0, left, bottom); + gdk_draw_line (pixmap, border_gc, xpos, 0, right, bottom); + gdk_draw_line (pixmap, border_gc, left, bottom, right, bottom); +} /*****/ static int -control_calc_p_pos(double pos) +control_calc_p_pos (double pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the position (in widget's coordinates) of the - * requested point from the gradient. Rounding is done to - * minimize mismatches between the rendered gradient preview - * and the gradient control's handles. - */ + /* Calculate the position (in widget's coordinates) of the + * requested point from the gradient. Rounding is done to + * minimize mismatches between the rendered gradient preview + * and the gradient control's handles. + */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); -} /* control_calc_p_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); +} /*****/ static double -control_calc_g_pos(int pos) +control_calc_g_pos (int pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the gradient position that corresponds to widget's coordinates */ + /* Calculate the gradient position that corresponds to widget's coordinates */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; -} /* control_calc_g_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; +} /***** Control popup functions *****/ -/*****/ - static void cpopup_create_main_menu (void) { @@ -3350,8 +3345,6 @@ cpopup_do_popup (void) /***** Create a single menu item *****/ -/*****/ - static GtkWidget * cpopup_create_color_item (GtkWidget **color_box, GtkWidget **label) @@ -3416,8 +3409,6 @@ cpopup_create_menu_item_with_label (gchar *str, /***** Update all menus *****/ -/*****/ - static void cpopup_adjust_menus (void) { @@ -3677,79 +3668,87 @@ cpopup_check_selection_params (gint *equal_blending, /*****/ static void -cpopup_render_color_box(GtkPreview *preview, double r, double g, double b, double a) +cpopup_render_color_box (GtkPreview *preview, + double r, + double g, + double b, + double a) { - guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; - int x, y; - int r0, g0, b0; - int r1, g1, b1; - guchar *p0, *p1, *p2; + guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; + int x, y; + int r0, g0, b0; + int r1, g1, b1; + guchar *p0, *p1, *p2; - /* Fill rows */ + /* Fill rows */ - r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; - r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; + r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; + r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; - g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; - g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; + g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; + g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; - b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; - b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; + b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; + b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; - p0 = rows[0]; - p1 = rows[1]; - p2 = rows[2]; + p0 = rows[0]; + p1 = rows[1]; + p2 = rows[2]; - for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) { - if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) { - *p0++ = 0; - *p0++ = 0; - *p0++ = 0; + for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) + { + if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) + { + *p0++ = 0; + *p0++ = 0; + *p0++ = 0; - *p1++ = 0; - *p1++ = 0; - *p1++ = 0; - } else - if ((x / GRAD_CHECK_SIZE) & 1) { - *p0++ = r1; - *p0++ = g1; - *p0++ = b1; + *p1++ = 0; + *p1++ = 0; + *p1++ = 0; + } + else + if ((x / GRAD_CHECK_SIZE) & 1) + { + *p0++ = r1; + *p0++ = g1; + *p0++ = b1; - *p1++ = r0; - *p1++ = g0; - *p1++ = b0; - } else { - *p0++ = r0; - *p0++ = g0; - *p0++ = b0; + *p1++ = r0; + *p1++ = g0; + *p1++ = b0; + } + else + { + *p0++ = r0; + *p0++ = g0; + *p0++ = b0; - *p1++ = r1; - *p1++ = g1; - *p1++ = b1; - } /* else */ + *p1++ = r1; + *p1++ = g1; + *p1++ = b1; + } - *p2++ = 0; - *p2++ = 0; - *p2++ = 0; - } /* for */ + *p2++ = 0; + *p2++ = 0; + *p2++ = 0; + } - /* Fill preview */ + /* Fill preview */ - gtk_preview_draw_row(preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); + gtk_preview_draw_row (preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); - for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); - else - gtk_preview_draw_row(preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); + for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); + else + gtk_preview_draw_row (preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); - gtk_preview_draw_row(preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); -} /* cpopup_render_color_box */ + gtk_preview_draw_row (preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); +} /***** Creale load & save menus *****/ -/*****/ - static GtkWidget * cpopup_create_load_menu (GtkWidget **color_boxes, GtkWidget **labels, @@ -3824,8 +3823,8 @@ cpopup_create_load_menu (GtkWidget **color_boxes, } static GtkWidget * -cpopup_create_save_menu (GtkWidget **color_boxes, - GtkWidget **labels, +cpopup_create_save_menu (GtkWidget **color_boxes, + GtkWidget **labels, GtkSignalFunc callback) { GtkWidget *menu; @@ -3846,324 +3845,328 @@ cpopup_create_save_menu (GtkWidget **color_boxes, return menu; } +/*****/ + +static void +cpopup_update_saved_color (int n, + double r, + double g, + double b, + double a) +{ + char str[256]; + + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_save_color_boxes[n]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_save_color_boxes[n]), + r, g, b, a); + + g_snprintf (str, sizeof (str), + _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + + gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + + g_editor->saved_colors[n].r = r; + g_editor->saved_colors[n].g = g; + g_editor->saved_colors[n].b = b; + g_editor->saved_colors[n].a = a; +} /*****/ static void -cpopup_update_saved_color(int n, double r, double g, double b, double a) +cpopup_load_left_callback (GtkWidget *widget, + gpointer data) { - char str[256]; + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_save_color_boxes[n]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_save_color_boxes[n]), - r, g, b, a); + switch ((long) data) + { + case 0: /* Fetch from left neighbor's right endpoint */ + if (g_editor->control_sel_l->prev != NULL) + seg = g_editor->control_sel_l->prev; + else + seg = seg_get_last_segment (g_editor->control_sel_l); - g_snprintf(str, sizeof(str), _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + cpopup_blend_endpoints (seg->r1, seg->g1, seg->b1, seg->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + case 1: /* Fetch from right endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - g_editor->saved_colors[n].r = r; - g_editor->saved_colors[n].g = g; - g_editor->saved_colors[n].b = b; - g_editor->saved_colors[n].a = a; -} /* cpopup_update_saved_color */ + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (fg_r, + fg_g, + fg_b, + fg_a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_left_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; +} + +static void +cpopup_load_right_callback (GtkWidget *widget, + gpointer data) +{ + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; + + switch ((long) data) + { + case 0: /* Fetch from right neighbor's left endpoint */ + if (g_editor->control_sel_r->next != NULL) + seg = g_editor->control_sel_r->next; + else + seg = curr_gradient->segments; + + cpopup_blend_endpoints (g_editor->control_sel_r->r0, + g_editor->control_sel_r->g0, + g_editor->control_sel_r->b0, + g_editor->control_sel_r->a0, + seg->r0, seg->g0, seg->b0, seg->a0, + TRUE, TRUE); + break; + + case 1: /* Fetch from left endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + TRUE, TRUE); + break; + + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + fg_r, + fg_g, + fg_b, + fg_a, + TRUE, TRUE); + break; + + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_right_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; +} /*****/ static void -cpopup_load_left_callback(GtkWidget *widget, gpointer data) +cpopup_set_color_selection_color (GtkColorSelection *cs, + double r, + double g, + double b, + double a) { - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; + gdouble color[4]; - switch ((long) data) { - case 0: /* Fetch from left neighbor's right endpoint */ - if (g_editor->control_sel_l->prev != NULL) - seg = g_editor->control_sel_l->prev; - else - seg = seg_get_last_segment(g_editor->control_sel_l); - - cpopup_blend_endpoints(seg->r1, seg->g1, seg->b1, seg->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 1: /* Fetch from right endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(fg_r, - fg_g, - fg_b, - fg_a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_left_callback */ + color[0] = r; + color[1] = g; + color[2] = b; + color[3] = a; + gtk_color_selection_set_color (cs, color); +} /*****/ static void -cpopup_save_left_callback(GtkWidget *widget, gpointer data) +cpopup_get_color_selection_color (GtkColorSelection *cs, + double *r, + double *g, + double *b, + double *a) { - g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; -} /* cpopup_save_left_callback */ + gdouble color[4]; + gtk_color_selection_get_color (cs, color); -/*****/ - -static void -cpopup_load_right_callback(GtkWidget *widget, gpointer data) -{ - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; - - switch ((long) data) { - case 0: /* Fetch from right neighbor's left endpoint */ - if (g_editor->control_sel_r->next != NULL) - seg = g_editor->control_sel_r->next; - else - seg = curr_gradient->segments; - - cpopup_blend_endpoints(g_editor->control_sel_r->r0, - g_editor->control_sel_r->g0, - g_editor->control_sel_r->b0, - g_editor->control_sel_r->a0, - seg->r0, seg->g0, seg->b0, seg->a0, - TRUE, TRUE); - break; - - case 1: /* Fetch from left endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - fg_r, - fg_g, - fg_b, - fg_a, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_right_callback */ - - -/*****/ - -static void -cpopup_save_right_callback(GtkWidget *widget, gpointer data) -{ - g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; -} /* cpopup_save_right_callback */ - - -/*****/ - -static void -cpopup_set_color_selection_color(GtkColorSelection *cs, - double r, double g, double b, double a) -{ - gdouble color[4]; - - color[0] = r; - color[1] = g; - color[2] = b; - color[3] = a; - - gtk_color_selection_set_color(cs, color); -} /* cpopup_set_color_selection_color */ - - -/*****/ - -static void -cpopup_get_color_selection_color(GtkColorSelection *cs, - double *r, double *g, double *b, double *a) -{ - gdouble color[4]; - - gtk_color_selection_get_color(cs, color); - - *r = color[0]; - *g = color[1]; - *b = color[2]; - *a = color[3]; -} /* cpopup_get_color_selection_color */ - + *r = color[0]; + *g = color[1]; + *b = color[2]; + *a = color[3]; +} /*****/ static grad_segment_t * -cpopup_save_selection(void) +cpopup_save_selection (void) { - grad_segment_t *seg, *prev, *tmp; - grad_segment_t *oseg, *oaseg; + grad_segment_t *seg, *prev, *tmp; + grad_segment_t *oseg, *oaseg; - prev = NULL; - oseg = g_editor->control_sel_l; - tmp = NULL; + prev = NULL; + oseg = g_editor->control_sel_l; + tmp = NULL; - do { - seg = seg_new_segment(); + do + { + seg = seg_new_segment (); - *seg = *oseg; /* Copy everything */ + *seg = *oseg; /* Copy everything */ - if (prev == NULL) - tmp = seg; /* Remember first segment */ - else - prev->next = seg; + if (prev == NULL) + tmp = seg; /* Remember first segment */ + else + prev->next = seg; - seg->prev = prev; - seg->next = NULL; + seg->prev = prev; + seg->next = NULL; - prev = seg; - oaseg = oseg; - oseg = oseg->next; - } while (oaseg != g_editor->control_sel_r); - - return tmp; -} /* cpopup_save_selection */ + prev = seg; + oaseg = oseg; + oseg = oseg->next; + } + while (oaseg != g_editor->control_sel_r); + return tmp; +} /*****/ static void -cpopup_free_selection(grad_segment_t *seg) +cpopup_free_selection (grad_segment_t *seg) { - seg_free_segments(seg); -} /* cpopup_free_selection */ - + seg_free_segments (seg); +} /*****/ static void -cpopup_replace_selection(grad_segment_t *replace_seg) +cpopup_replace_selection (grad_segment_t *replace_seg) { - grad_segment_t *lseg, *rseg; - grad_segment_t *replace_last; + grad_segment_t *lseg, *rseg; + grad_segment_t *replace_last; - /* Remember left and right segments */ + /* Remember left and right segments */ - lseg = g_editor->control_sel_l->prev; - rseg = g_editor->control_sel_r->next; + lseg = g_editor->control_sel_l->prev; + rseg = g_editor->control_sel_r->next; - replace_last = seg_get_last_segment(replace_seg); + replace_last = seg_get_last_segment (replace_seg); - /* Free old selection */ + /* Free old selection */ - g_editor->control_sel_r->next = NULL; + g_editor->control_sel_r->next = NULL; - seg_free_segments(g_editor->control_sel_l); + seg_free_segments (g_editor->control_sel_l); - /* Link in new segments */ + /* Link in new segments */ - if (lseg) - lseg->next = replace_seg; - else - curr_gradient->segments = replace_seg; + if (lseg) + lseg->next = replace_seg; + else + curr_gradient->segments = replace_seg; - replace_seg->prev = lseg; + replace_seg->prev = lseg; - if (rseg) - rseg->prev = replace_last; + if (rseg) + rseg->prev = replace_last; - replace_last->next = rseg; + replace_last->next = rseg; - g_editor->control_sel_l = replace_seg; - g_editor->control_sel_r = replace_last; + g_editor->control_sel_l = replace_seg; + g_editor->control_sel_r = replace_last; - curr_gradient->last_visited = NULL; /* Force re-search */ -} /* cpopup_replace_selection */ + curr_gradient->last_visited = NULL; /* Force re-search */ +} /***** Color dialogs for left and right endpoint *****/ -/*****/ - static void -cpopup_create_color_dialog (gchar *title, - double r, double g, double b, double a, - GtkSignalFunc color_changed_callback, - GtkSignalFunc ok_callback, - GtkSignalFunc cancel_callback, - GtkSignalFunc delete_callback) +cpopup_create_color_dialog (gchar *title, + double r, + double g, + double b, + double a, + GtkSignalFunc color_changed_callback, + GtkSignalFunc ok_callback, + GtkSignalFunc cancel_callback, + GtkSignalFunc delete_callback) { GtkWidget *window; GtkColorSelection *cs; @@ -4360,8 +4363,6 @@ cpopup_right_color_dialog_delete (GtkWidget *widget, /***** Blending menu *****/ -/*****/ - static GtkWidget * cpopup_create_blending_menu (void) { @@ -4432,8 +4433,6 @@ cpopup_blending_callback (GtkWidget *widget, /***** Coloring menu *****/ -/*****/ - static GtkWidget * cpopup_create_coloring_menu (void) { @@ -4593,26 +4592,23 @@ cpopup_split_uniform_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Split"), cpopup_split_uniform_split_callback, NULL, NULL }, - { N_("Cancel"), cpopup_split_uniform_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_segment_split_uniformly", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Split segment uniformly") : - _("Split segments uniformly")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Split segment uniformly") : + _("Split segments uniformly"), + "gradient_segment_split_uniformly", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_split_uniform_delete_callback), - dialog); + _("Split"), cpopup_split_uniform_split_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), cpopup_split_uniform_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -4646,11 +4642,6 @@ cpopup_split_uniform_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_split_uniform_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 0); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -4704,16 +4695,6 @@ cpopup_split_uniform_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_split_uniform_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_split_uniform_cancel_callback (widget, data); - - return TRUE; -} - static void cpopup_split_uniform (grad_segment_t *lseg, int parts, @@ -4958,8 +4939,6 @@ cpopup_redistribute_callback (GtkWidget *widget, /***** Control popup -> selection options functions *****/ -/*****/ - static GtkWidget * cpopup_create_sel_ops_menu (void) { @@ -5172,26 +5151,23 @@ cpopup_replicate_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Replicate"), cpopup_do_replicate_callback, NULL, NULL }, - { N_("Cancel"), cpopup_replicate_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), - "gradient_segment_replicate", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Replicate segment") : - _("Replicate selection")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Replicate segment") : + _("Replicate selection"), + "gradient_segment_replicate", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_replicate_delete_callback), - dialog); + _("Replicate"), cpopup_do_replicate_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), cpopup_replicate_cancel_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); @@ -5223,11 +5199,6 @@ cpopup_replicate_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_replicate_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -5370,16 +5341,6 @@ cpopup_replicate_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_replicate_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_replicate_cancel_callback (widget, data); - - return TRUE; -} - /*****/ static void @@ -5420,8 +5381,6 @@ cpopup_blend_opacity (GtkWidget *widget, /***** Main blend function *****/ -/*****/ - static void cpopup_blend_endpoints (double r0, double g0, double b0, double a0, double r1, double g1, double b1, double a1, @@ -5469,645 +5428,671 @@ cpopup_blend_endpoints (double r0, double g0, double b0, double a0, /***** Gradient functions *****/ -/*****/ - static gradient_t * -grad_new_gradient(void) +grad_new_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = g_malloc(sizeof(gradient_t)); + grad = g_new (gradient_t, 1); - grad->name = NULL; - grad->segments = NULL; - grad->last_visited = NULL; - grad->dirty = 0; - grad->filename = NULL; - grad->pixmap = NULL; + grad->name = NULL; + grad->segments = NULL; + grad->last_visited = NULL; + grad->dirty = 0; + grad->filename = NULL; + grad->pixmap = NULL; - return grad; -} /* grad_new_gradient */ - - -/*****/ - -static void -grad_free_gradient(gradient_t *grad) -{ - g_assert(grad != NULL); - - if (grad->name) - g_free(grad->name); - - if (grad->segments) - seg_free_segments(grad->segments); - - if (grad->filename) - g_free(grad->filename); - - g_free(grad); -} /* grad_free_gradient */ - - -/*****/ - -static void -grad_save_all(int need_free) -{ - GSList *node; - gradient_t *grad; - - node = gradients_list; - - while (node) { - grad = node->data; - - /* If gradient has dirty flag set, save it */ - - if (grad->dirty) - grad_save_gradient(grad, grad->filename); - - if(need_free) - grad_free_gradient(grad); - - node = g_slist_next(node); - } /* while */ + return grad; } /*****/ static void -grad_free_gradients(void) +grad_free_gradient (gradient_t *grad) { - grad_save_all(1); + g_assert (grad != NULL); + + if (grad->name) + g_free (grad->name); + + if (grad->segments) + seg_free_segments (grad->segments); + + if (grad->filename) + g_free (grad->filename); + + g_free (grad); +} + +/*****/ + +static void +grad_save_all (int need_free) +{ + GSList *node; + gradient_t *grad; + + node = gradients_list; + + while (node) + { + grad = node->data; + + /* If gradient has dirty flag set, save it */ + if (grad->dirty) + grad_save_gradient (grad, grad->filename); + + if (need_free) + grad_free_gradient (grad); + + node = g_slist_next (node); + } +} + +/*****/ + +static void +grad_free_gradients (void) +{ + grad_save_all (1); - g_slist_free(gradients_list); - - num_gradients = 0; - gradients_list = NULL; - curr_gradient = NULL; -} /* grad_free_gradients */ + g_slist_free (gradients_list); + num_gradients = 0; + gradients_list = NULL; + curr_gradient = NULL; +} /*****/ static void -grad_load_gradient(char *filename) +grad_load_gradient (char *filename) { - FILE *file; - gradient_t *grad; - grad_segment_t *seg, *prev; - int num_segments; - int i; - int type, color; - char line[1024]; + FILE *file; + gradient_t *grad; + grad_segment_t *seg, *prev; + int num_segments; + int i; + int type, color; + char line[1024]; - g_assert(filename != NULL); + g_assert (filename != NULL); - file = fopen(filename, "rb"); - if (!file) - return; + file = fopen (filename, "rb"); + if (!file) + return; - fgets(line, 1024, file); - if (strcmp(line, "GIMP Gradient\n") != 0) - return; + fgets (line, 1024, file); + if (strcmp (line, "GIMP Gradient\n") != 0) + return; - grad = grad_new_gradient(); + grad = grad_new_gradient (); - grad->filename = g_strdup(filename); - grad->name = g_strdup(g_basename(filename)); + grad->filename = g_strdup (filename); + grad->name = g_strdup (g_basename (filename)); - fgets(line, 1024, file); - num_segments = atoi(line); + fgets (line, 1024, file); + num_segments = atoi (line); - if (num_segments < 1) { - g_message (_("grad_load_gradient(): invalid number of segments in \"%s\""), filename); - g_free(grad); - return; - } /* if */ + if (num_segments < 1) + { + g_message (_("grad_load_gradient(): " + "invalid number of segments in \"%s\""), filename); + g_free (grad); + return; + } - prev = NULL; + prev = NULL; - for (i = 0; i < num_segments; i++) { - seg = seg_new_segment(); - seg->prev = prev; + for (i = 0; i < num_segments; i++) + { + seg = seg_new_segment (); + seg->prev = prev; - if (prev) - prev->next = seg; - else - grad->segments = seg; + if (prev) + prev->next = seg; + else + grad->segments = seg; - fgets(line, 1024, file); + fgets (line, 1024, file); - if (sscanf(line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", - &(seg->left), &(seg->middle), &(seg->right), - &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), - &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), - &type, &color) != 13) { - g_message (_("grad_load_gradient(): badly formatted " - "gradient segment %d in \"%s\" --- bad things may " - "happen soon"), i, filename); - } else { - seg->type = (grad_type_t) type; - seg->color = (grad_color_t) color; - } /* else */ + if (sscanf (line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", + &(seg->left), &(seg->middle), &(seg->right), + &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), + &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), + &type, &color) != 13) + { + g_message (_("grad_load_gradient(): badly formatted " + "gradient segment %d in \"%s\" --- bad things may " + "happen soon"), i, filename); + } + else + { + seg->type = (grad_type_t) type; + seg->color = (grad_color_t) color; + } - prev = seg; - } /* for */ + prev = seg; + } - fclose(file); + fclose (file); - grad_insert_in_gradients_list(grad); - - /* Check if this gradient is the default one */ - - if (strcmp(default_gradient, grad->name) == 0) - grad_default_gradient = grad; -} /* grad_load_gradient */ + grad_insert_in_gradients_list (grad); + /* Check if this gradient is the default one */ + if (strcmp (default_gradient, grad->name) == 0) + grad_default_gradient = grad; +} /*****/ static void -grad_save_gradient(gradient_t *grad, char *filename) +grad_save_gradient (gradient_t *grad, + char *filename) { - FILE *file; - int num_segments; - grad_segment_t *seg; + FILE *file; + int num_segments; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert (grad != NULL); - if (!filename) { - g_message (_("grad_save_gradient(): can not save gradient with NULL filename")); - return; - } /* if */ + if (!filename) + { + g_message (_("grad_save_gradient(): " + "can not save gradient with NULL filename")); + return; + } - file = fopen(filename, "wb"); - if (!file) { - g_message (_("grad_save_gradient(): can't open \"%s\""), filename); - return; - } /* if */ + file = fopen (filename, "wb"); + if (!file) + { + g_message (_("grad_save_gradient(): can't open \"%s\""), filename); + return; + } - /* File format is: - * - * GIMP Gradient - * number_of_segments - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * ... - */ + /* File format is: + * + * GIMP Gradient + * number_of_segments + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * ... + */ - fprintf(file, "GIMP Gradient\n"); + fprintf (file, "GIMP Gradient\n"); - /* Count number of segments */ + /* Count number of segments */ + num_segments = 0; + seg = grad->segments; - num_segments = 0; - seg = grad->segments; + while (seg) + { + num_segments++; + seg = seg->next; + } - while (seg) { - num_segments++; - seg = seg->next; - } /* while */ + /* Write rest of file */ + fprintf (file, "%d\n", num_segments); - /* Write rest of file */ + for (seg = grad->segments; seg; seg = seg->next) + fprintf (file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, (int) seg->color); - fprintf(file, "%d\n", num_segments); - - for (seg = grad->segments; seg; seg = seg->next) - fprintf(file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, (int) seg->color); - - fclose(file); - - grad->dirty = 0; -} /* grad_save_gradient */ + fclose(file); + grad->dirty = 0; +} /*****/ static gradient_t * -grad_create_default_gradient(void) +grad_create_default_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = grad_new_gradient(); - grad->segments = seg_new_segment(); - - return grad; -} /* grad_create_default_gradient */ + grad = grad_new_gradient(); + grad->segments = seg_new_segment (); + return grad; +} /*****/ static int -grad_insert_in_gradients_list(gradient_t *grad) +grad_insert_in_gradients_list (gradient_t *grad) { - GSList *tmp; - gradient_t *g; - int n; + GSList *tmp; + gradient_t *g; + int n; - /* We insert gradients in alphabetical order. Find the index - * of the gradient after which we will insert the current one. - */ + /* We insert gradients in alphabetical order. Find the index + * of the gradient after which we will insert the current one. + */ - n = 0; - tmp = gradients_list; + n = 0; + tmp = gradients_list; - while (tmp) { - g = tmp->data; + while (tmp) + { + g = tmp->data; - if (strcmp(grad->name, g->name) <= 0) - break; /* We found the one we want */ + if (strcmp (grad->name, g->name) <= 0) + break; /* We found the one we want */ - n++; - tmp = g_slist_next(tmp); - } /* while */ + n++; + tmp = g_slist_next (tmp); + } - num_gradients++; - gradients_list = g_slist_insert(gradients_list, grad, n); - - return n; -} /* grad_insert_in_gradients_list */ + num_gradients++; + gradients_list = g_slist_insert (gradients_list, grad, n); + return n; +} /*****/ static void -grad_dump_gradient(gradient_t *grad, FILE *file) +grad_dump_gradient (gradient_t *grad, + FILE *file) { - grad_segment_t *seg; + grad_segment_t *seg; - fprintf(file, "Name: \"%s\"\n", grad->name); - fprintf(file, "Dirty: %d\n", grad->dirty); - fprintf(file, "Filename: \"%s\"\n", grad->filename); + fprintf (file, "Name: \"%s\"\n", grad->name); + fprintf (file, "Dirty: %d\n", grad->dirty); + fprintf (file, "Filename: \"%s\"\n", grad->filename); - seg = grad->segments; + seg = grad->segments; - while (seg) { - fprintf(file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", - (seg == grad->last_visited) ? '>' : ' ', - seg, - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, - (int) seg->color, - seg->prev, seg->next); - - seg = seg->next; - } /* while */ -} /* grad_dump_gradient */ + while (seg) + { + fprintf (file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", + (seg == grad->last_visited) ? '>' : ' ', + seg, + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, + (int) seg->color, + seg->prev, seg->next); + seg = seg->next; + } +} /***** Segment functions *****/ -/*****/ - static grad_segment_t * -seg_new_segment(void) +seg_new_segment (void) { - grad_segment_t *seg; + grad_segment_t *seg; - seg = g_malloc(sizeof(grad_segment_t)); + seg = g_new (grad_segment_t, 1); - seg->left = 0.0; - seg->middle = 0.5; - seg->right = 1.0; + seg->left = 0.0; + seg->middle = 0.5; + seg->right = 1.0; - seg->r0 = seg->g0 = seg->b0 = 0.0; - seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; + seg->r0 = seg->g0 = seg->b0 = 0.0; + seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; - seg->type = GRAD_LINEAR; - seg->color = GRAD_RGB; + seg->type = GRAD_LINEAR; + seg->color = GRAD_RGB; - seg->prev = seg->next = NULL; - - return seg; -} /* seg_new_segment */ + seg->prev = seg->next = NULL; + return seg; +} /*****/ static void -seg_free_segment(grad_segment_t *seg) +seg_free_segment (grad_segment_t *seg) { - g_assert(seg != NULL); - - g_free(seg); -} /* seg_free_segment */ + g_assert (seg != NULL); + g_free (seg); +} /*****/ static void -seg_free_segments(grad_segment_t *seg) +seg_free_segments (grad_segment_t *seg) { - grad_segment_t *tmp; + grad_segment_t *tmp; - g_assert(seg != NULL); - - while (seg) { - tmp = seg->next; - seg_free_segment(seg); - seg = tmp; - } /* while */ -} /* seg_free_segments */ + g_assert (seg != NULL); + while (seg) + { + tmp = seg->next; + seg_free_segment(seg); + seg = tmp; + } +} /*****/ static grad_segment_t * -seg_get_segment_at(gradient_t *grad, double pos) +seg_get_segment_at (gradient_t *grad, + double pos) { - grad_segment_t *seg; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert(grad != NULL); - pos = BOUNDS(pos, 0.0, 1.0); /* to handle FP imprecision at the edges of the gradient */ + /* handle FP imprecision at the edges of the gradient */ + pos = BOUNDS (pos, 0.0, 1.0); - if (grad->last_visited) - seg = grad->last_visited; - else - seg = grad->segments; + if (grad->last_visited) + seg = grad->last_visited; + else + seg = grad->segments; - while (seg) - if (pos >= seg->left) { - if (pos <= seg->right) { - grad->last_visited = seg; /* for speed */ - return seg; - } else - seg = seg->next; - } else - seg = seg->prev; + while (seg) + { + if (pos >= seg->left) + { + if (pos <= seg->right) + { + grad->last_visited = seg; /* for speed */ + return seg; + } + else + { + seg = seg->next; + } + } + else + { + seg = seg->prev; + } + } - /* Oops: we should have found a segment, but we didn't */ - - grad_dump_gradient(curr_gradient, stderr); - gimp_fatal_error (_("seg_get_segment_at(): No matching segment for position %0.15f"), pos); - return NULL; /* To shut up -Wall */ -} /* seg_get_segment_at */ + /* Oops: we should have found a segment, but we didn't */ + grad_dump_gradient (curr_gradient, stderr); + gimp_fatal_error (_("seg_get_segment_at(): " + "No matching segment for position %0.15f"), pos); + return NULL; /* To shut up -Wall */ +} /*****/ static grad_segment_t * -seg_get_last_segment(grad_segment_t *seg) +seg_get_last_segment (grad_segment_t *seg) { - if (!seg) - return NULL; + if (!seg) + return NULL; - while (seg->next) - seg = seg->next; - - return seg; -} /* seg_get_last_segment */ + while (seg->next) + seg = seg->next; + return seg; +} /*****/ static void -seg_get_closest_handle(gradient_t *grad, double pos, - grad_segment_t **seg, control_drag_mode_t *handle) +seg_get_closest_handle (gradient_t *grad, + double pos, + grad_segment_t **seg, + control_drag_mode_t *handle) { - double l_delta, m_delta, r_delta; + double l_delta, m_delta, r_delta; - *seg = seg_get_segment_at(grad, pos); + *seg = seg_get_segment_at (grad, pos); - m_delta = fabs(pos - (*seg)->middle); + m_delta = fabs (pos - (*seg)->middle); - if (pos < (*seg)->middle) { - l_delta = fabs(pos - (*seg)->left); + if (pos < (*seg)->middle) + { + l_delta = fabs (pos - (*seg)->left); - if (l_delta < m_delta) - *handle = GRAD_DRAG_LEFT; - else - *handle = GRAD_DRAG_MIDDLE; - } else { - r_delta = fabs(pos - (*seg)->right); - - if (m_delta < r_delta) - *handle = GRAD_DRAG_MIDDLE; - else { - *seg = (*seg)->next; - *handle = GRAD_DRAG_LEFT; - } /* else */ - } /* else */ -} /* seg_get_closest_handle */ + if (l_delta < m_delta) + *handle = GRAD_DRAG_LEFT; + else + *handle = GRAD_DRAG_MIDDLE; + } + else + { + r_delta = fabs (pos - (*seg)->right); + if (m_delta < r_delta) + { + *handle = GRAD_DRAG_MIDDLE; + } + else + { + *seg = (*seg)->next; + *handle = GRAD_DRAG_LEFT; + } + } +} /***** Calculation functions *****/ -/*****/ - static double -calc_linear_factor(double middle, double pos) +calc_linear_factor (double middle, + double pos) { - if (pos <= middle) { - if (middle < EPSILON) - return 0.0; - else - return 0.5 * pos / middle; - } else { - pos -= middle; - middle = 1.0 - middle; - - if (middle < EPSILON) - return 1.0; - else - return 0.5 + 0.5 * pos / middle; - } /* else */ -} /* calc_linear_factor */ + if (pos <= middle) + { + if (middle < EPSILON) + return 0.0; + else + return 0.5 * pos / middle; + } + else + { + pos -= middle; + middle = 1.0 - middle; + if (middle < EPSILON) + return 1.0; + else + return 0.5 + 0.5 * pos / middle; + } +} /*****/ static double -calc_curved_factor(double middle, double pos) +calc_curved_factor (double middle, + double pos) { - if (middle < EPSILON) - middle = EPSILON; - - return pow(pos, log(0.5) / log(middle)); -} /* calc_curved_factor */ + if (middle < EPSILON) + middle = EPSILON; + return pow(pos, log (0.5) / log (middle)); +} /*****/ static double -calc_sine_factor(double middle, double pos) +calc_sine_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return (sin((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; -} /* calc_sine_factor */ + pos = calc_linear_factor (middle, pos); + return (sin ((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; +} /*****/ static double -calc_sphere_increasing_factor(double middle, double pos) +calc_sphere_increasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos) - 1.0; - - return sqrt(1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ -} /* calc_sphere_increasing_factor */ + pos = calc_linear_factor (middle, pos) - 1.0; + return sqrt (1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ +} /*****/ static double -calc_sphere_decreasing_factor(double middle, double pos) +calc_sphere_decreasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ -} /* calc_sphere_decreasing_factor */ + pos = calc_linear_factor (middle, pos); + return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ +} /*****/ static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, + double *g, + double *b) { - double red, green, blue; - double h, s, v; - double min, max; - double delta; + double red, green, blue; + double h, s, v; + double min, max; + double delta; - red = *r; - green = *g; - blue = *b; + red = *r; + green = *g; + blue = *b; - h = 0.0; /* Shut up -Wall */ + h = 0.0; /* Shut up -Wall */ - if (red > green) { - if (red > blue) - max = red; - else - max = blue; + if (red > green) + { + if (red > blue) + max = red; + else + max = blue; - if (green < blue) - min = green; - else - min = blue; - } else { - if (green > blue) - max = green; - else - max = blue; + if (green < blue) + min = green; + else + min = blue; + } + else + { + if (green > blue) + max = green; + else + max = blue; - if (red < blue) - min = red; - else - min = blue; - } /* else */ + if (red < blue) + min = red; + else + min = blue; + } - v = max; + v = max; - if (max != 0.0) - s = (max - min) / max; - else - s = 0.0; + if (max != 0.0) + s = (max - min) / max; + else + s = 0.0; - if (s == 0.0) - h = 0.0; - else { - delta = max - min; + if (s == 0.0) + { + h = 0.0; + } + else + { + delta = max - min; - if (red == max) - h = (green - blue) / delta; - else if (green == max) - h = 2 + (blue - red) / delta; - else if (blue == max) - h = 4 + (red - green) / delta; + if (red == max) + h = (green - blue) / delta; + else if (green == max) + h = 2 + (blue - red) / delta; + else if (blue == max) + h = 4 + (red - green) / delta; - h /= 6.0; + h /= 6.0; - if (h < 0.0) - h += 1.0; - else if (h > 1.0) - h -= 1.0; - } /* else */ - - *r = h; - *g = s; - *b = v; -} /* calc_rgb_to_hsv */ + if (h < 0.0) + h += 1.0; + else if (h > 1.0) + h -= 1.0; + } + *r = h; + *g = s; + *b = v; +} /*****/ static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, + double *s, + double *v) { - double hue, saturation, value; - double f, p, q, t; + double hue, saturation, value; + double f, p, q, t; - if (*s == 0.0) { - *h = *v; - *s = *v; - *v = *v; /* heh */ - } else { - hue = *h * 6.0; - saturation = *s; - value = *v; + if (*s == 0.0) + { + *h = *v; + *s = *v; + *v = *v; /* heh */ + } + else + { + hue = *h * 6.0; + saturation = *s; + value = *v; - if (hue == 6.0) - hue = 0.0; + if (hue == 6.0) + hue = 0.0; - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); + f = hue - (int) hue; + p = value * (1.0 - saturation); + q = value * (1.0 - saturation * f); + t = value * (1.0 - saturation * (1.0 - f)); - switch ((int) hue) { - case 0: - *h = value; - *s = t; - *v = p; - break; + switch ((int) hue) + { + case 0: + *h = value; + *s = t; + *v = p; + break; - case 1: - *h = q; - *s = value; - *v = p; - break; + case 1: + *h = q; + *s = value; + *v = p; + break; - case 2: - *h = p; - *s = value; - *v = t; - break; + case 2: + *h = p; + *s = value; + *v = t; + break; - case 3: - *h = p; - *s = q; - *v = value; - break; + case 3: + *h = p; + *s = q; + *v = value; + break; - case 4: - *h = t; - *s = p; - *v = value; - break; - - case 5: - *h = value; - *s = p; - *v = q; - break; - } /* switch */ - } /* else */ -} /* calc_hsv_to_rgb */ + case 4: + *h = t; + *s = p; + *v = value; + break; + case 5: + *h = value; + *s = p; + *v = q; + break; + } + } +} /***** Files and paths functions *****/ -/*****/ - static gchar * build_user_filename (gchar *name, gchar *path_str) diff --git a/app/gradient_editor.c b/app/gradient_editor.c index c5c8a84b84..0274f668a0 100644 --- a/app/gradient_editor.c +++ b/app/gradient_editor.c @@ -150,7 +150,6 @@ #include #endif -#include "actionarea.h" #include "appenv.h" #include "colormaps.h" #include "cursorutil.h" @@ -158,8 +157,8 @@ #include "errors.h" #include "general.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "session.h" #include "gradient_header.h" @@ -209,8 +208,6 @@ static void ed_do_copy_gradient_callback (GtkWidget *, gpointer , gpointer); static void ed_delete_gradient_callback (GtkWidget *, gpointer); static void ed_do_delete_gradient_callback (GtkWidget *, gpointer); static void ed_cancel_delete_gradient_callback (GtkWidget *, gpointer); -static gint ed_delete_delete_gradient_callback (GtkWidget *, GdkEvent *, - gpointer); static void ed_rename_gradient_callback (GtkWidget *, gpointer); static void ed_do_rename_gradient_callback (GtkWidget *, gpointer, gpointer); @@ -222,8 +219,6 @@ static gint ed_delete_save_pov_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_save_grads_callback (GtkWidget *, gpointer); static void ed_refresh_grads_callback (GtkWidget *, gpointer); - -static gint ed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_close_callback (GtkWidget *, gpointer); /* Zoom, scrollbar & instant update callbacks */ @@ -248,27 +243,29 @@ static void prev_fill_image (int width, int height, /* Gradient control functions */ -static gint control_events (GtkWidget *, GdkEvent *, gpointer); -static void control_do_hint (gint x, gint y); -static void control_button_press (gint x, gint y, - guint button, guint state); -static int control_point_in_handle (gint x, gint y, grad_segment_t *seg, - control_drag_mode_t handle); -static void control_select_single_segment (grad_segment_t *seg); -static void control_extend_selection (grad_segment_t *seg, double pos); -static void control_motion (gint x); +static gint control_events (GtkWidget *, GdkEvent *, + gpointer); +static void control_do_hint (gint x, gint y); +static void control_button_press (gint x, gint y, + guint button, guint state); +static gboolean control_point_in_handle (gint x, gint y, + grad_segment_t *seg, + control_drag_mode_t handle); +static void control_select_single_segment (grad_segment_t *seg); +static void control_extend_selection (grad_segment_t *seg, double pos); +static void control_motion (gint x); -static void control_compress_left (grad_segment_t *range_l, - grad_segment_t *range_r, - grad_segment_t *drag_seg, +static void control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, double pos); -static void control_compress_range (grad_segment_t *range_l, - grad_segment_t *range_r, - double new_l, double new_r); +static void control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, double new_r); -static double control_move (grad_segment_t *range_l, - grad_segment_t *range_r, - double delta); +static double control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta); /* Control update/redraw functions */ @@ -379,8 +376,6 @@ static void cpopup_split_uniform_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_scale_update (GtkAdjustment *, gpointer); static void cpopup_split_uniform_split_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_split_uniform_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_split_uniform (grad_segment_t *lseg, int parts, grad_segment_t **newl, grad_segment_t **newr); @@ -398,8 +393,6 @@ static void cpopup_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_scale_update (GtkAdjustment *, gpointer); static void cpopup_do_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_replicate_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_blend_colors (GtkWidget *, gpointer); static void cpopup_blend_opacity (GtkWidget *, gpointer); @@ -668,13 +661,6 @@ grad_create_gradient_editor_init (gint need_show) gint i; gint select_pos; - static ActionAreaItem action_items[] = - { - { N_("Save"), ed_save_grads_callback, NULL, NULL }, - { N_("Refresh"), ed_refresh_grads_callback, NULL, NULL }, - { N_("Close"), ed_close_callback, NULL, NULL } - }; - /* If the editor already exists, just show it */ if (g_editor) { @@ -698,15 +684,20 @@ grad_create_gradient_editor_init (gint need_show) g_editor = g_new (gradient_editor_t, 1); /* Shell and main vbox */ - g_editor->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_editor", "Gimp"); - gtk_window_set_title (GTK_WINDOW (g_editor->shell), _("Gradient Editor")); + g_editor->shell = gimp_dialog_new (_("Gradient Editor"), "gradient_editor", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_callback), - NULL); + _("Save"), ed_save_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Refresh"), ed_refresh_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Close"), ed_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -881,7 +872,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (gvbox); /* Gradient preview */ - g_editor->preview_rows[0] = NULL; g_editor->preview_rows[1] = NULL; g_editor->preview_last_x = 0; @@ -905,7 +895,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (g_editor->preview); /* Gradient control */ - g_editor->control_pixmap = NULL; g_editor->control_drag_segment = NULL; g_editor->control_sel_l = NULL; @@ -967,9 +956,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_box_pack_start (GTK_BOX (vbox), g_editor->hint_label, FALSE, FALSE, 0); gtk_widget_show (g_editor->hint_label); - /* The action area */ - build_action_area (GTK_DIALOG (g_editor->shell), action_items, 3, 2); - /* Initialize other data */ g_editor->left_color_preview = NULL; g_editor->left_saved_segments = NULL; @@ -995,11 +981,8 @@ grad_create_gradient_editor_init (gint need_show) gtk_clist_moveto (GTK_CLIST (g_editor->clist), select_pos, 0, 0.0, 0.0); } - /***** Gradient editor functions *****/ -/*****/ - static void ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) { @@ -1319,17 +1302,20 @@ ed_initialize_saved_colors(void) /***** the "new gradient" dialog functions *****/ -/*****/ - static void ed_new_gradient_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box(_("New gradient"), - _("Enter a name for the new gradient"), - _("untitled"), - NULL, NULL, - ed_do_new_gradient_callback, NULL)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the new gradient"), + _("untitled"), + NULL, NULL, + ed_do_new_gradient_callback, NULL); + gtk_widget_show (qbox); } static void @@ -1373,12 +1359,11 @@ ed_do_new_gradient_callback (GtkWidget *widget, /***** The "copy gradient" dialog functions *****/ -/*****/ - static void ed_copy_gradient_callback (GtkWidget *widget, gpointer data) { + GtkWidget *qbox; gchar *name; if (curr_gradient == NULL) @@ -1386,13 +1371,16 @@ ed_copy_gradient_callback (GtkWidget *widget, name = g_strdup_printf (_("%s copy"), curr_gradient->name); - gtk_widget_show (query_string_box (_("Copy gradient"), - _("Enter a name for the copied gradient"), - name, - NULL, NULL, - ed_do_copy_gradient_callback, NULL)); + qbox = gimp_query_string_box (_("Copy gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the copied gradient"), + name, + NULL, NULL, + ed_do_copy_gradient_callback, NULL); + gtk_widget_show (qbox); - g_free(name); + g_free (name); } static void @@ -1460,21 +1448,24 @@ ed_do_copy_gradient_callback (GtkWidget *widget, /***** The "rename gradient" dialog functions *****/ -/*****/ - static void ed_rename_gradient_callback (GtkWidget *widget, - gpointer data) + gpointer data) { + GtkWidget *qbox; + if (curr_gradient == NULL) return; - gtk_widget_show (query_string_box (_("Rename gradient"), - _("Enter a new name for the gradient"), - curr_gradient->name, - NULL, NULL, - ed_do_rename_gradient_callback, - curr_gradient)); + qbox = gimp_query_string_box (_("Rename gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a new name for the gradient"), + curr_gradient->name, + NULL, NULL, + ed_do_rename_gradient_callback, + curr_gradient); + gtk_widget_show (qbox); } static void @@ -1536,8 +1527,6 @@ ed_do_rename_gradient_callback (GtkWidget *widget, /***** The "delete gradient" dialog functions *****/ -/*****/ - static void ed_delete_gradient_callback (GtkWidget *widget, gpointer data) @@ -1547,24 +1536,21 @@ ed_delete_gradient_callback (GtkWidget *widget, GtkWidget *label; gchar *str; - static ActionAreaItem action_items[] = - { - { N_("Delete"), ed_do_delete_gradient_callback, NULL, NULL }, - { N_("Cancel"), ed_cancel_delete_gradient_callback, NULL, NULL } - }; - if (num_gradients <= 1) return; - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "delete_gradient", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Delete gradient")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = gimp_dialog_new (_("Delete gradient"), "delete_gradient", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_delete_gradient_callback), - dialog); + _("Delete"), ed_do_delete_gradient_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), ed_cancel_delete_gradient_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -1572,9 +1558,9 @@ ed_delete_gradient_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); gtk_widget_show (vbox); - str = g_strdup_printf(_("Are you sure you want to delete\n" - "\"%s\" from the list and from disk?"), - curr_gradient->name); + str = g_strdup_printf (_("Are you sure you want to delete\n" + "\"%s\" from the list and from disk?"), + curr_gradient->name); label = gtk_label_new (str); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); @@ -1582,11 +1568,6 @@ ed_delete_gradient_callback (GtkWidget *widget, g_free (str); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1658,20 +1639,8 @@ ed_cancel_delete_gradient_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -ed_delete_delete_gradient_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_cancel_delete_gradient_callback (widget, data); - - return TRUE; -} - /***** The "save as pov" dialog functions *****/ -/*****/ - static void ed_save_pov_callback (GtkWidget *widget, gpointer data) @@ -1682,7 +1651,7 @@ ed_save_pov_callback (GtkWidget *widget, return; window = gtk_file_selection_new (_("Save as POV-Ray")); - gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); + gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button), "clicked", (GtkSignalFunc) ed_do_save_pov_callback, @@ -1696,6 +1665,10 @@ ed_save_pov_callback (GtkWidget *widget, (GdkEventFunc) ed_delete_save_pov_callback, window); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html"); + gtk_widget_show (window); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1771,8 +1744,6 @@ ed_delete_save_pov_callback (GtkWidget *widget, /***** The main dialog action area button callbacks *****/ -/*****/ - static void ed_save_grads_callback (GtkWidget *widget, gpointer data) @@ -1815,20 +1786,8 @@ ed_close_callback (GtkWidget *widget, gtk_widget_hide (g_editor->shell); } -static gint -ed_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_close_callback (widget, data); - - return TRUE; -} - /***** Zoom, scrollbar & instant update callbacks *****/ -/*****/ - static void ed_scrollbar_update (GtkAdjustment *adjustment, gpointer data) @@ -1942,8 +1901,6 @@ ed_instant_update_update (GtkWidget *widget, /***** Gradient preview functions *****/ -/*****/ - static gint prev_events (GtkWidget *widget, GdkEvent *event, @@ -2103,7 +2060,7 @@ prev_set_foreground (gint x) palette_set_foreground (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Foreground color set to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2126,7 +2083,7 @@ prev_set_background (gint x) palette_set_background (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Background color to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2229,54 +2186,58 @@ prev_update (gboolean recalculate) /*****/ static void -prev_fill_image(int width, int height, double left, double right) +prev_fill_image (int width, + int height, + double left, + double right) { - guchar *p0, *p1; - int x, y; - double dx, cur_x; - double r, g, b, a; - double c0, c1; + guchar *p0, *p1; + int x, y; + double dx, cur_x; + double r, g, b, a; + double c0, c1; - dx = (right - left) / (width - 1); - cur_x = left; - p0 = g_editor->preview_rows[0]; - p1 = g_editor->preview_rows[1]; + dx = (right - left) / (width - 1); + cur_x = left; + p0 = g_editor->preview_rows[0]; + p1 = g_editor->preview_rows[1]; - /* Create lines to fill the image */ + /* Create lines to fill the image */ + for (x = 0; x < width; x++) + { + grad_get_color_at (cur_x, &r, &g, &b, &a); - for (x = 0; x < width; x++) { - grad_get_color_at(cur_x, &r, &g, &b, &a); + if ((x / GRAD_CHECK_SIZE) & 1) + { + c0 = GRAD_CHECK_LIGHT; + c1 = GRAD_CHECK_DARK; + } + else + { + c0 = GRAD_CHECK_DARK; + c1 = GRAD_CHECK_LIGHT; + } - if ((x / GRAD_CHECK_SIZE) & 1) { - c0 = GRAD_CHECK_LIGHT; - c1 = GRAD_CHECK_DARK; - } else { - c0 = GRAD_CHECK_DARK; - c1 = GRAD_CHECK_LIGHT; - } /* else */ + *p0++ = (c0 + (r - c0) * a) * 255.0; + *p0++ = (c0 + (g - c0) * a) * 255.0; + *p0++ = (c0 + (b - c0) * a) * 255.0; - *p0++ = (c0 + (r - c0) * a) * 255.0; - *p0++ = (c0 + (g - c0) * a) * 255.0; - *p0++ = (c0 + (b - c0) * a) * 255.0; + *p1++ = (c1 + (r - c1) * a) * 255.0; + *p1++ = (c1 + (g - c1) * a) * 255.0; + *p1++ = (c1 + (b - c1) * a) * 255.0; - *p1++ = (c1 + (r - c1) * a) * 255.0; - *p1++ = (c1 + (g - c1) * a) * 255.0; - *p1++ = (c1 + (b - c1) * a) * 255.0; - - cur_x += dx; - } /* for */ - - /* Fill image */ - - for (y = 0; y < height; y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[1], 0, y, width); - else - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[0], 0, y, width); -} /* prev_fill_image */ + cur_x += dx; + } + /* Fill image */ + for (y = 0; y < height; y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[1], 0, y, width); + else + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[0], 0, y, width); +} /***** Gradient control functions *****/ @@ -2288,8 +2249,6 @@ prev_fill_image(int width, int height, double left, double right) * them yourself ;-) */ -/*****/ - static gint control_events (GtkWidget *widget, GdkEvent *event, @@ -2395,51 +2354,56 @@ control_events (GtkWidget *widget, /*****/ static void -control_do_hint(gint x, gint y) +control_do_hint (gint x, + gint y) { - grad_segment_t *seg; - control_drag_mode_t handle; - int in_handle; - double pos; + grad_segment_t *seg; + control_drag_mode_t handle; + gboolean in_handle; + double pos; - pos = control_calc_g_pos(x); + pos = control_calc_g_pos (x); - if ((pos < 0.0) || (pos > 1.0)) - return; + if ((pos < 0.0) || (pos > 1.0)) + return; - seg_get_closest_handle(curr_gradient, pos, &seg, &handle); + seg_get_closest_handle (curr_gradient, pos, &seg, &handle); - in_handle = control_point_in_handle(x, y, seg, handle); + in_handle = control_point_in_handle (x, y, seg, handle); - if (in_handle) { - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg != NULL) { - if (seg->prev != NULL) - ed_set_hint(_("Drag: move Shift+drag: move & compress")); - else - ed_set_hint(_("Click: select Shift+click: extend selection")); - } else - ed_set_hint(_("Click: select Shift+click: extend selection")); + if (in_handle) + { + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg != NULL) + { + if (seg->prev != NULL) + ed_set_hint (_("Drag: move Shift+drag: move & compress")); + else + ed_set_hint (_("Click: select Shift+click: extend selection")); + } + else + ed_set_hint (_("Click: select Shift+click: extend selection")); - break; + break; - case GRAD_DRAG_MIDDLE: - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move")); + case GRAD_DRAG_MIDDLE: + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move")); - break; - - default: - g_message ("control_do_hint: oops, in_handle is true " - "yet we got handle type %d", (int) handle); - break; - } /* switch */ - } else - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move Shift+drag: move & compress")); -} /* control_do_hint */ + break; + default: + g_message ("control_do_hint: oops, in_handle is true " + "yet we got handle type %d", (int) handle); + break; + } + } + else + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move Shift+drag: move & compress")); +} /*****/ @@ -2452,7 +2416,7 @@ control_button_press (gint x, grad_segment_t *seg; control_drag_mode_t handle; double xpos; - gint in_handle; + gboolean in_handle; /* See which button was pressed */ @@ -2592,343 +2556,370 @@ control_button_press (gint x, /*****/ -static int -control_point_in_handle(gint x, gint y, grad_segment_t *seg, control_drag_mode_t handle) +static gboolean +control_point_in_handle (gint x, + gint y, + grad_segment_t *seg, + control_drag_mode_t handle) { - gint handle_pos; + gint handle_pos; - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - handle_pos = control_calc_p_pos(seg->left); - else { - seg = seg_get_last_segment(curr_gradient->segments); + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + handle_pos = control_calc_p_pos (seg->left); + else + { + seg = seg_get_last_segment (curr_gradient->segments); - handle_pos = control_calc_p_pos(seg->right); - } /* else */ + handle_pos = control_calc_p_pos (seg->right); + } - break; + break; - case GRAD_DRAG_MIDDLE: - handle_pos = control_calc_p_pos(seg->middle); - break; + case GRAD_DRAG_MIDDLE: + handle_pos = control_calc_p_pos (seg->middle); + break; - default: - g_message ("control_point_in_handle(): oops, can not handle drag mode %d", - (int) handle); - return 0; - } /* switch */ + default: + g_message ("control_point_in_handle(): oops, can not handle drag mode %d", + (int) handle); + return FALSE; + } - y /= 2; - - if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) - return 1; - else - return 0; -} /* control_point_in_handle */ + y /= 2; + if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) + return TRUE; + else + return FALSE; +} /*****/ static void -control_select_single_segment(grad_segment_t *seg) +control_select_single_segment (grad_segment_t *seg) { - g_editor->control_sel_l = seg; - g_editor->control_sel_r = seg; -} /* control_select_single_segment */ - + g_editor->control_sel_l = seg; + g_editor->control_sel_r = seg; +} /*****/ static void -control_extend_selection(grad_segment_t *seg, double pos) +control_extend_selection (grad_segment_t *seg, + double pos) { - if (fabs(pos - g_editor->control_sel_l->left) < fabs(pos - g_editor->control_sel_r->right)) - g_editor->control_sel_l = seg; - else - g_editor->control_sel_r = seg; -} /* control_extend_selection */ - + if (fabs (pos - g_editor->control_sel_l->left) < + fabs(pos - g_editor->control_sel_r->right)) + g_editor->control_sel_l = seg; + else + g_editor->control_sel_r = seg; +} /*****/ static void -control_motion(gint x) +control_motion (gint x) { - grad_segment_t *seg; - double pos; - double delta; - char str[256]; + grad_segment_t *seg; + double pos; + double delta; + char str[256]; - seg = g_editor->control_drag_segment; + seg = g_editor->control_drag_segment; - switch (g_editor->control_drag_mode) { - case GRAD_DRAG_LEFT: - pos = control_calc_g_pos(x); + switch (g_editor->control_drag_mode) + { + case GRAD_DRAG_LEFT: + pos = control_calc_g_pos (x); - if (!g_editor->control_compress) - seg->prev->right = seg->left = BOUNDS(pos, - seg->prev->middle + EPSILON, - seg->middle - EPSILON); - else - control_compress_left(g_editor->control_sel_l, - g_editor->control_sel_r, - seg, pos); + if (!g_editor->control_compress) + seg->prev->right = seg->left = BOUNDS (pos, + seg->prev->middle + EPSILON, + seg->middle - EPSILON); + else + control_compress_left (g_editor->control_sel_l, + g_editor->control_sel_r, + seg, pos); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->left); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->left); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_MIDDLE: - pos = control_calc_g_pos(x); - seg->middle = BOUNDS(pos, seg->left + EPSILON, seg->right - EPSILON); + case GRAD_DRAG_MIDDLE: + pos = control_calc_g_pos (x); + seg->middle = BOUNDS (pos, seg->left + EPSILON, seg->right - EPSILON); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->middle); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->middle); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_ALL: - pos = control_calc_g_pos(x); - delta = pos - g_editor->control_last_gx; + case GRAD_DRAG_ALL: + pos = control_calc_g_pos (x); + delta = pos - g_editor->control_last_gx; - if ((seg->left >= g_editor->control_sel_l->left) && - (seg->right <= g_editor->control_sel_r->right)) - delta = control_move(g_editor->control_sel_l, g_editor->control_sel_r, delta); - else - delta = control_move(seg, seg, delta); + if ((seg->left >= g_editor->control_sel_l->left) && + (seg->right <= g_editor->control_sel_r->right)) + delta = control_move (g_editor->control_sel_l, + g_editor->control_sel_r, delta); + else + delta = control_move (seg, seg, delta); - g_editor->control_last_gx += delta; + g_editor->control_last_gx += delta; - g_snprintf(str, sizeof(str), _("Distance: %0.6f"), - g_editor->control_last_gx - g_editor->control_orig_pos); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Distance: %0.6f"), + g_editor->control_last_gx - g_editor->control_orig_pos); + ed_set_hint (str); - break; + break; - default: - gimp_fatal_error(_("control_motion(): Attempt to move bogus handle %d"), - (int) g_editor->control_drag_mode); - break; - } /* switch */ + default: + gimp_fatal_error (_("control_motion(): Attempt to move bogus handle %d"), + (int) g_editor->control_drag_mode); + break; + } - curr_gradient->dirty = 1; - - if (g_editor->instant_update) - ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); - else - ed_update_editor(GRAD_UPDATE_CONTROL); -} /* control_motion */ + curr_gradient->dirty = 1; + if (g_editor->instant_update) + ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); + else + ed_update_editor (GRAD_UPDATE_CONTROL); +} /*****/ static void -control_compress_left(grad_segment_t *range_l, grad_segment_t *range_r, - grad_segment_t *drag_seg, double pos) +control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, + double pos) { - grad_segment_t *seg; - double lbound, rbound; - int k; + grad_segment_t *seg; + double lbound, rbound; + int k; - /* Check what we have to compress */ + /* Check what we have to compress */ - if (!((drag_seg->left >= range_l->left) && - ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) { - /* We are compressing a segment outside the selection */ + if (!((drag_seg->left >= range_l->left) && + ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) + { + /* We are compressing a segment outside the selection */ - range_l = range_r = drag_seg; - } /* else */ + range_l = range_r = drag_seg; + } - /* Calculate left bound for dragged hadle */ + /* Calculate left bound for dragged hadle */ - if (drag_seg == range_l) - lbound = range_l->prev->left + 2.0 * EPSILON; - else { - /* Count number of segments to the left of the dragged handle */ + if (drag_seg == range_l) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + { + /* Count number of segments to the left of the dragged handle */ - seg = drag_seg; - k = 0; + seg = drag_seg; + k = 0; - while (seg != range_l) { - k++; - seg = seg->prev; - } /* while */ + while (seg != range_l) + { + k++; + seg = seg->prev; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - lbound = range_l->left + 2.0 * k * EPSILON; - } /* else */ + lbound = range_l->left + 2.0 * k * EPSILON; + } - /* Calculate right bound for dragged handle */ + /* Calculate right bound for dragged handle */ - if (drag_seg == range_r->next) - rbound = range_r->next->right - 2.0 * EPSILON; - else { - /* Count number of segments to the right of the dragged handle */ + if (drag_seg == range_r->next) + rbound = range_r->next->right - 2.0 * EPSILON; + else + { + /* Count number of segments to the right of the dragged handle */ - seg = drag_seg; - k = 1; + seg = drag_seg; + k = 1; - while (seg != range_r) { - k++; - seg = seg->next; - } /* while */ + while (seg != range_r) + { + k++; + seg = seg->next; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - rbound = range_r->right - 2.0 * k * EPSILON; - } /* else */ + rbound = range_r->right - 2.0 * k * EPSILON; + } - /* Calculate position */ + /* Calculate position */ - pos = BOUNDS(pos, lbound, rbound); + pos = BOUNDS (pos, lbound, rbound); - /* Compress segments to the left of the handle */ + /* Compress segments to the left of the handle */ - if (drag_seg == range_l) - control_compress_range(range_l->prev, range_l->prev, range_l->prev->left, pos); - else - control_compress_range(range_l, drag_seg->prev, range_l->left, pos); + if (drag_seg == range_l) + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, pos); + else + control_compress_range (range_l, drag_seg->prev, range_l->left, pos); - /* Compress segments to the right of the handle */ - - if (drag_seg != range_r->next) - control_compress_range(drag_seg, range_r, pos, range_r->right); - else - control_compress_range(drag_seg, drag_seg, pos, drag_seg->right); -} /* control_compress_left */ + /* Compress segments to the right of the handle */ + if (drag_seg != range_r->next) + control_compress_range (drag_seg, range_r, pos, range_r->right); + else + control_compress_range (drag_seg, drag_seg, pos, drag_seg->right); +} /*****/ static void -control_compress_range(grad_segment_t *range_l, grad_segment_t *range_r, - double new_l, double new_r) +control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, + double new_r) { - double orig_l, orig_r; - double scale; - grad_segment_t *seg, *aseg; + double orig_l, orig_r; + double scale; + grad_segment_t *seg, *aseg; - orig_l = range_l->left; - orig_r = range_r->right; + orig_l = range_l->left; + orig_r = range_r->right; - scale = (new_r - new_l) / (orig_r - orig_l); + scale = (new_r - new_l) / (orig_r - orig_l); - seg = range_l; + seg = range_l; - do { - seg->left = new_l + (seg->left - orig_l) * scale; - seg->middle = new_l + (seg->middle - orig_l) * scale; - seg->right = new_l + (seg->right - orig_l) * scale; + do + { + seg->left = new_l + (seg->left - orig_l) * scale; + seg->middle = new_l + (seg->middle - orig_l) * scale; + seg->right = new_l + (seg->right - orig_l) * scale; - /* Next */ - - aseg = seg; - seg = seg->next; - } while (aseg != range_r); -} /* control_compress_range */ + /* Next */ + aseg = seg; + seg = seg->next; + } while (aseg != range_r); +} /*****/ static double -control_move(grad_segment_t *range_l, grad_segment_t *range_r, double delta) +control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta) { - double lbound, rbound; - int is_first, is_last; - grad_segment_t *seg, *aseg; + double lbound, rbound; + int is_first, is_last; + grad_segment_t *seg, *aseg; - /* First or last segments in gradient? */ + /* First or last segments in gradient? */ - is_first = (range_l->prev == NULL); - is_last = (range_r->next == NULL); + is_first = (range_l->prev == NULL); + is_last = (range_r->next == NULL); - /* Calculate drag bounds */ + /* Calculate drag bounds */ - if (!g_editor->control_compress) { - if (!is_first) - lbound = range_l->prev->middle + EPSILON; - else - lbound = range_l->left + EPSILON; + if (!g_editor->control_compress) + { + if (!is_first) + lbound = range_l->prev->middle + EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->middle - EPSILON; - else - rbound = range_r->right - EPSILON; - } else { - if (!is_first) - lbound = range_l->prev->left + 2.0 * EPSILON; - else - lbound = range_l->left + EPSILON; + if (!is_last) + rbound = range_r->next->middle - EPSILON; + else + rbound = range_r->right - EPSILON; + } + else + { + if (!is_first) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->right - 2.0 * EPSILON; - else - rbound = range_r->right - EPSILON; - } /* if */ + if (!is_last) + rbound = range_r->next->right - 2.0 * EPSILON; + else + rbound = range_r->right - EPSILON; + } - /* Fix the delta if necessary */ + /* Fix the delta if necessary */ - if (delta < 0.0) { - if (!is_first) { - if (range_l->left + delta < lbound) - delta = lbound - range_l->left; - } else - if (range_l->middle + delta < lbound) - delta = lbound - range_l->middle; - } else { - if (!is_last) { - if (range_r->right + delta > rbound) - delta = rbound - range_r->right; - } else - if (range_r->middle + delta > rbound) - delta = rbound - range_r->middle; - } /* else */ + if (delta < 0.0) + { + if (!is_first) + { + if (range_l->left + delta < lbound) + delta = lbound - range_l->left; + } + else + if (range_l->middle + delta < lbound) + delta = lbound - range_l->middle; + } + else + { + if (!is_last) + { + if (range_r->right + delta > rbound) + delta = rbound - range_r->right; + } + else + if (range_r->middle + delta > rbound) + delta = rbound - range_r->middle; + } - /* Move all the segments inside the range */ + /* Move all the segments inside the range */ - seg = range_l; + seg = range_l; - do { - if (!((seg == range_l) && is_first)) - seg->left += delta; + do + { + if (!((seg == range_l) && is_first)) + seg->left += delta; - seg->middle += delta; + seg->middle += delta; - if (!((seg == range_r) && is_last)) - seg->right += delta; + if (!((seg == range_r) && is_last)) + seg->right += delta; - /* Next */ + /* Next */ - aseg = seg; - seg = seg->next; - } while (aseg != range_r); + aseg = seg; + seg = seg->next; + } + while (aseg != range_r); - /* Fix the segments that surround the range */ + /* Fix the segments that surround the range */ - if (!is_first) - { - if (!g_editor->control_compress) - range_l->prev->right = range_l->left; - else - control_compress_range(range_l->prev, range_l->prev, - range_l->prev->left, range_l->left); - } + if (!is_first) + { + if (!g_editor->control_compress) + range_l->prev->right = range_l->left; + else + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, range_l->left); + } - if (!is_last) - { - if (!g_editor->control_compress) - range_r->next->left = range_r->right; - else - control_compress_range(range_r->next, range_r->next, - range_r->right, range_r->next->right); - } - - return delta; -} /* control_move */ + if (!is_last) + { + if (!g_editor->control_compress) + range_r->next->left = range_r->right; + else + control_compress_range (range_r->next, range_r->next, + range_r->right, range_r->next->right); + } + return delta; +} /*****/ @@ -2990,158 +2981,162 @@ control_update (gboolean recalculate) /*****/ static void -control_draw(GdkPixmap *pixmap, int width, int height, double left, double right) +control_draw (GdkPixmap *pixmap, + int width, + int height, + double left, + double right) { - int sel_l, sel_r; - double g_pos; - grad_segment_t *seg; - control_drag_mode_t handle; + int sel_l, sel_r; + double g_pos; + grad_segment_t *seg; + control_drag_mode_t handle; - /* Clear the pixmap */ + /* Clear the pixmap */ - gdk_draw_rectangle(pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], - TRUE, 0, 0, width, height); + gdk_draw_rectangle (pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], + TRUE, 0, 0, width, height); - /* Draw selection */ + /* Draw selection */ - sel_l = control_calc_p_pos(g_editor->control_sel_l->left); - sel_r = control_calc_p_pos(g_editor->control_sel_r->right); + sel_l = control_calc_p_pos (g_editor->control_sel_l->left); + sel_r = control_calc_p_pos (g_editor->control_sel_r->right); - gdk_draw_rectangle(pixmap, g_editor->control->style->dark_gc[GTK_STATE_NORMAL], - TRUE, sel_l, 0, sel_r - sel_l + 1, height); + gdk_draw_rectangle (pixmap, + g_editor->control->style->dark_gc[GTK_STATE_NORMAL], + TRUE, sel_l, 0, sel_r - sel_l + 1, height); - /* Draw handles */ + /* Draw handles */ - seg = curr_gradient->segments; + seg = curr_gradient->segments; - while (seg) { - control_draw_normal_handle(pixmap, seg->left, height); - control_draw_middle_handle(pixmap, seg->middle, height); + while (seg) + { + control_draw_normal_handle (pixmap, seg->left, height); + control_draw_middle_handle (pixmap, seg->middle, height); - /* Draw right handle only if this is the last segment */ + /* Draw right handle only if this is the last segment */ - if (seg->next == NULL) - control_draw_normal_handle(pixmap, seg->right, height); + if (seg->next == NULL) + control_draw_normal_handle (pixmap, seg->right, height); - /* Next! */ + /* Next! */ - seg = seg->next; - } /* while */ + seg = seg->next; + } - /* Draw the handle which is closest to the mouse position */ + /* Draw the handle which is closest to the mouse position */ - g_pos = control_calc_g_pos(g_editor->control_last_x); + g_pos = control_calc_g_pos (g_editor->control_last_x); - seg_get_closest_handle(curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); + seg_get_closest_handle (curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - control_draw_normal_handle(pixmap, seg->left, height); - else { - seg = seg_get_last_segment(curr_gradient->segments); - control_draw_normal_handle(pixmap, seg->right, height); - } /* else */ + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + control_draw_normal_handle (pixmap, seg->left, height); + else + { + seg = seg_get_last_segment (curr_gradient->segments); + control_draw_normal_handle (pixmap, seg->right, height); + } - break; + break; - case GRAD_DRAG_MIDDLE: - control_draw_middle_handle(pixmap, seg->middle, height); - break; - - default: - break; - } /* switch */ -} /* control_draw */ + case GRAD_DRAG_MIDDLE: + control_draw_middle_handle (pixmap, seg->middle, height); + break; + default: + break; + } +} /*****/ static void -control_draw_normal_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_normal_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->black_gc, - control_calc_p_pos(pos), height); -} /* control_draw_normal_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->black_gc, + control_calc_p_pos (pos), height); +} static void -control_draw_middle_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_middle_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], - control_calc_p_pos(pos), height); -} /* control_draw_middle_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], + control_calc_p_pos(pos), height); +} static void -control_draw_handle(GdkPixmap *pixmap, GdkGC *border_gc, GdkGC *fill_gc, int xpos, int height) +control_draw_handle (GdkPixmap *pixmap, + GdkGC *border_gc, + GdkGC *fill_gc, + int xpos, + int height) { - int y; - int left, right, bottom; + int y; + int left, right, bottom; - for (y = 0; y < height; y++) - gdk_draw_line(pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); + for (y = 0; y < height; y++) + gdk_draw_line (pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); - bottom = height - 1; - left = xpos - bottom / 2; - right = xpos + bottom / 2; - - gdk_draw_line(pixmap, border_gc, xpos, 0, left, bottom); - gdk_draw_line(pixmap, border_gc, xpos, 0, right, bottom); - gdk_draw_line(pixmap, border_gc, left, bottom, right, bottom); -} /* control_draw_handle */ + bottom = height - 1; + left = xpos - bottom / 2; + right = xpos + bottom / 2; + gdk_draw_line (pixmap, border_gc, xpos, 0, left, bottom); + gdk_draw_line (pixmap, border_gc, xpos, 0, right, bottom); + gdk_draw_line (pixmap, border_gc, left, bottom, right, bottom); +} /*****/ static int -control_calc_p_pos(double pos) +control_calc_p_pos (double pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the position (in widget's coordinates) of the - * requested point from the gradient. Rounding is done to - * minimize mismatches between the rendered gradient preview - * and the gradient control's handles. - */ + /* Calculate the position (in widget's coordinates) of the + * requested point from the gradient. Rounding is done to + * minimize mismatches between the rendered gradient preview + * and the gradient control's handles. + */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); -} /* control_calc_p_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); +} /*****/ static double -control_calc_g_pos(int pos) +control_calc_g_pos (int pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the gradient position that corresponds to widget's coordinates */ + /* Calculate the gradient position that corresponds to widget's coordinates */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; -} /* control_calc_g_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; +} /***** Control popup functions *****/ -/*****/ - static void cpopup_create_main_menu (void) { @@ -3350,8 +3345,6 @@ cpopup_do_popup (void) /***** Create a single menu item *****/ -/*****/ - static GtkWidget * cpopup_create_color_item (GtkWidget **color_box, GtkWidget **label) @@ -3416,8 +3409,6 @@ cpopup_create_menu_item_with_label (gchar *str, /***** Update all menus *****/ -/*****/ - static void cpopup_adjust_menus (void) { @@ -3677,79 +3668,87 @@ cpopup_check_selection_params (gint *equal_blending, /*****/ static void -cpopup_render_color_box(GtkPreview *preview, double r, double g, double b, double a) +cpopup_render_color_box (GtkPreview *preview, + double r, + double g, + double b, + double a) { - guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; - int x, y; - int r0, g0, b0; - int r1, g1, b1; - guchar *p0, *p1, *p2; + guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; + int x, y; + int r0, g0, b0; + int r1, g1, b1; + guchar *p0, *p1, *p2; - /* Fill rows */ + /* Fill rows */ - r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; - r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; + r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; + r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; - g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; - g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; + g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; + g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; - b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; - b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; + b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; + b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; - p0 = rows[0]; - p1 = rows[1]; - p2 = rows[2]; + p0 = rows[0]; + p1 = rows[1]; + p2 = rows[2]; - for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) { - if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) { - *p0++ = 0; - *p0++ = 0; - *p0++ = 0; + for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) + { + if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) + { + *p0++ = 0; + *p0++ = 0; + *p0++ = 0; - *p1++ = 0; - *p1++ = 0; - *p1++ = 0; - } else - if ((x / GRAD_CHECK_SIZE) & 1) { - *p0++ = r1; - *p0++ = g1; - *p0++ = b1; + *p1++ = 0; + *p1++ = 0; + *p1++ = 0; + } + else + if ((x / GRAD_CHECK_SIZE) & 1) + { + *p0++ = r1; + *p0++ = g1; + *p0++ = b1; - *p1++ = r0; - *p1++ = g0; - *p1++ = b0; - } else { - *p0++ = r0; - *p0++ = g0; - *p0++ = b0; + *p1++ = r0; + *p1++ = g0; + *p1++ = b0; + } + else + { + *p0++ = r0; + *p0++ = g0; + *p0++ = b0; - *p1++ = r1; - *p1++ = g1; - *p1++ = b1; - } /* else */ + *p1++ = r1; + *p1++ = g1; + *p1++ = b1; + } - *p2++ = 0; - *p2++ = 0; - *p2++ = 0; - } /* for */ + *p2++ = 0; + *p2++ = 0; + *p2++ = 0; + } - /* Fill preview */ + /* Fill preview */ - gtk_preview_draw_row(preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); + gtk_preview_draw_row (preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); - for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); - else - gtk_preview_draw_row(preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); + for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); + else + gtk_preview_draw_row (preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); - gtk_preview_draw_row(preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); -} /* cpopup_render_color_box */ + gtk_preview_draw_row (preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); +} /***** Creale load & save menus *****/ -/*****/ - static GtkWidget * cpopup_create_load_menu (GtkWidget **color_boxes, GtkWidget **labels, @@ -3824,8 +3823,8 @@ cpopup_create_load_menu (GtkWidget **color_boxes, } static GtkWidget * -cpopup_create_save_menu (GtkWidget **color_boxes, - GtkWidget **labels, +cpopup_create_save_menu (GtkWidget **color_boxes, + GtkWidget **labels, GtkSignalFunc callback) { GtkWidget *menu; @@ -3846,324 +3845,328 @@ cpopup_create_save_menu (GtkWidget **color_boxes, return menu; } +/*****/ + +static void +cpopup_update_saved_color (int n, + double r, + double g, + double b, + double a) +{ + char str[256]; + + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_save_color_boxes[n]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_save_color_boxes[n]), + r, g, b, a); + + g_snprintf (str, sizeof (str), + _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + + gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + + g_editor->saved_colors[n].r = r; + g_editor->saved_colors[n].g = g; + g_editor->saved_colors[n].b = b; + g_editor->saved_colors[n].a = a; +} /*****/ static void -cpopup_update_saved_color(int n, double r, double g, double b, double a) +cpopup_load_left_callback (GtkWidget *widget, + gpointer data) { - char str[256]; + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_save_color_boxes[n]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_save_color_boxes[n]), - r, g, b, a); + switch ((long) data) + { + case 0: /* Fetch from left neighbor's right endpoint */ + if (g_editor->control_sel_l->prev != NULL) + seg = g_editor->control_sel_l->prev; + else + seg = seg_get_last_segment (g_editor->control_sel_l); - g_snprintf(str, sizeof(str), _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + cpopup_blend_endpoints (seg->r1, seg->g1, seg->b1, seg->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + case 1: /* Fetch from right endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - g_editor->saved_colors[n].r = r; - g_editor->saved_colors[n].g = g; - g_editor->saved_colors[n].b = b; - g_editor->saved_colors[n].a = a; -} /* cpopup_update_saved_color */ + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (fg_r, + fg_g, + fg_b, + fg_a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_left_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; +} + +static void +cpopup_load_right_callback (GtkWidget *widget, + gpointer data) +{ + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; + + switch ((long) data) + { + case 0: /* Fetch from right neighbor's left endpoint */ + if (g_editor->control_sel_r->next != NULL) + seg = g_editor->control_sel_r->next; + else + seg = curr_gradient->segments; + + cpopup_blend_endpoints (g_editor->control_sel_r->r0, + g_editor->control_sel_r->g0, + g_editor->control_sel_r->b0, + g_editor->control_sel_r->a0, + seg->r0, seg->g0, seg->b0, seg->a0, + TRUE, TRUE); + break; + + case 1: /* Fetch from left endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + TRUE, TRUE); + break; + + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + fg_r, + fg_g, + fg_b, + fg_a, + TRUE, TRUE); + break; + + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_right_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; +} /*****/ static void -cpopup_load_left_callback(GtkWidget *widget, gpointer data) +cpopup_set_color_selection_color (GtkColorSelection *cs, + double r, + double g, + double b, + double a) { - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; + gdouble color[4]; - switch ((long) data) { - case 0: /* Fetch from left neighbor's right endpoint */ - if (g_editor->control_sel_l->prev != NULL) - seg = g_editor->control_sel_l->prev; - else - seg = seg_get_last_segment(g_editor->control_sel_l); - - cpopup_blend_endpoints(seg->r1, seg->g1, seg->b1, seg->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 1: /* Fetch from right endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(fg_r, - fg_g, - fg_b, - fg_a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_left_callback */ + color[0] = r; + color[1] = g; + color[2] = b; + color[3] = a; + gtk_color_selection_set_color (cs, color); +} /*****/ static void -cpopup_save_left_callback(GtkWidget *widget, gpointer data) +cpopup_get_color_selection_color (GtkColorSelection *cs, + double *r, + double *g, + double *b, + double *a) { - g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; -} /* cpopup_save_left_callback */ + gdouble color[4]; + gtk_color_selection_get_color (cs, color); -/*****/ - -static void -cpopup_load_right_callback(GtkWidget *widget, gpointer data) -{ - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; - - switch ((long) data) { - case 0: /* Fetch from right neighbor's left endpoint */ - if (g_editor->control_sel_r->next != NULL) - seg = g_editor->control_sel_r->next; - else - seg = curr_gradient->segments; - - cpopup_blend_endpoints(g_editor->control_sel_r->r0, - g_editor->control_sel_r->g0, - g_editor->control_sel_r->b0, - g_editor->control_sel_r->a0, - seg->r0, seg->g0, seg->b0, seg->a0, - TRUE, TRUE); - break; - - case 1: /* Fetch from left endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - fg_r, - fg_g, - fg_b, - fg_a, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_right_callback */ - - -/*****/ - -static void -cpopup_save_right_callback(GtkWidget *widget, gpointer data) -{ - g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; -} /* cpopup_save_right_callback */ - - -/*****/ - -static void -cpopup_set_color_selection_color(GtkColorSelection *cs, - double r, double g, double b, double a) -{ - gdouble color[4]; - - color[0] = r; - color[1] = g; - color[2] = b; - color[3] = a; - - gtk_color_selection_set_color(cs, color); -} /* cpopup_set_color_selection_color */ - - -/*****/ - -static void -cpopup_get_color_selection_color(GtkColorSelection *cs, - double *r, double *g, double *b, double *a) -{ - gdouble color[4]; - - gtk_color_selection_get_color(cs, color); - - *r = color[0]; - *g = color[1]; - *b = color[2]; - *a = color[3]; -} /* cpopup_get_color_selection_color */ - + *r = color[0]; + *g = color[1]; + *b = color[2]; + *a = color[3]; +} /*****/ static grad_segment_t * -cpopup_save_selection(void) +cpopup_save_selection (void) { - grad_segment_t *seg, *prev, *tmp; - grad_segment_t *oseg, *oaseg; + grad_segment_t *seg, *prev, *tmp; + grad_segment_t *oseg, *oaseg; - prev = NULL; - oseg = g_editor->control_sel_l; - tmp = NULL; + prev = NULL; + oseg = g_editor->control_sel_l; + tmp = NULL; - do { - seg = seg_new_segment(); + do + { + seg = seg_new_segment (); - *seg = *oseg; /* Copy everything */ + *seg = *oseg; /* Copy everything */ - if (prev == NULL) - tmp = seg; /* Remember first segment */ - else - prev->next = seg; + if (prev == NULL) + tmp = seg; /* Remember first segment */ + else + prev->next = seg; - seg->prev = prev; - seg->next = NULL; + seg->prev = prev; + seg->next = NULL; - prev = seg; - oaseg = oseg; - oseg = oseg->next; - } while (oaseg != g_editor->control_sel_r); - - return tmp; -} /* cpopup_save_selection */ + prev = seg; + oaseg = oseg; + oseg = oseg->next; + } + while (oaseg != g_editor->control_sel_r); + return tmp; +} /*****/ static void -cpopup_free_selection(grad_segment_t *seg) +cpopup_free_selection (grad_segment_t *seg) { - seg_free_segments(seg); -} /* cpopup_free_selection */ - + seg_free_segments (seg); +} /*****/ static void -cpopup_replace_selection(grad_segment_t *replace_seg) +cpopup_replace_selection (grad_segment_t *replace_seg) { - grad_segment_t *lseg, *rseg; - grad_segment_t *replace_last; + grad_segment_t *lseg, *rseg; + grad_segment_t *replace_last; - /* Remember left and right segments */ + /* Remember left and right segments */ - lseg = g_editor->control_sel_l->prev; - rseg = g_editor->control_sel_r->next; + lseg = g_editor->control_sel_l->prev; + rseg = g_editor->control_sel_r->next; - replace_last = seg_get_last_segment(replace_seg); + replace_last = seg_get_last_segment (replace_seg); - /* Free old selection */ + /* Free old selection */ - g_editor->control_sel_r->next = NULL; + g_editor->control_sel_r->next = NULL; - seg_free_segments(g_editor->control_sel_l); + seg_free_segments (g_editor->control_sel_l); - /* Link in new segments */ + /* Link in new segments */ - if (lseg) - lseg->next = replace_seg; - else - curr_gradient->segments = replace_seg; + if (lseg) + lseg->next = replace_seg; + else + curr_gradient->segments = replace_seg; - replace_seg->prev = lseg; + replace_seg->prev = lseg; - if (rseg) - rseg->prev = replace_last; + if (rseg) + rseg->prev = replace_last; - replace_last->next = rseg; + replace_last->next = rseg; - g_editor->control_sel_l = replace_seg; - g_editor->control_sel_r = replace_last; + g_editor->control_sel_l = replace_seg; + g_editor->control_sel_r = replace_last; - curr_gradient->last_visited = NULL; /* Force re-search */ -} /* cpopup_replace_selection */ + curr_gradient->last_visited = NULL; /* Force re-search */ +} /***** Color dialogs for left and right endpoint *****/ -/*****/ - static void -cpopup_create_color_dialog (gchar *title, - double r, double g, double b, double a, - GtkSignalFunc color_changed_callback, - GtkSignalFunc ok_callback, - GtkSignalFunc cancel_callback, - GtkSignalFunc delete_callback) +cpopup_create_color_dialog (gchar *title, + double r, + double g, + double b, + double a, + GtkSignalFunc color_changed_callback, + GtkSignalFunc ok_callback, + GtkSignalFunc cancel_callback, + GtkSignalFunc delete_callback) { GtkWidget *window; GtkColorSelection *cs; @@ -4360,8 +4363,6 @@ cpopup_right_color_dialog_delete (GtkWidget *widget, /***** Blending menu *****/ -/*****/ - static GtkWidget * cpopup_create_blending_menu (void) { @@ -4432,8 +4433,6 @@ cpopup_blending_callback (GtkWidget *widget, /***** Coloring menu *****/ -/*****/ - static GtkWidget * cpopup_create_coloring_menu (void) { @@ -4593,26 +4592,23 @@ cpopup_split_uniform_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Split"), cpopup_split_uniform_split_callback, NULL, NULL }, - { N_("Cancel"), cpopup_split_uniform_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_segment_split_uniformly", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Split segment uniformly") : - _("Split segments uniformly")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Split segment uniformly") : + _("Split segments uniformly"), + "gradient_segment_split_uniformly", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_split_uniform_delete_callback), - dialog); + _("Split"), cpopup_split_uniform_split_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), cpopup_split_uniform_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -4646,11 +4642,6 @@ cpopup_split_uniform_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_split_uniform_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 0); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -4704,16 +4695,6 @@ cpopup_split_uniform_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_split_uniform_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_split_uniform_cancel_callback (widget, data); - - return TRUE; -} - static void cpopup_split_uniform (grad_segment_t *lseg, int parts, @@ -4958,8 +4939,6 @@ cpopup_redistribute_callback (GtkWidget *widget, /***** Control popup -> selection options functions *****/ -/*****/ - static GtkWidget * cpopup_create_sel_ops_menu (void) { @@ -5172,26 +5151,23 @@ cpopup_replicate_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Replicate"), cpopup_do_replicate_callback, NULL, NULL }, - { N_("Cancel"), cpopup_replicate_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), - "gradient_segment_replicate", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Replicate segment") : - _("Replicate selection")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Replicate segment") : + _("Replicate selection"), + "gradient_segment_replicate", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_replicate_delete_callback), - dialog); + _("Replicate"), cpopup_do_replicate_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), cpopup_replicate_cancel_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); @@ -5223,11 +5199,6 @@ cpopup_replicate_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_replicate_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -5370,16 +5341,6 @@ cpopup_replicate_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_replicate_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_replicate_cancel_callback (widget, data); - - return TRUE; -} - /*****/ static void @@ -5420,8 +5381,6 @@ cpopup_blend_opacity (GtkWidget *widget, /***** Main blend function *****/ -/*****/ - static void cpopup_blend_endpoints (double r0, double g0, double b0, double a0, double r1, double g1, double b1, double a1, @@ -5469,645 +5428,671 @@ cpopup_blend_endpoints (double r0, double g0, double b0, double a0, /***** Gradient functions *****/ -/*****/ - static gradient_t * -grad_new_gradient(void) +grad_new_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = g_malloc(sizeof(gradient_t)); + grad = g_new (gradient_t, 1); - grad->name = NULL; - grad->segments = NULL; - grad->last_visited = NULL; - grad->dirty = 0; - grad->filename = NULL; - grad->pixmap = NULL; + grad->name = NULL; + grad->segments = NULL; + grad->last_visited = NULL; + grad->dirty = 0; + grad->filename = NULL; + grad->pixmap = NULL; - return grad; -} /* grad_new_gradient */ - - -/*****/ - -static void -grad_free_gradient(gradient_t *grad) -{ - g_assert(grad != NULL); - - if (grad->name) - g_free(grad->name); - - if (grad->segments) - seg_free_segments(grad->segments); - - if (grad->filename) - g_free(grad->filename); - - g_free(grad); -} /* grad_free_gradient */ - - -/*****/ - -static void -grad_save_all(int need_free) -{ - GSList *node; - gradient_t *grad; - - node = gradients_list; - - while (node) { - grad = node->data; - - /* If gradient has dirty flag set, save it */ - - if (grad->dirty) - grad_save_gradient(grad, grad->filename); - - if(need_free) - grad_free_gradient(grad); - - node = g_slist_next(node); - } /* while */ + return grad; } /*****/ static void -grad_free_gradients(void) +grad_free_gradient (gradient_t *grad) { - grad_save_all(1); + g_assert (grad != NULL); + + if (grad->name) + g_free (grad->name); + + if (grad->segments) + seg_free_segments (grad->segments); + + if (grad->filename) + g_free (grad->filename); + + g_free (grad); +} + +/*****/ + +static void +grad_save_all (int need_free) +{ + GSList *node; + gradient_t *grad; + + node = gradients_list; + + while (node) + { + grad = node->data; + + /* If gradient has dirty flag set, save it */ + if (grad->dirty) + grad_save_gradient (grad, grad->filename); + + if (need_free) + grad_free_gradient (grad); + + node = g_slist_next (node); + } +} + +/*****/ + +static void +grad_free_gradients (void) +{ + grad_save_all (1); - g_slist_free(gradients_list); - - num_gradients = 0; - gradients_list = NULL; - curr_gradient = NULL; -} /* grad_free_gradients */ + g_slist_free (gradients_list); + num_gradients = 0; + gradients_list = NULL; + curr_gradient = NULL; +} /*****/ static void -grad_load_gradient(char *filename) +grad_load_gradient (char *filename) { - FILE *file; - gradient_t *grad; - grad_segment_t *seg, *prev; - int num_segments; - int i; - int type, color; - char line[1024]; + FILE *file; + gradient_t *grad; + grad_segment_t *seg, *prev; + int num_segments; + int i; + int type, color; + char line[1024]; - g_assert(filename != NULL); + g_assert (filename != NULL); - file = fopen(filename, "rb"); - if (!file) - return; + file = fopen (filename, "rb"); + if (!file) + return; - fgets(line, 1024, file); - if (strcmp(line, "GIMP Gradient\n") != 0) - return; + fgets (line, 1024, file); + if (strcmp (line, "GIMP Gradient\n") != 0) + return; - grad = grad_new_gradient(); + grad = grad_new_gradient (); - grad->filename = g_strdup(filename); - grad->name = g_strdup(g_basename(filename)); + grad->filename = g_strdup (filename); + grad->name = g_strdup (g_basename (filename)); - fgets(line, 1024, file); - num_segments = atoi(line); + fgets (line, 1024, file); + num_segments = atoi (line); - if (num_segments < 1) { - g_message (_("grad_load_gradient(): invalid number of segments in \"%s\""), filename); - g_free(grad); - return; - } /* if */ + if (num_segments < 1) + { + g_message (_("grad_load_gradient(): " + "invalid number of segments in \"%s\""), filename); + g_free (grad); + return; + } - prev = NULL; + prev = NULL; - for (i = 0; i < num_segments; i++) { - seg = seg_new_segment(); - seg->prev = prev; + for (i = 0; i < num_segments; i++) + { + seg = seg_new_segment (); + seg->prev = prev; - if (prev) - prev->next = seg; - else - grad->segments = seg; + if (prev) + prev->next = seg; + else + grad->segments = seg; - fgets(line, 1024, file); + fgets (line, 1024, file); - if (sscanf(line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", - &(seg->left), &(seg->middle), &(seg->right), - &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), - &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), - &type, &color) != 13) { - g_message (_("grad_load_gradient(): badly formatted " - "gradient segment %d in \"%s\" --- bad things may " - "happen soon"), i, filename); - } else { - seg->type = (grad_type_t) type; - seg->color = (grad_color_t) color; - } /* else */ + if (sscanf (line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", + &(seg->left), &(seg->middle), &(seg->right), + &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), + &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), + &type, &color) != 13) + { + g_message (_("grad_load_gradient(): badly formatted " + "gradient segment %d in \"%s\" --- bad things may " + "happen soon"), i, filename); + } + else + { + seg->type = (grad_type_t) type; + seg->color = (grad_color_t) color; + } - prev = seg; - } /* for */ + prev = seg; + } - fclose(file); + fclose (file); - grad_insert_in_gradients_list(grad); - - /* Check if this gradient is the default one */ - - if (strcmp(default_gradient, grad->name) == 0) - grad_default_gradient = grad; -} /* grad_load_gradient */ + grad_insert_in_gradients_list (grad); + /* Check if this gradient is the default one */ + if (strcmp (default_gradient, grad->name) == 0) + grad_default_gradient = grad; +} /*****/ static void -grad_save_gradient(gradient_t *grad, char *filename) +grad_save_gradient (gradient_t *grad, + char *filename) { - FILE *file; - int num_segments; - grad_segment_t *seg; + FILE *file; + int num_segments; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert (grad != NULL); - if (!filename) { - g_message (_("grad_save_gradient(): can not save gradient with NULL filename")); - return; - } /* if */ + if (!filename) + { + g_message (_("grad_save_gradient(): " + "can not save gradient with NULL filename")); + return; + } - file = fopen(filename, "wb"); - if (!file) { - g_message (_("grad_save_gradient(): can't open \"%s\""), filename); - return; - } /* if */ + file = fopen (filename, "wb"); + if (!file) + { + g_message (_("grad_save_gradient(): can't open \"%s\""), filename); + return; + } - /* File format is: - * - * GIMP Gradient - * number_of_segments - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * ... - */ + /* File format is: + * + * GIMP Gradient + * number_of_segments + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * ... + */ - fprintf(file, "GIMP Gradient\n"); + fprintf (file, "GIMP Gradient\n"); - /* Count number of segments */ + /* Count number of segments */ + num_segments = 0; + seg = grad->segments; - num_segments = 0; - seg = grad->segments; + while (seg) + { + num_segments++; + seg = seg->next; + } - while (seg) { - num_segments++; - seg = seg->next; - } /* while */ + /* Write rest of file */ + fprintf (file, "%d\n", num_segments); - /* Write rest of file */ + for (seg = grad->segments; seg; seg = seg->next) + fprintf (file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, (int) seg->color); - fprintf(file, "%d\n", num_segments); - - for (seg = grad->segments; seg; seg = seg->next) - fprintf(file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, (int) seg->color); - - fclose(file); - - grad->dirty = 0; -} /* grad_save_gradient */ + fclose(file); + grad->dirty = 0; +} /*****/ static gradient_t * -grad_create_default_gradient(void) +grad_create_default_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = grad_new_gradient(); - grad->segments = seg_new_segment(); - - return grad; -} /* grad_create_default_gradient */ + grad = grad_new_gradient(); + grad->segments = seg_new_segment (); + return grad; +} /*****/ static int -grad_insert_in_gradients_list(gradient_t *grad) +grad_insert_in_gradients_list (gradient_t *grad) { - GSList *tmp; - gradient_t *g; - int n; + GSList *tmp; + gradient_t *g; + int n; - /* We insert gradients in alphabetical order. Find the index - * of the gradient after which we will insert the current one. - */ + /* We insert gradients in alphabetical order. Find the index + * of the gradient after which we will insert the current one. + */ - n = 0; - tmp = gradients_list; + n = 0; + tmp = gradients_list; - while (tmp) { - g = tmp->data; + while (tmp) + { + g = tmp->data; - if (strcmp(grad->name, g->name) <= 0) - break; /* We found the one we want */ + if (strcmp (grad->name, g->name) <= 0) + break; /* We found the one we want */ - n++; - tmp = g_slist_next(tmp); - } /* while */ + n++; + tmp = g_slist_next (tmp); + } - num_gradients++; - gradients_list = g_slist_insert(gradients_list, grad, n); - - return n; -} /* grad_insert_in_gradients_list */ + num_gradients++; + gradients_list = g_slist_insert (gradients_list, grad, n); + return n; +} /*****/ static void -grad_dump_gradient(gradient_t *grad, FILE *file) +grad_dump_gradient (gradient_t *grad, + FILE *file) { - grad_segment_t *seg; + grad_segment_t *seg; - fprintf(file, "Name: \"%s\"\n", grad->name); - fprintf(file, "Dirty: %d\n", grad->dirty); - fprintf(file, "Filename: \"%s\"\n", grad->filename); + fprintf (file, "Name: \"%s\"\n", grad->name); + fprintf (file, "Dirty: %d\n", grad->dirty); + fprintf (file, "Filename: \"%s\"\n", grad->filename); - seg = grad->segments; + seg = grad->segments; - while (seg) { - fprintf(file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", - (seg == grad->last_visited) ? '>' : ' ', - seg, - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, - (int) seg->color, - seg->prev, seg->next); - - seg = seg->next; - } /* while */ -} /* grad_dump_gradient */ + while (seg) + { + fprintf (file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", + (seg == grad->last_visited) ? '>' : ' ', + seg, + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, + (int) seg->color, + seg->prev, seg->next); + seg = seg->next; + } +} /***** Segment functions *****/ -/*****/ - static grad_segment_t * -seg_new_segment(void) +seg_new_segment (void) { - grad_segment_t *seg; + grad_segment_t *seg; - seg = g_malloc(sizeof(grad_segment_t)); + seg = g_new (grad_segment_t, 1); - seg->left = 0.0; - seg->middle = 0.5; - seg->right = 1.0; + seg->left = 0.0; + seg->middle = 0.5; + seg->right = 1.0; - seg->r0 = seg->g0 = seg->b0 = 0.0; - seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; + seg->r0 = seg->g0 = seg->b0 = 0.0; + seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; - seg->type = GRAD_LINEAR; - seg->color = GRAD_RGB; + seg->type = GRAD_LINEAR; + seg->color = GRAD_RGB; - seg->prev = seg->next = NULL; - - return seg; -} /* seg_new_segment */ + seg->prev = seg->next = NULL; + return seg; +} /*****/ static void -seg_free_segment(grad_segment_t *seg) +seg_free_segment (grad_segment_t *seg) { - g_assert(seg != NULL); - - g_free(seg); -} /* seg_free_segment */ + g_assert (seg != NULL); + g_free (seg); +} /*****/ static void -seg_free_segments(grad_segment_t *seg) +seg_free_segments (grad_segment_t *seg) { - grad_segment_t *tmp; + grad_segment_t *tmp; - g_assert(seg != NULL); - - while (seg) { - tmp = seg->next; - seg_free_segment(seg); - seg = tmp; - } /* while */ -} /* seg_free_segments */ + g_assert (seg != NULL); + while (seg) + { + tmp = seg->next; + seg_free_segment(seg); + seg = tmp; + } +} /*****/ static grad_segment_t * -seg_get_segment_at(gradient_t *grad, double pos) +seg_get_segment_at (gradient_t *grad, + double pos) { - grad_segment_t *seg; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert(grad != NULL); - pos = BOUNDS(pos, 0.0, 1.0); /* to handle FP imprecision at the edges of the gradient */ + /* handle FP imprecision at the edges of the gradient */ + pos = BOUNDS (pos, 0.0, 1.0); - if (grad->last_visited) - seg = grad->last_visited; - else - seg = grad->segments; + if (grad->last_visited) + seg = grad->last_visited; + else + seg = grad->segments; - while (seg) - if (pos >= seg->left) { - if (pos <= seg->right) { - grad->last_visited = seg; /* for speed */ - return seg; - } else - seg = seg->next; - } else - seg = seg->prev; + while (seg) + { + if (pos >= seg->left) + { + if (pos <= seg->right) + { + grad->last_visited = seg; /* for speed */ + return seg; + } + else + { + seg = seg->next; + } + } + else + { + seg = seg->prev; + } + } - /* Oops: we should have found a segment, but we didn't */ - - grad_dump_gradient(curr_gradient, stderr); - gimp_fatal_error (_("seg_get_segment_at(): No matching segment for position %0.15f"), pos); - return NULL; /* To shut up -Wall */ -} /* seg_get_segment_at */ + /* Oops: we should have found a segment, but we didn't */ + grad_dump_gradient (curr_gradient, stderr); + gimp_fatal_error (_("seg_get_segment_at(): " + "No matching segment for position %0.15f"), pos); + return NULL; /* To shut up -Wall */ +} /*****/ static grad_segment_t * -seg_get_last_segment(grad_segment_t *seg) +seg_get_last_segment (grad_segment_t *seg) { - if (!seg) - return NULL; + if (!seg) + return NULL; - while (seg->next) - seg = seg->next; - - return seg; -} /* seg_get_last_segment */ + while (seg->next) + seg = seg->next; + return seg; +} /*****/ static void -seg_get_closest_handle(gradient_t *grad, double pos, - grad_segment_t **seg, control_drag_mode_t *handle) +seg_get_closest_handle (gradient_t *grad, + double pos, + grad_segment_t **seg, + control_drag_mode_t *handle) { - double l_delta, m_delta, r_delta; + double l_delta, m_delta, r_delta; - *seg = seg_get_segment_at(grad, pos); + *seg = seg_get_segment_at (grad, pos); - m_delta = fabs(pos - (*seg)->middle); + m_delta = fabs (pos - (*seg)->middle); - if (pos < (*seg)->middle) { - l_delta = fabs(pos - (*seg)->left); + if (pos < (*seg)->middle) + { + l_delta = fabs (pos - (*seg)->left); - if (l_delta < m_delta) - *handle = GRAD_DRAG_LEFT; - else - *handle = GRAD_DRAG_MIDDLE; - } else { - r_delta = fabs(pos - (*seg)->right); - - if (m_delta < r_delta) - *handle = GRAD_DRAG_MIDDLE; - else { - *seg = (*seg)->next; - *handle = GRAD_DRAG_LEFT; - } /* else */ - } /* else */ -} /* seg_get_closest_handle */ + if (l_delta < m_delta) + *handle = GRAD_DRAG_LEFT; + else + *handle = GRAD_DRAG_MIDDLE; + } + else + { + r_delta = fabs (pos - (*seg)->right); + if (m_delta < r_delta) + { + *handle = GRAD_DRAG_MIDDLE; + } + else + { + *seg = (*seg)->next; + *handle = GRAD_DRAG_LEFT; + } + } +} /***** Calculation functions *****/ -/*****/ - static double -calc_linear_factor(double middle, double pos) +calc_linear_factor (double middle, + double pos) { - if (pos <= middle) { - if (middle < EPSILON) - return 0.0; - else - return 0.5 * pos / middle; - } else { - pos -= middle; - middle = 1.0 - middle; - - if (middle < EPSILON) - return 1.0; - else - return 0.5 + 0.5 * pos / middle; - } /* else */ -} /* calc_linear_factor */ + if (pos <= middle) + { + if (middle < EPSILON) + return 0.0; + else + return 0.5 * pos / middle; + } + else + { + pos -= middle; + middle = 1.0 - middle; + if (middle < EPSILON) + return 1.0; + else + return 0.5 + 0.5 * pos / middle; + } +} /*****/ static double -calc_curved_factor(double middle, double pos) +calc_curved_factor (double middle, + double pos) { - if (middle < EPSILON) - middle = EPSILON; - - return pow(pos, log(0.5) / log(middle)); -} /* calc_curved_factor */ + if (middle < EPSILON) + middle = EPSILON; + return pow(pos, log (0.5) / log (middle)); +} /*****/ static double -calc_sine_factor(double middle, double pos) +calc_sine_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return (sin((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; -} /* calc_sine_factor */ + pos = calc_linear_factor (middle, pos); + return (sin ((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; +} /*****/ static double -calc_sphere_increasing_factor(double middle, double pos) +calc_sphere_increasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos) - 1.0; - - return sqrt(1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ -} /* calc_sphere_increasing_factor */ + pos = calc_linear_factor (middle, pos) - 1.0; + return sqrt (1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ +} /*****/ static double -calc_sphere_decreasing_factor(double middle, double pos) +calc_sphere_decreasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ -} /* calc_sphere_decreasing_factor */ + pos = calc_linear_factor (middle, pos); + return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ +} /*****/ static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, + double *g, + double *b) { - double red, green, blue; - double h, s, v; - double min, max; - double delta; + double red, green, blue; + double h, s, v; + double min, max; + double delta; - red = *r; - green = *g; - blue = *b; + red = *r; + green = *g; + blue = *b; - h = 0.0; /* Shut up -Wall */ + h = 0.0; /* Shut up -Wall */ - if (red > green) { - if (red > blue) - max = red; - else - max = blue; + if (red > green) + { + if (red > blue) + max = red; + else + max = blue; - if (green < blue) - min = green; - else - min = blue; - } else { - if (green > blue) - max = green; - else - max = blue; + if (green < blue) + min = green; + else + min = blue; + } + else + { + if (green > blue) + max = green; + else + max = blue; - if (red < blue) - min = red; - else - min = blue; - } /* else */ + if (red < blue) + min = red; + else + min = blue; + } - v = max; + v = max; - if (max != 0.0) - s = (max - min) / max; - else - s = 0.0; + if (max != 0.0) + s = (max - min) / max; + else + s = 0.0; - if (s == 0.0) - h = 0.0; - else { - delta = max - min; + if (s == 0.0) + { + h = 0.0; + } + else + { + delta = max - min; - if (red == max) - h = (green - blue) / delta; - else if (green == max) - h = 2 + (blue - red) / delta; - else if (blue == max) - h = 4 + (red - green) / delta; + if (red == max) + h = (green - blue) / delta; + else if (green == max) + h = 2 + (blue - red) / delta; + else if (blue == max) + h = 4 + (red - green) / delta; - h /= 6.0; + h /= 6.0; - if (h < 0.0) - h += 1.0; - else if (h > 1.0) - h -= 1.0; - } /* else */ - - *r = h; - *g = s; - *b = v; -} /* calc_rgb_to_hsv */ + if (h < 0.0) + h += 1.0; + else if (h > 1.0) + h -= 1.0; + } + *r = h; + *g = s; + *b = v; +} /*****/ static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, + double *s, + double *v) { - double hue, saturation, value; - double f, p, q, t; + double hue, saturation, value; + double f, p, q, t; - if (*s == 0.0) { - *h = *v; - *s = *v; - *v = *v; /* heh */ - } else { - hue = *h * 6.0; - saturation = *s; - value = *v; + if (*s == 0.0) + { + *h = *v; + *s = *v; + *v = *v; /* heh */ + } + else + { + hue = *h * 6.0; + saturation = *s; + value = *v; - if (hue == 6.0) - hue = 0.0; + if (hue == 6.0) + hue = 0.0; - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); + f = hue - (int) hue; + p = value * (1.0 - saturation); + q = value * (1.0 - saturation * f); + t = value * (1.0 - saturation * (1.0 - f)); - switch ((int) hue) { - case 0: - *h = value; - *s = t; - *v = p; - break; + switch ((int) hue) + { + case 0: + *h = value; + *s = t; + *v = p; + break; - case 1: - *h = q; - *s = value; - *v = p; - break; + case 1: + *h = q; + *s = value; + *v = p; + break; - case 2: - *h = p; - *s = value; - *v = t; - break; + case 2: + *h = p; + *s = value; + *v = t; + break; - case 3: - *h = p; - *s = q; - *v = value; - break; + case 3: + *h = p; + *s = q; + *v = value; + break; - case 4: - *h = t; - *s = p; - *v = value; - break; - - case 5: - *h = value; - *s = p; - *v = q; - break; - } /* switch */ - } /* else */ -} /* calc_hsv_to_rgb */ + case 4: + *h = t; + *s = p; + *v = value; + break; + case 5: + *h = value; + *s = p; + *v = q; + break; + } + } +} /***** Files and paths functions *****/ -/*****/ - static gchar * build_user_filename (gchar *name, gchar *path_str) diff --git a/app/gradient_select.c b/app/gradient_select.c index d54d8e091b..75591d0a96 100644 --- a/app/gradient_select.c +++ b/app/gradient_select.c @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /* This is the popup for the gradient selection stuff.. * idea is a cut down version of the gradient selection widget * just a clist on which each gradient can be selected. @@ -28,7 +27,6 @@ * setting the slection all need to be done as well. */ - /* Main structure for the dialog. There can be multiple of these * so every thing has to go into the strcuture and we have to have a list * the structures so we can find which one we are taking about. @@ -48,123 +46,125 @@ #include "colormaps.h" #include "cursorutil.h" #include "datafiles.h" +#include "dialog_handler.h" #include "errors.h" #include "general.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient.h" #include "gradient_header.h" #include "indicator_area.h" #include "interface.h" #include "palette.h" #include "session.h" -#include "actionarea.h" -#include "dialog_handler.h" #include "libgimp/gimpintl.h" GSList *grad_active_dialogs = NULL; /* List of active dialogs */ GradSelectP gradient_select_dialog = NULL; /* The main selection dialog */ -static void grad_select_close_callback (GtkWidget *, gpointer); +static void grad_select_close_callback (GtkWidget *, gpointer); static void grad_select_edit_callback (GtkWidget *, gpointer); -static void grad_change_callbacks(GradSelectP gsp, gint closing); -extern void import_palette_grad_update(gradient_t *); /* ALT Hmm... */ - - -static ActionAreaItem action_items[2] = -{ - { N_("Edit"), grad_select_edit_callback, NULL, NULL }, - { N_("Close"), grad_select_close_callback, NULL, NULL } -}; +static void grad_change_callbacks (GradSelectP gsp, gint closing); +extern void import_palette_grad_update (gradient_t *); /* ALT Hmm... */ void -grad_free_gradient_editor(void) +grad_free_gradient_editor (void) { if (gradient_select_dialog) - session_get_window_info (gradient_select_dialog->shell, &gradient_select_session_info); -} /* grad_free_gradient_editor */ + session_get_window_info (gradient_select_dialog->shell, + &gradient_select_session_info); +} void -grad_sel_rename_all(gint n, gradient_t *grad) +grad_sel_rename_all (gint n, + gradient_t *grad) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_set_text(GTK_CLIST(gsp->clist),n,1,grad->name); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, grad->name); + list = g_slist_next (list); } if(gradient_select_dialog) { - gtk_clist_set_text(GTK_CLIST(gradient_select_dialog->clist),n,1,grad->name); + gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist), + n, 1, grad->name); } } void -grad_sel_new_all(gint pos, gradient_t *grad) +grad_sel_new_all (gint pos, + gradient_t *grad) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_freeze(GTK_CLIST(gsp->clist)); - ed_insert_in_gradients_listbox(gsp->gc,gsp->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gsp->clist)); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_freeze (GTK_CLIST (gsp->clist)); + ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gsp->clist)); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_freeze(GTK_CLIST(gradient_select_dialog->clist)); - ed_insert_in_gradients_listbox(gradient_select_dialog->gc,gradient_select_dialog->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gradient_select_dialog->clist)); + gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist)); + ed_insert_in_gradients_listbox (gradient_select_dialog->gc, + gradient_select_dialog->clist, + grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist)); } } void -grad_sel_copy_all(gint pos, gradient_t *grad) +grad_sel_copy_all (gint pos, + gradient_t *grad) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_freeze(GTK_CLIST(gsp->clist)); - ed_insert_in_gradients_listbox(gsp->gc,gsp->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gsp->clist)); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_freeze (GTK_CLIST (gsp->clist)); + ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gsp->clist)); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_freeze(GTK_CLIST(gradient_select_dialog->clist)); - ed_insert_in_gradients_listbox(gradient_select_dialog->gc,gradient_select_dialog->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gradient_select_dialog->clist)); + gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist)); + ed_insert_in_gradients_listbox (gradient_select_dialog->gc, + gradient_select_dialog->clist, + grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist)); } } void -grad_sel_delete_all(gint n) +grad_sel_delete_all (gint n) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_remove(GTK_CLIST(gsp->clist), n); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_remove (GTK_CLIST (gsp->clist), n); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_remove(GTK_CLIST(gradient_select_dialog->clist), n); + gtk_clist_remove (GTK_CLIST (gradient_select_dialog->clist), n); } } @@ -174,117 +174,119 @@ grad_sel_free_all() GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_freeze(GTK_CLIST(gsp->clist)); - gtk_clist_clear(GTK_CLIST(gsp->clist)); - gtk_clist_thaw(GTK_CLIST(gsp->clist)); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_freeze (GTK_CLIST (gsp->clist)); + gtk_clist_clear (GTK_CLIST (gsp->clist)); + gtk_clist_thaw (GTK_CLIST (gsp->clist)); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_freeze(GTK_CLIST(gradient_select_dialog->clist)); - gtk_clist_clear(GTK_CLIST(gradient_select_dialog->clist)); - gtk_clist_thaw(GTK_CLIST(gradient_select_dialog->clist)); + gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist)); + gtk_clist_clear (GTK_CLIST (gradient_select_dialog->clist)); + gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist)); } } void -grad_sel_refill_all() +grad_sel_refill_all () { GSList *list = grad_active_dialogs; GradSelectP gsp; int select_pos = -1; - while(list) + while (list) { - gsp = (GradSelectP)list->data; + gsp = (GradSelectP) list->data; gsp->grad = curr_gradient; - select_pos = ed_set_list_of_gradients(gsp->gc, - gsp->clist, - curr_gradient); - if(select_pos != -1) - gtk_clist_moveto(GTK_CLIST(gsp->clist),select_pos,0,0.0,0.0); - - list = g_slist_next(list); + select_pos = ed_set_list_of_gradients (gsp->gc, + gsp->clist, + curr_gradient); + if (select_pos != -1) + gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0); + + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { gradient_select_dialog->grad = curr_gradient; - select_pos = ed_set_list_of_gradients(gradient_select_dialog->gc, - gradient_select_dialog->clist, - curr_gradient); - if(select_pos != -1) - gtk_clist_moveto(GTK_CLIST(gradient_select_dialog->clist),select_pos,0,0.0,0.0); + select_pos = ed_set_list_of_gradients (gradient_select_dialog->gc, + gradient_select_dialog->clist, + curr_gradient); + if (select_pos != -1) + gtk_clist_moveto (GTK_CLIST (gradient_select_dialog->clist), + select_pos, 0, 0.0, 0.0); } } - void -sel_update_dialogs(gint row, gradient_t *grad) +sel_update_dialogs (gint row, + gradient_t *grad) { /* Go around each updating the names and hopefully the previews */ GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_set_text(GTK_CLIST(gsp->clist),row,1,grad->name); + gsp = (GradSelectP) list->data; + gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, grad->name); /* Are we updating one that is selected in a popup dialog? */ - if(grad == gsp->grad) - grad_change_callbacks(gsp, 0); - list = g_slist_next(list); + if (grad == gsp->grad) + grad_change_callbacks (gsp, 0); + list = g_slist_next (list); } - if(gradient_select_dialog) - gtk_clist_set_text(GTK_CLIST(gradient_select_dialog->clist),row,1,grad->name); + if (gradient_select_dialog) + gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist), + row, 1, grad->name); gradient_area_update (); /* update the indicator_area */ - import_palette_grad_update(grad); + import_palette_grad_update (grad); } static void -sel_list_item_update(GtkWidget *widget, - gint row, - gint column, - GdkEventButton *event, - gpointer data) +sel_list_item_update (GtkWidget *widget, + gint row, + gint column, + GdkEventButton *event, + gpointer data) { - GradSelectP gsp = (GradSelectP)data; + GradSelectP gsp = (GradSelectP) data; - GSList* tmp = g_slist_nth(gradients_list,row); - gsp->grad = (gradient_t *)(tmp->data); + GSList* tmp = g_slist_nth (gradients_list, row); + gsp->grad = (gradient_t *) (tmp->data); /* If main one then make it the current selection */ - if(gsp == gradient_select_dialog) + if (gsp == gradient_select_dialog) { - grad_set_grad_to_name(gsp->grad->name); + grad_set_grad_to_name (gsp->grad->name); gradient_area_update (); /* update the indicator_area */ - import_palette_grad_update(gsp->grad); + import_palette_grad_update (gsp->grad); } else { - grad_change_callbacks(gsp, 0); + grad_change_callbacks (gsp, 0); } } static void -grad_select_edit_callback (GtkWidget *w, +grad_select_edit_callback (GtkWidget *widget, gpointer client_data) { GradSelectP gsp; gsp = (GradSelectP) client_data; - grad_create_gradient_editor_init(TRUE); + grad_create_gradient_editor_init (TRUE); - /* Set the current gradient in this dialog to the "real current"*/ - if(gsp && gsp->grad) - grad_set_grad_to_name(gsp->grad->name); + /* Set the current gradient in this dialog to the "real current"*/ + if (gsp && gsp->grad) + grad_set_grad_to_name (gsp->grad->name); } void @@ -292,21 +294,19 @@ grad_select_free (GradSelectP gsp) { if (gsp) { - if(gsp->callback_name) - g_free(gsp->callback_name); + if (gsp->callback_name) + g_free (gsp->callback_name); /* remove from active list */ - - grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp); + grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp); g_free (gsp); } } /* Close active dialogs that no longer have PDB registered for them */ - void -gradients_check_dialogs(void) +gradients_check_dialogs (void) { GSList *list; GradSelectP gsp; @@ -321,21 +321,21 @@ gradients_check_dialogs(void) list = list->next; name = gsp->callback_name; - prec = procedural_db_lookup(name); - - if(!prec) + prec = procedural_db_lookup (name); + + if (!prec) { - grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp); + grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp); /* Can alter grad_active_dialogs list*/ - grad_select_close_callback(NULL,gsp); + grad_select_close_callback (NULL, gsp); } } } - static void -grad_change_callbacks(GradSelectP gsp, gint closing) +grad_change_callbacks(GradSelectP gsp, + gint closing) { gchar * name; ProcRecord *prec = NULL; @@ -346,8 +346,8 @@ grad_change_callbacks(GradSelectP gsp, gint closing) /* Any procs registered to callback? */ Argument *return_vals; - - if(!gsp || !gsp->callback_name || busy != 0) + + if (!gsp || !gsp->callback_name || busy != 0) return; busy = 1; @@ -355,9 +355,9 @@ grad_change_callbacks(GradSelectP gsp, gint closing) grad = gsp->grad; /* If its still registered run it */ - prec = procedural_db_lookup(name); + prec = procedural_db_lookup (name); - if(prec && grad) + if (prec && grad) { gdouble *values, *pv; double pos, delta; @@ -366,30 +366,31 @@ grad_change_callbacks(GradSelectP gsp, gint closing) pos = 0.0; delta = 1.0 / (i - 1); - values = g_malloc(i * 4 * sizeof(gdouble)); + values = g_new (gdouble, 4 * i); pv = values; curr_gradient = grad; - while (i--) { - grad_get_color_at(pos, &r, &g, &b, &a); - - *pv++ = r; - *pv++ = g; - *pv++ = b; - *pv++ = a; - - pos += delta; - } /* while */ + while (i--) + { + grad_get_color_at (pos, &r, &g, &b, &a); + + *pv++ = r; + *pv++ = g; + *pv++ = b; + *pv++ = a; + + pos += delta; + } curr_gradient = oldgrad; - + return_vals = procedural_db_run_proc (name, &nreturn_vals, - PDB_STRING,grad->name, - PDB_INT32,gsp->sample_size*4, - PDB_FLOATARRAY,values, - PDB_INT32,closing, + PDB_STRING, grad->name, + PDB_INT32, gsp->sample_size*4, + PDB_FLOATARRAY, values, + PDB_INT32, closing, PDB_END); if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS) @@ -401,7 +402,7 @@ grad_change_callbacks(GradSelectP gsp, gint closing) } static void -grad_select_close_callback (GtkWidget *w, +grad_select_close_callback (GtkWidget *widget, gpointer client_data) { GradSelectP gsp; @@ -420,18 +421,9 @@ grad_select_close_callback (GtkWidget *w, } } -static gint -grad_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - grad_select_close_callback (w, client_data); - return TRUE; -} - GradSelectP -gsel_new_selection (gchar * title, - gchar * initial_gradient) +gsel_new_selection (gchar *title, + gchar *initial_gradient) { GradSelectP gsp; gradient_t *grad = NULL; @@ -448,23 +440,27 @@ gsel_new_selection (gchar * title, grad_create_gradient_editor_init(FALSE); } - gsp = g_malloc (sizeof (_GradSelect)); + gsp = g_new (_GradSelect, 1); gsp->callback_name = NULL; /* The shell and main vbox */ - gsp->shell = gtk_dialog_new (); + gsp->shell = gimp_dialog_new (title ? title : _("Gradient Selection"), + "gradient_selection", + gimp_standard_help_func, + "dialogs/gradient_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_window_set_wmclass (GTK_WINDOW (gsp->shell), "gradselection", "Gimp"); - gtk_window_set_policy (GTK_WINDOW (gsp->shell), FALSE, TRUE, FALSE); + _("Edit"), grad_select_edit_callback, + gsp, NULL, FALSE, FALSE, + _("Close"), grad_select_close_callback, + gsp, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (gsp->shell)->vbox), vbox, TRUE, TRUE, 0); - - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (gsp->shell), "delete_event", - GTK_SIGNAL_FUNC (grad_select_delete_callback), - gsp); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (gsp->shell)->vbox), vbox); /* clist preview of gradients */ scrolled_win = gtk_scrolled_window_new (NULL, NULL); @@ -498,23 +494,10 @@ gsel_new_selection (gchar * title, gdk_color_parse ("black", &gsp->black); gdk_color_alloc (colormap, &gsp->black); - gtk_signal_connect (GTK_OBJECT(gsp->clist), "select_row", - GTK_SIGNAL_FUNC(sel_list_item_update), + gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row", + GTK_SIGNAL_FUNC (sel_list_item_update), (gpointer) gsp); - action_items[0].user_data = gsp; - action_items[1].user_data = gsp; - build_action_area (GTK_DIALOG (gsp->shell), action_items, 2, 1); - - if(!title) - { - gtk_window_set_title (GTK_WINDOW (gsp->shell), _("Gradient Selection")); - } - else - { - gtk_window_set_title (GTK_WINDOW (gsp->shell), title); - } - if (initial_gradient && strlen (initial_gradient)) { list = gradients_list; @@ -547,31 +530,32 @@ gsel_new_selection (gchar * title, gtk_widget_show (gsp->shell); if (select_pos != -1) - gtk_clist_moveto (GTK_CLIST(gsp->clist),select_pos,0,0.0,0.0); + gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0); return gsp; } void -grad_create_gradient_editor(void) +grad_create_gradient_editor (void) { - if(gradient_select_dialog == NULL) + if (gradient_select_dialog == NULL) { - gradient_select_dialog = gsel_new_selection(_("Gradients"),NULL); + gradient_select_dialog = gsel_new_selection (_("Gradients"), NULL); /* register this one only */ - dialog_register(gradient_select_dialog->shell); + dialog_register (gradient_select_dialog->shell); - session_set_window_geometry (gradient_select_dialog->shell, &gradient_select_session_info, TRUE); + session_set_window_geometry (gradient_select_dialog->shell, + &gradient_select_session_info, TRUE); } else { - if (!GTK_WIDGET_VISIBLE(gradient_select_dialog->shell)) + if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell)) { - gtk_widget_show(gradient_select_dialog->shell); + gtk_widget_show (gradient_select_dialog->shell); } else - gdk_window_raise(gradient_select_dialog->shell->window); + gdk_window_raise (gradient_select_dialog->shell->window); return; } } diff --git a/app/gui/brush-editor.c b/app/gui/brush-editor.c index 28f0fa3746..4541982c79 100644 --- a/app/gui/brush-editor.c +++ b/app/gui/brush-editor.c @@ -23,22 +23,16 @@ #include "appenv.h" #include "gimpbrushgenerated.h" #include "brush_edit.h" -#include "actionarea.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" -static void brush_edit_close_callback (GtkWidget *w, void *data); +static void brush_edit_close_callback (GtkWidget *, gpointer); static gint brush_edit_preview_resize (GtkWidget *widget, GdkEvent *event, BrushEditGeneratedWindow *begw); -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Close"), brush_edit_close_callback, NULL, NULL } -}; - static void -update_brush_callback (GtkAdjustment *adjustment, +update_brush_callback (GtkAdjustment *adjustment, BrushEditGeneratedWindow *begw) { if (begw->brush && @@ -64,15 +58,6 @@ update_brush_callback (GtkAdjustment *adjustment, } } -static gint -brush_edit_delete_callback (GtkWidget *w, - BrushEditGeneratedWindow *begw) -{ - if (GTK_WIDGET_VISIBLE (w)) - gtk_widget_hide (w); - return TRUE; -} - static void brush_edit_clear_preview (BrushEditGeneratedWindow *begw) { @@ -93,7 +78,7 @@ brush_edit_clear_preview (BrushEditGeneratedWindow *begw) } static gint -brush_edit_brush_dirty_callback(GimpBrush *brush, +brush_edit_brush_dirty_callback (GimpBrush *brush, BrushEditGeneratedWindow *begw) { int x, y, width, yend, ystart, xo; @@ -138,15 +123,17 @@ brush_edit_brush_dirty_callback(GimpBrush *brush, return TRUE; } -void brush_renamed_callback(GtkWidget *widget, BrushEditGeneratedWindow *begw) +void +brush_renamed_callback (GtkWidget *widget, + BrushEditGeneratedWindow *begw) { gtk_entry_set_text(GTK_ENTRY(begw->name), gimp_brush_get_name(GIMP_BRUSH(begw->brush))); } void -brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw, - GimpBrush *gbrush) +brush_edit_generated_set_brush (BrushEditGeneratedWindow *begw, + GimpBrush *gbrush) { GimpBrushGenerated *brush = 0; if (begw->brush == (GimpBrushGenerated*)gbrush) @@ -189,16 +176,21 @@ brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw, } } -void name_changed_func(GtkWidget *widget, BrushEditGeneratedWindow *begw) +void +name_changed_func (GtkWidget *widget, + BrushEditGeneratedWindow *begw) { gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(widget)); gimp_brush_set_name(GIMP_BRUSH(begw->brush), entry_text); } -void focus_out_func(GtkWidget *wid1, GtkWidget *wid2, BrushEditGeneratedWindow *begw) +void +focus_out_func (GtkWidget *wid1, + GtkWidget *wid2, + BrushEditGeneratedWindow *begw) { - name_changed_func(wid1, begw); + name_changed_func (wid1, begw); } BrushEditGeneratedWindow * @@ -210,34 +202,31 @@ brush_edit_generated_new () GtkWidget *slider; GtkWidget *table; - - - begw = g_malloc (sizeof (BrushEditGeneratedWindow)); + begw = g_new (BrushEditGeneratedWindow, 1); begw->brush = NULL; - begw->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (begw->shell), "generatedbrusheditor", - "Gimp"); - gtk_window_set_title (GTK_WINDOW (begw->shell), _("Brush Editor")); - gtk_window_set_policy(GTK_WINDOW(begw->shell), FALSE, TRUE, FALSE); + begw->shell = gimp_dialog_new (_("Brush Editor"), "generated_brush_editor", + gimp_standard_help_func, + "dialogs/generated_brush_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Close"), brush_edit_close_callback, + begw, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (begw->shell)->vbox), vbox, - TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (begw->shell)->vbox), vbox); - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (begw->shell), "delete_event", - GTK_SIGNAL_FUNC (brush_edit_delete_callback), - begw); + /* Populate the window with some widgets */ -/* Populate the window with some widgets */ - - /* table for brush controlls */ + /* table for brush controlls */ table = gtk_table_new(5, 4, FALSE); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); - /* Brush's name */ + /* Brush's name */ begw->name = gtk_entry_new(); gtk_box_pack_start (GTK_BOX (vbox), begw->name, TRUE, TRUE, 0); @@ -249,7 +238,7 @@ brush_edit_generated_new () begw); gtk_widget_show(begw->name); - /* brush's preview widget w/frame */ + /* brush's preview widget w/frame */ begw->frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (begw->frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), begw->frame, TRUE, TRUE, 0); @@ -276,7 +265,7 @@ brush_edit_generated_new () /* brush radius scale */ label = gtk_label_new (_("Radius:")); gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5); -/* gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); */ + /* gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); */ gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 3, 0, 0, 0); begw->radius_data = GTK_ADJUSTMENT (gtk_adjustment_new (10.0, 0.0, 100.0, 0.1, 1.0, 0.0)); slider = gtk_hscale_new (begw->radius_data); @@ -341,20 +330,15 @@ brush_edit_generated_new () gtk_table_set_col_spacing(GTK_TABLE (table), 0, 3); gtk_widget_show (table); - /* The action area */ - action_items[0].user_data = begw; - build_action_area (GTK_DIALOG (begw->shell), action_items, 1, 0); - gtk_widget_show (vbox); gtk_widget_show (begw->shell); - return begw; } static gint -brush_edit_preview_resize (GtkWidget *widget, - GdkEvent *event, +brush_edit_preview_resize (GtkWidget *widget, + GdkEvent *event, BrushEditGeneratedWindow *begw) { gtk_preview_size (GTK_PREVIEW (begw->preview), @@ -363,14 +347,16 @@ brush_edit_preview_resize (GtkWidget *widget, /* update the display */ if (begw->brush) - brush_edit_brush_dirty_callback(GIMP_BRUSH(begw->brush), begw); + brush_edit_brush_dirty_callback (GIMP_BRUSH (begw->brush), begw); return FALSE; } static void -brush_edit_close_callback (GtkWidget *w, void *data) +brush_edit_close_callback (GtkWidget *widget, + gpointer data) { - BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *)data; + BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *) data; + if (GTK_WIDGET_VISIBLE (begw->shell)) gtk_widget_hide (begw->shell); } diff --git a/app/gui/brush-select.c b/app/gui/brush-select.c index 04c34f4888..967d5ba394 100644 --- a/app/gui/brush-select.c +++ b/app/gui/brush-select.c @@ -23,7 +23,6 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "brush_scale.h" #include "gimpbrushgenerated.h" #include "gimpbrushlist.h" @@ -32,6 +31,7 @@ #include "gimpcontext.h" #include "gimplist.h" #include "gimprc.h" +#include "gimpui.h" #include "brush_edit.h" #include "brush_select.h" #include "colormaps.h" @@ -140,12 +140,10 @@ static void paint_mode_menu_callback (GtkWidget *, gpointer); static gint brush_select_events (GtkWidget *, GdkEvent *, BrushSelectP); static gint brush_select_resize (GtkWidget *, GdkEvent *, BrushSelectP); -static gint brush_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void preview_scroll_update (GtkAdjustment *, gpointer); static void opacity_scale_update (GtkAdjustment *, gpointer); static void spacing_scale_update (GtkAdjustment *, gpointer); - /* local variables */ /* List of active dialogs */ @@ -154,7 +152,6 @@ GSList *brush_active_dialogs = NULL; /* Brush editor dialog (main brush dialog only) */ static BrushEditGeneratedWindow *brush_edit_generated_dialog; - /* If title == NULL then it is the main brush dialog */ BrushSelectP brush_select_new (gchar *title, @@ -184,13 +181,7 @@ brush_select_new (gchar *title, GimpBrushP active = NULL; gint gotinitbrush = FALSE; - static ActionAreaItem action_items[] = - { - { N_("Refresh"), brush_select_refresh_callback, NULL, NULL }, - { N_("Close"), brush_select_close_callback, NULL, NULL } - }; - - bsp = g_malloc (sizeof (_BrushSelect)); + bsp = g_new (_BrushSelect, 1); bsp->redraw = TRUE; bsp->scroll_offset = 0; bsp->callback_name = 0; @@ -205,35 +196,42 @@ brush_select_new (gchar *title, bsp->freeze = FALSE; /* The shell and main vbox */ - bsp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bsp->shell), "brushselection", "Gimp"); - - if (!title) + if (title) { - gtk_window_set_title (GTK_WINDOW (bsp->shell), _("Brush Selection")); + bsp->shell = gimp_dialog_new (title, "brush_selection", + gimp_standard_help_func, + "dialogs/brush_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* set dialog's size later because weird thing will happen if the - * size was not saved in the current paint options mode - */ - session_set_window_geometry (bsp->shell, &brush_select_session_info, - FALSE); - } - else - { - gtk_window_set_title (GTK_WINDOW (bsp->shell), title); + _("Close"), brush_select_close_callback, + bsp, NULL, TRUE, TRUE, + + NULL); if (init_name && strlen (init_name)) active = gimp_brush_list_get_brush (brush_list, init_name); if (active) gotinitbrush = TRUE; } + else + { + bsp->shell = gimp_dialog_new (_("Brush Selection"), "brush_selection", + gimp_standard_help_func, + "dialogs/brush_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_window_set_policy (GTK_WINDOW (bsp->shell), FALSE, TRUE, FALSE); + _("Refresh"), brush_select_refresh_callback, + bsp, NULL, FALSE, FALSE, + _("Close"), brush_select_close_callback, + bsp, NULL, TRUE, TRUE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (bsp->shell), "delete_event", - GTK_SIGNAL_FUNC (brush_select_delete_callback), - bsp); + NULL); + + session_set_window_geometry (bsp->shell, &brush_select_session_info, + FALSE); + } /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -425,14 +423,6 @@ brush_select_new (gchar *title, gtk_widget_show (table); - /* The action area */ - action_items[0].user_data = bsp; - action_items[1].user_data = bsp; - if (title) - build_action_area (GTK_DIALOG (bsp->shell), &action_items[1], 1, 0); - else - build_action_area (GTK_DIALOG (bsp->shell), action_items, 2, 1); - gtk_widget_show (bsp->options_box); gtk_widget_show (hbox); gtk_widget_show (vbox); @@ -447,7 +437,7 @@ brush_select_new (gchar *title, display_brushes (bsp); /* Only for main dialog */ - if(!title) + if (!title) { /* add callbacks to keep the display area current */ gimp_list_foreach (GIMP_LIST (brush_list), @@ -514,7 +504,6 @@ brush_select_new (gchar *title, return bsp; } - void brush_select_select (BrushSelectP bsp, GimpBrushP brush) @@ -546,7 +535,6 @@ brush_select_select (BrushSelectP bsp, brush_select_show_selected (bsp, row, col); } - void brush_select_free (BrushSelectP bsp) { @@ -838,7 +826,6 @@ typedef struct { GimpBrushP brush; } popup_timeout_args_t; - static gint brush_popup_anim_timeout (gpointer data) { @@ -1104,7 +1091,6 @@ display_brush (BrushSelectP bsp, } } - static void display_setup (BrushSelectP bsp) { @@ -1156,7 +1142,6 @@ display_brushes (BrushSelectP bsp) gimp_list_foreach (GIMP_LIST (brush_list), (GFunc) do_display_brush, bsp); } - static void brush_select_show_selected (BrushSelectP bsp, int row, @@ -1246,7 +1231,6 @@ brush_select_show_selected (BrushSelectP bsp, g_free (buf); } - static void preview_calc_scrollbar (BrushSelectP bsp) { @@ -1343,7 +1327,6 @@ update_active_brush_field (BrushSelectP bsp) gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data), "value_changed"); } - static void edit_active_brush () { @@ -1508,56 +1491,47 @@ brush_select_events (GtkWidget *widget, } static gint -edit_brush_callback (GtkWidget *w, - GdkEvent *e, +edit_brush_callback (GtkWidget *widget, + GdkEvent *event, gpointer data) { - edit_active_brush(); + edit_active_brush (); return TRUE; } static gint -delete_brush_callback (GtkWidget *w, - GdkEvent *e, +delete_brush_callback (GtkWidget *widget, + GdkEvent *event, gpointer data) { - delete_active_brush(data); + delete_active_brush (data); return TRUE; } static gint -new_brush_callback (GtkWidget *w, - GdkEvent *e, +new_brush_callback (GtkWidget *widget, + GdkEvent *event, gpointer data) { GimpBrushGenerated *brush; + brush = gimp_brush_generated_new (10, .5, 0.0, 1.0); - gimp_brush_list_add(brush_list, GIMP_BRUSH (brush)); + gimp_brush_list_add (brush_list, GIMP_BRUSH (brush)); select_brush (GIMP_BRUSH (brush)); if (brush_edit_generated_dialog) brush_edit_generated_set_brush (brush_edit_generated_dialog, - get_active_brush()); - edit_brush_callback (w, e, data); - return TRUE; -} - -static gint -brush_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - brush_select_close_callback (w, data); - + get_active_brush ()); + edit_brush_callback (widget, event, data); return TRUE; } static void -brush_select_close_callback (GtkWidget *w, /* Unused so can be NULL */ - gpointer client_data) +brush_select_close_callback (GtkWidget *widget, + gpointer data) { BrushSelectP bsp; - bsp = (BrushSelectP) client_data; + bsp = (BrushSelectP) data; if (GTK_WIDGET_VISIBLE (bsp->shell)) gtk_widget_hide (bsp->shell); @@ -1572,15 +1546,14 @@ brush_select_close_callback (GtkWidget *w, /* Unused so can be NULL */ } } - static void -brush_select_refresh_callback (GtkWidget *w, - gpointer client_data) +brush_select_refresh_callback (GtkWidget *widget, + gpointer data) { BrushSelectP bsp; GimpBrushP active; - bsp = (BrushSelectP) client_data; + bsp = (BrushSelectP) data; /* re-init the brush list */ bsp->freeze = TRUE; @@ -1608,7 +1581,6 @@ brush_select_refresh_callback (GtkWidget *w, gtk_widget_draw (bsp->preview, NULL); } - static void preview_scroll_update (GtkAdjustment *adjustment, gpointer data) @@ -1617,7 +1589,7 @@ preview_scroll_update (GtkAdjustment *adjustment, GimpBrushP active; int row, col, index; - bsp = data; + bsp = (BrushSelectP) data; if (bsp) { @@ -1645,24 +1617,25 @@ preview_scroll_update (GtkAdjustment *adjustment, } static void -paint_mode_menu_callback (GtkWidget *w, - gpointer client_data) +paint_mode_menu_callback (GtkWidget *widget, + gpointer data) { - BrushSelectP bsp = (BrushSelectP) gtk_object_get_user_data (GTK_OBJECT (w)); + BrushSelectP bsp; + bsp = (BrushSelectP) gtk_object_get_user_data (GTK_OBJECT (widget)); + if (bsp == brush_select_dialog) { gimp_context_set_paint_mode (gimp_context_get_user (), - (int) client_data); + (int) data); } else { - bsp->paint_mode = (int) client_data; + bsp->paint_mode = (int) data; brush_change_callbacks (bsp, 0); } } - static void opacity_scale_update (GtkAdjustment *adjustment, gpointer data) diff --git a/app/gui/channels-dialog.c b/app/gui/channels-dialog.c index 22b4c9cd97..65eb33dae3 100644 --- a/app/gui/channels-dialog.c +++ b/app/gui/channels-dialog.c @@ -17,7 +17,6 @@ */ #include "gdk/gdkkeysyms.h" #include "appenv.h" -#include "actionarea.h" #include "channels_dialog.h" #include "colormaps.h" #include "color_panel.h" @@ -28,6 +27,7 @@ #include "gimage_mask.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "interface.h" #include "layers_dialogP.h" #include "lc_dialogP.h" @@ -2363,16 +2363,6 @@ new_channel_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -new_channel_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - new_channel_query_cancel_callback (widget, data); - - return TRUE; -} - static void new_channel_query_scale_update (GtkAdjustment *adjustment, gdouble *scale_val) @@ -2391,12 +2381,6 @@ channels_dialog_new_channel_query (GimpImage* gimage) GtkWidget *opacity_scale; GtkObject *opacity_scale_data; - static ActionAreaItem action_items[] = - { - { N_("OK"), new_channel_query_ok_callback, NULL, NULL }, - { N_("Cancel"), new_channel_query_cancel_callback, NULL, NULL } - }; - /* the new options structure */ options = g_new (NewChannelOptions, 1); options->gimage = gimage; @@ -2404,17 +2388,19 @@ channels_dialog_new_channel_query (GimpImage* gimage) 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), - "new_channel_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), - _("New Channel Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("New Channel Options"), "new_channel_options", + gimp_standard_help_func, + "dialogs/channels_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (new_channel_query_delete_callback), - options); + _("OK"), new_channel_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), new_channel_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 2); @@ -2469,11 +2455,6 @@ channels_dialog_new_channel_query (GimpImage* gimage) TRUE, TRUE, 0); gtk_widget_show (options->color_panel->color_panel_widget); - /* The action area */ - action_items[0].user_data = options; - action_items[1].user_data = options; - build_action_area (GTK_DIALOG (options->query_box), action_items, 2, 1); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (hbox); @@ -2558,16 +2539,6 @@ edit_channel_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -edit_channel_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - edit_channel_query_cancel_callback (widget, data); - - return TRUE; -} - static void channels_dialog_edit_channel_query (ChannelWidget *channel_widget) { @@ -2580,12 +2551,6 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget) GtkObject *opacity_scale_data; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), edit_channel_query_ok_callback, NULL, NULL }, - { N_("Cancel"), edit_channel_query_cancel_callback, NULL, NULL } - }; - /* the new options structure */ options = g_new (EditChannelOptions, 1); options->channel_widget = channel_widget; @@ -2597,17 +2562,19 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget) 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_channel_atributes", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), - _("Edit Channel Attributes")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Edit Channel Attributes"), "edit_channel_attributes", + gimp_standard_help_func, + "dialogs/channels_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (edit_channel_query_delete_callback), - options); + _("OK"), edit_channel_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), edit_channel_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 2); @@ -2661,11 +2628,6 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget) TRUE, TRUE, 0); gtk_widget_show (options->color_panel->color_panel_widget); - /* The action area */ - 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); diff --git a/app/gui/color-notebook.c b/app/gui/color-notebook.c index bdb4b3739c..39976e007a 100644 --- a/app/gui/color-notebook.c +++ b/app/gui/color-notebook.c @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #define __COLOR_NOTEBOOK_C__ 1 #include "config.h" @@ -29,28 +28,17 @@ #include #include "appenv.h" -#include "actionarea.h" #include "color_notebook.h" +#include "gimpui.h" #include "libgimp/color_selector.h" #include "libgimp/gimpintl.h" - - -static void color_notebook_ok_callback (GtkWidget *, gpointer); +static void color_notebook_ok_callback (GtkWidget *, gpointer); static void color_notebook_cancel_callback (GtkWidget *, gpointer); -static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void color_notebook_update_callback (void *, int, int, int); static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint); - -static ActionAreaItem action_items[2] = -{ - { N_("OK"), color_notebook_ok_callback, NULL, NULL }, - { N_("Cancel"), color_notebook_cancel_callback, NULL, NULL }, -}; - - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo { char *name; /* label used in notebook tab */ @@ -98,28 +86,33 @@ color_notebook_new (int r, g_return_val_if_fail (selector_info != NULL, NULL); - cnp = g_malloc (sizeof (_ColorNotebook)); + cnp = g_new (_ColorNotebook, 1); - cnp->callback = callback; - cnp->client_data = client_data; + cnp->callback = callback; + cnp->client_data = client_data; cnp->wants_updates = wants_updates; - cnp->selectors = NULL; - cnp->cur_page = NULL; + cnp->selectors = NULL; + cnp->cur_page = NULL; - cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; + cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff; - cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; + cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; - /* window hints need to stay the same, so people's window manager - * setups still work */ - cnp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE); + cnp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_notebook_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event", - (GtkSignalFunc) color_notebook_delete_callback, cnp); + wants_updates ? _("Close") : _("OK"), + color_notebook_ok_callback, + cnp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_notebook_cancel_callback, + cnp, NULL, FALSE, TRUE, + + NULL); /* do we actually need a notebook? */ if (selector_info->next) @@ -179,21 +172,6 @@ color_notebook_new (int r, info = info->next; } - /* The action area */ - action_items[0].user_data = cnp; - action_items[1].user_data = cnp; - if (cnp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0); - gtk_widget_show (cnp->shell); /* this must come after showing the widget, otherwise we get a @@ -209,7 +187,6 @@ color_notebook_new (int r, return cnp; } - void color_notebook_show (ColorNotebookP cnp) { @@ -217,7 +194,6 @@ color_notebook_show (ColorNotebookP cnp) gtk_widget_show (cnp->shell); } - void color_notebook_hide (ColorNotebookP cnp) { @@ -253,13 +229,12 @@ color_notebook_free (ColorNotebookP cnp) g_free (cnp); } - void color_notebook_set_color (ColorNotebookP cnp, - int r, - int g, - int b, - int set_current) + int r, + int g, + int b, + int set_current) { ColorSelectorInstance *csel; g_return_if_fail (cnp != NULL); @@ -279,11 +254,12 @@ color_notebook_set_color (ColorNotebookP cnp, csel->info->m.setcolor (csel->selector_data, r, g, b, set_current); } - - /* Called by a colour selector on user selection of a colour */ static void -color_notebook_update_callback (void *data, int r, int g, int b) +color_notebook_update_callback (void *data, + int r, + int g, + int b) { ColorSelectorInstance *csel; ColorNotebookP cnp; @@ -307,16 +283,13 @@ color_notebook_update_callback (void *data, int r, int g, int b) } } - - - static void -color_notebook_ok_callback (GtkWidget *w, - gpointer client_data) +color_notebook_ok_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->values[RED], @@ -326,25 +299,13 @@ color_notebook_ok_callback (GtkWidget *w, cnp->client_data); } - -static gint -color_notebook_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_notebook_cancel_callback (w, client_data); - - return TRUE; -} - - static void -color_notebook_cancel_callback (GtkWidget *w, - gpointer client_data) +color_notebook_cancel_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->orig_values[RED], @@ -355,14 +316,14 @@ color_notebook_cancel_callback (GtkWidget *w, } static void -color_notebook_page_switch (GtkWidget *w, +color_notebook_page_switch (GtkWidget *widget, GtkNotebookPage *page, guint page_num) { ColorNotebookP cnp; ColorSelectorInstance *csel; - cnp = gtk_object_get_user_data (GTK_OBJECT (w)); + cnp = gtk_object_get_user_data (GTK_OBJECT (widget)); csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook"); g_return_if_fail (cnp != NULL && csel != NULL); @@ -466,5 +427,4 @@ selector_death (ColorSelectorInfo *info) g_warning ("color selector %p not found, can't happen!", info); } - /* End of color_notebook.c */ diff --git a/app/gui/color-select.c b/app/gui/color-select.c index 1108664b37..8222bbd0c0 100644 --- a/app/gui/color-select.c +++ b/app/gui/color-select.c @@ -16,16 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include #include #include + #include "appenv.h" -#include "actionarea.h" #include "color_select.h" #include "colormaps.h" #include "errors.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "session.h" #include "color_area.h" /* for color_area_draw_rect */ @@ -110,7 +112,6 @@ static void color_select_update_colors (ColorSelect *, gint); static void color_select_ok_callback (GtkWidget *, gpointer); static void color_select_cancel_callback (GtkWidget *, gpointer); -static gint color_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static gint color_select_xy_expose (GtkWidget *, GdkEventExpose *, ColorSelect *); static gint color_select_xy_events (GtkWidget *, GdkEvent *, @@ -190,12 +191,6 @@ color_select_new (gint r, ColorSelect *csp; GtkWidget *main_vbox; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_select_ok_callback, NULL, NULL }, - { N_("Cancel"), color_select_cancel_callback, NULL, NULL } - }; - csp = g_new (ColorSelect, 1); csp->callback = callback; @@ -211,37 +206,26 @@ color_select_new (gint r, color_select_update_hsv_values (csp); color_select_update_pos (csp); - csp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (csp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (csp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (csp->shell), FALSE, FALSE, FALSE); + csp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, + wants_updates ? _("Close") : _("OK"), + color_select_ok_callback, + csp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_select_cancel_callback, + csp, NULL, FALSE, TRUE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (csp->shell), "delete_event", - (GtkSignalFunc) color_select_delete_callback, csp); + NULL); main_vbox = color_select_widget_new (csp, r, g, b); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (csp->shell)->vbox), main_vbox); gtk_widget_show (main_vbox); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, - TRUE, TRUE, 0); - - /* The action area */ - action_items[0].user_data = csp; - action_items[1].user_data = csp; - if (csp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0); - color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values); color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values); @@ -997,16 +981,6 @@ color_select_ok_callback (GtkWidget *widget, } } -static gint -color_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - color_select_cancel_callback (widget, data); - - return TRUE; -} - static void color_select_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/gui/commands.c b/app/gui/commands.c index 344fd7017d..9dc31ff075 100644 --- a/app/gui/commands.c +++ b/app/gui/commands.c @@ -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) diff --git a/app/gui/commands.h b/app/gui/commands.h index aba3d13a1e..7dbf589d23 100644 --- a/app/gui/commands.h +++ b/app/gui/commands.h @@ -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__ */ diff --git a/app/gui/device-status-dialog.c b/app/gui/device-status-dialog.c index 9faa2b0ea4..4ca834935d 100644 --- a/app/gui/device-status-dialog.c +++ b/app/gui/device-status-dialog.c @@ -15,19 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "config.h" #include #include #include "appenv.h" -#include "actionarea.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "devices.h" #include "interface.h" #include "gimprc.h" +#include "gimpui.h" #include "palette.h" #include "session.h" #include "tools.h" @@ -63,7 +62,7 @@ struct _DeviceInfo { GimpBrushP brush; GPatternP pattern; ToolType tool; - unsigned char foreground[3]; + guchar foreground[3]; }; typedef struct _DeviceInfoDialog DeviceInfoDialog; @@ -115,13 +114,6 @@ static void device_status_drop_pattern (GtkWidget *, /* Global data */ int current_device = GDK_CORE_POINTER; -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Save"), (ActionCallback)devices_write_rc, NULL, NULL }, - { N_("Close"), devices_close_callback, NULL, NULL } -}; - /* dnd stuff */ static GtkTargetEntry color_area_target_table[] = { @@ -151,17 +143,17 @@ create_input_dialog (void) if (!inputd) { - inputd = gtk_input_dialog_new(); + inputd = gtk_input_dialog_new (); /* register this one only */ - dialog_register(inputd); + dialog_register (inputd); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area), FALSE); - hbbox = gtk_hbutton_box_new(); - gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbbox), 4); + hbbox = gtk_hbutton_box_new (); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox); GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button, @@ -170,46 +162,52 @@ create_input_dialog (void) GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button, GTK_CAN_DEFAULT); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, - FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, + FALSE, FALSE, 0); gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button); gtk_widget_show(hbbox); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button), + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button), "clicked", - GTK_SIGNAL_FUNC(devices_write_rc), NULL); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), + GTK_SIGNAL_FUNC (devices_write_rc), NULL); + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button), "clicked", - GTK_SIGNAL_FUNC(devices_close_callback), inputd); + GTK_SIGNAL_FUNC (devices_close_callback), inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "destroy", - (GtkSignalFunc)input_dialog_destroy_callback, + gtk_signal_connect (GTK_OBJECT (inputd), "destroy", + (GtkSignalFunc) input_dialog_destroy_callback, &inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "enable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); - gtk_signal_connect (GTK_OBJECT(inputd), "disable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "enable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "disable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (inputd, + gimp_standard_help_func, + "dialogs/input_devices_dialog.html"); + gtk_widget_show (inputd); } else { - if (!GTK_WIDGET_MAPPED(inputd)) - gtk_widget_show(inputd); + if (!GTK_WIDGET_MAPPED (inputd)) + gtk_widget_show (inputd); else - gdk_window_raise(inputd->window); + gdk_window_raise (inputd->window); } } void -input_dialog_able_callback (GtkWidget *w, - guint32 deviceid, +input_dialog_able_callback (GtkWidget *widget, + guint32 deviceid, gpointer data) { device_status_update (deviceid); } static void -input_dialog_destroy_callback (GtkWidget *w, +input_dialog_destroy_callback (GtkWidget *widget, gpointer call_data) { *((GtkWidget **)call_data) = NULL; @@ -223,7 +221,7 @@ devices_init (void) /* Create device info structures for present devices */ tmp_list = gdk_input_list_devices (); - + while (tmp_list) { GdkDeviceInfo *gdk_info = (GdkDeviceInfo *)tmp_list->data; @@ -528,7 +526,7 @@ devices_save_current_info (void) device_info->is_init = TRUE; device_info->device = current_device; device_info->brush = get_active_brush (); - device_info->pattern = get_active_pattern(); + device_info->pattern = get_active_pattern (); if (active_tool) device_info->tool = active_tool->type; else @@ -539,7 +537,7 @@ devices_save_current_info (void) } static void -devices_write_rc_device (DeviceInfo *device_info, +devices_write_rc_device (DeviceInfo *device_info, FILE *fp) { GdkDeviceInfo *gdk_info; @@ -552,7 +550,7 @@ devices_write_rc_device (DeviceInfo *device_info, { /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ - tmp_list = gdk_input_list_devices(); + tmp_list = gdk_input_list_devices (); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; @@ -566,7 +564,7 @@ devices_write_rc_device (DeviceInfo *device_info, } } - fprintf(fp, "(device \"%s\"",device_info->name); + fprintf (fp, "(device \"%s\"",device_info->name); switch (gdk_info ? gdk_info->mode : device_info->mode) { @@ -581,9 +579,10 @@ devices_write_rc_device (DeviceInfo *device_info, break; } - fprintf(fp, "\n (mode %s)",mode); + fprintf (fp, "\n (mode %s)", mode); - fprintf(fp, "\n (axes %d",gdk_info ? gdk_info->num_axes : device_info->num_axes); + fprintf (fp, "\n (axes %d", + gdk_info ? gdk_info->num_axes : device_info->num_axes); for (i=0; i<(gdk_info ? gdk_info->num_axes : device_info->num_axes); i++) { @@ -615,19 +614,20 @@ devices_write_rc_device (DeviceInfo *device_info, break; #endif /* GTK_HAVE_SIX_VALUATORS */ } - fprintf(fp, " %s",axis_type); + fprintf (fp, " %s",axis_type); } - fprintf(fp,")"); + fprintf (fp,")"); - fprintf(fp, "\n (keys %d", gdk_info ? gdk_info->num_keys : device_info->num_keys); + fprintf (fp, "\n (keys %d", + gdk_info ? gdk_info->num_keys : device_info->num_keys); - for (i=0; i<(gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) + for (i=0; i < (gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) { GdkModifierType modifiers = gdk_info ? gdk_info->keys[i].modifiers : device_info->keys[i].modifiers; guint keyval = gdk_info ? gdk_info->keys[i].keyval : device_info->keys[i].keyval; - + if (keyval) { /* FIXME: integrate this back with menus_install_accelerator */ @@ -650,22 +650,22 @@ devices_write_rc_device (DeviceInfo *device_info, else fprintf (fp, " \"\""); } - fprintf(fp,")"); + fprintf (fp,")"); if (device_info->is_init) { if (device_info->brush) - fprintf(fp, "\n (brush \"%s\")",device_info->brush->name); + fprintf (fp, "\n (brush \"%s\")",device_info->brush->name); if (device_info->pattern) - fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name); + fprintf (fp, "\n (pattern \"%s\")",device_info->pattern->name); /* Fixme: hard coded last tool.... see gimprc */ if (device_info->tool && device_info->tool <= LAST_TOOLBOX_TOOL) - fprintf(fp, "\n (tool \"%s\")", - tool_info[device_info->tool].tool_name); - fprintf(fp, "\n (foreground %d %d %d)", - device_info->foreground[0], - device_info->foreground[1], - device_info->foreground[2]); + fprintf (fp, "\n (tool \"%s\")", + tool_info[device_info->tool].tool_name); + fprintf (fp, "\n (foreground %d %d %d)", + device_info->foreground[0], + device_info->foreground[1], + device_info->foreground[2]); } fprintf(fp,")\n"); @@ -702,18 +702,25 @@ create_device_status (void) if (deviceD == NULL) { deviceD = g_new (DeviceInfoDialog, 1); - deviceD->shell = gtk_dialog_new (); + + deviceD->shell = + gimp_dialog_new (_("Device Status"), "device_status", + gimp_standard_help_func, + "dialogs/device_status_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, TRUE, + + _("Save"), (GtkSignalFunc) devices_write_rc, + NULL, NULL, FALSE, FALSE, + _("Close"), devices_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* register this one only */ - dialog_register(deviceD->shell); - - gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status")); - gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE); - /* don't set the dialog's size, as the number of devices may have - * changed since the last session - */ - session_set_window_geometry (deviceD->shell, - &device_status_session_info, FALSE); + dialog_register (deviceD->shell); + session_set_window_geometry (deviceD->shell, &device_status_session_info, + FALSE); deviceD->num_devices = 0; tmp_list = devices_info; @@ -723,10 +730,10 @@ create_device_status (void) deviceD->num_devices++; tmp_list = tmp_list->next; } -/* devices table */ + /* devices table */ deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE); - gtk_container_set_border_width (GTK_CONTAINER(deviceD->table), 3); - gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox), + gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox), deviceD->table); gtk_widget_realize (deviceD->table); gtk_widget_show (deviceD->table); @@ -841,9 +848,6 @@ create_device_status (void) i++; } - action_items[1].user_data = deviceD->shell; - build_action_area (GTK_DIALOG (deviceD->shell), action_items, 2, 1); - deviceD->current = 0xffffffff; /* random, but doesn't matter */ device_status_update_current (); @@ -878,7 +882,7 @@ device_status_destroy_callback (void) } static void -devices_close_callback (GtkWidget *w, +devices_close_callback (GtkWidget *widget, gpointer data) { gtk_widget_hide (GTK_WIDGET(data)); diff --git a/app/gui/file-new-dialog.c b/app/gui/file-new-dialog.c index 333e6d9c5f..f23969962d 100644 --- a/app/gui/file-new-dialog.c +++ b/app/gui/file-new-dialog.c @@ -15,11 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "file_new_dialog.h" - -#include "actionarea.h" #include "gimprc.h" +#include "gimpui.h" #include "gdisplay.h" #include "libgimp/gimpchainbutton.h" @@ -27,7 +25,8 @@ #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" -typedef struct { +typedef struct +{ GtkWidget *dlg; GtkWidget *confirm_dlg; @@ -50,7 +49,6 @@ static void file_new_confirm_dialog (NewImageInfo *); static void file_new_ok_callback (GtkWidget *, gpointer); static void file_new_reset_callback (GtkWidget *, gpointer); -static gint file_new_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void file_new_cancel_callback (GtkWidget *, gpointer); static void file_new_toggle_callback (GtkWidget *, gpointer); static void file_new_resolution_callback (GtkWidget *, gpointer); @@ -136,15 +134,6 @@ file_new_reset_callback (GtkWidget *widget, (GTK_TOGGLE_BUTTON (info->fill_type_w[BACKGROUND_FILL]), TRUE); } -static gint -file_new_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - file_new_cancel_callback (widget, data); - return TRUE; -} - static void file_new_cancel_callback (GtkWidget *widget, gpointer data) @@ -185,15 +174,6 @@ file_new_confirm_dialog_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (info->dlg, TRUE); } -static gint -file_new_confirm_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - file_new_confirm_dialog_cancel_callback (widget, data); - return TRUE; -} - static void file_new_confirm_dialog (NewImageInfo *info) { @@ -202,32 +182,21 @@ file_new_confirm_dialog (NewImageInfo *info) gchar *max_size; gchar *text; - static ActionAreaItem action_items[] = - { - { N_("OK"), - (ActionCallback) file_new_confirm_dialog_ok_callback, NULL, NULL }, - { N_("Cancel"), - (ActionCallback) file_new_confirm_dialog_cancel_callback, NULL, NULL } - }; - gtk_widget_set_sensitive (info->dlg, FALSE); - info->confirm_dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (info->confirm_dlg), - "confirm_size", "Gimp"); - gtk_window_set_title (GTK_WINDOW (info->confirm_dlg), _("Confirm Image Size")); - gtk_window_set_policy (GTK_WINDOW (info->confirm_dlg), FALSE, FALSE, FALSE); - gtk_window_position (GTK_WINDOW (info->confirm_dlg), GTK_WIN_POS_MOUSE); + info->confirm_dlg = + gimp_dialog_new (_("Confirm Image Size"), "confirm_size", + gimp_standard_help_func, + "dialogs/file_new_dialog.html#confirm_size_dialog", + GTK_WIN_POS_MOUSE, + FALSE, FALSE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (info->confirm_dlg), "delete_event", - (GtkSignalFunc) file_new_confirm_dialog_delete_callback, - info); + _("OK"), file_new_confirm_dialog_ok_callback, + info, NULL, TRUE, FALSE, + _("Cancel"), file_new_confirm_dialog_cancel_callback, + info, NULL, FALSE, TRUE, - /* The action area */ - action_items[0].user_data = info; - action_items[1].user_data = info; - build_action_area (GTK_DIALOG (info->confirm_dlg), action_items, 2, 0); + NULL); size = image_new_get_size_string (info->size); max_size = image_new_get_size_string (max_new_image_size); @@ -326,15 +295,14 @@ file_new_image_size_callback (GtkWidget *widget, gpointer data) { NewImageInfo *info; - gdouble width, height; gchar *text; gchar *label; info = (NewImageInfo*) data; - width = (gdouble) (gint) + info->values->width = (gdouble) (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0) + 0.5); - height = (gdouble) (gint) + info->values->height = (gdouble) (gint) (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1) + 0.5); info->size = image_new_calculate_size (info->values); @@ -391,35 +359,26 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) GSList *group; GList *list; - static ActionAreaItem action_items[] = - { - { N_("OK"), file_new_ok_callback, NULL, NULL }, - { N_("Reset"), file_new_reset_callback, NULL, NULL }, - { N_("Cancel"), file_new_cancel_callback, NULL, NULL } - }; - info = g_new (NewImageInfo, 1); info->values = values = image_new_values_new (values_orig); info->confirm_dlg = NULL; info->size = 0.0; - info->dlg = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (info->dlg), "new_image", "Gimp"); - gtk_window_set_title (GTK_WINDOW (info->dlg), _("New Image")); - gtk_window_set_position (GTK_WINDOW (info->dlg), GTK_WIN_POS_MOUSE); - gtk_window_set_policy(GTK_WINDOW (info->dlg), FALSE, FALSE, TRUE); + info->dlg = gimp_dialog_new (_("New Image"), "new_image", + gimp_standard_help_func, + "dialogs/file_new_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, FALSE, TRUE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (info->dlg), "delete_event", - GTK_SIGNAL_FUNC (file_new_delete_callback), - info); + _("OK"), file_new_ok_callback, + info, NULL, FALSE, FALSE, + _("Reset"), file_new_reset_callback, + info, NULL, FALSE, FALSE, + _("Cancel"), file_new_cancel_callback, + info, NULL, TRUE, TRUE, - /* The action area */ - action_items[0].user_data = info; - action_items[1].user_data = info; - action_items[2].user_data = info; - build_action_area (GTK_DIALOG (info->dlg), action_items, 3, 2); + NULL); /* vbox holding the rest of the dialog */ top_vbox = gtk_vbox_new (FALSE, 2); diff --git a/app/gui/gradient-editor.c b/app/gui/gradient-editor.c index c5c8a84b84..0274f668a0 100644 --- a/app/gui/gradient-editor.c +++ b/app/gui/gradient-editor.c @@ -150,7 +150,6 @@ #include #endif -#include "actionarea.h" #include "appenv.h" #include "colormaps.h" #include "cursorutil.h" @@ -158,8 +157,8 @@ #include "errors.h" #include "general.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "session.h" #include "gradient_header.h" @@ -209,8 +208,6 @@ static void ed_do_copy_gradient_callback (GtkWidget *, gpointer , gpointer); static void ed_delete_gradient_callback (GtkWidget *, gpointer); static void ed_do_delete_gradient_callback (GtkWidget *, gpointer); static void ed_cancel_delete_gradient_callback (GtkWidget *, gpointer); -static gint ed_delete_delete_gradient_callback (GtkWidget *, GdkEvent *, - gpointer); static void ed_rename_gradient_callback (GtkWidget *, gpointer); static void ed_do_rename_gradient_callback (GtkWidget *, gpointer, gpointer); @@ -222,8 +219,6 @@ static gint ed_delete_save_pov_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_save_grads_callback (GtkWidget *, gpointer); static void ed_refresh_grads_callback (GtkWidget *, gpointer); - -static gint ed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_close_callback (GtkWidget *, gpointer); /* Zoom, scrollbar & instant update callbacks */ @@ -248,27 +243,29 @@ static void prev_fill_image (int width, int height, /* Gradient control functions */ -static gint control_events (GtkWidget *, GdkEvent *, gpointer); -static void control_do_hint (gint x, gint y); -static void control_button_press (gint x, gint y, - guint button, guint state); -static int control_point_in_handle (gint x, gint y, grad_segment_t *seg, - control_drag_mode_t handle); -static void control_select_single_segment (grad_segment_t *seg); -static void control_extend_selection (grad_segment_t *seg, double pos); -static void control_motion (gint x); +static gint control_events (GtkWidget *, GdkEvent *, + gpointer); +static void control_do_hint (gint x, gint y); +static void control_button_press (gint x, gint y, + guint button, guint state); +static gboolean control_point_in_handle (gint x, gint y, + grad_segment_t *seg, + control_drag_mode_t handle); +static void control_select_single_segment (grad_segment_t *seg); +static void control_extend_selection (grad_segment_t *seg, double pos); +static void control_motion (gint x); -static void control_compress_left (grad_segment_t *range_l, - grad_segment_t *range_r, - grad_segment_t *drag_seg, +static void control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, double pos); -static void control_compress_range (grad_segment_t *range_l, - grad_segment_t *range_r, - double new_l, double new_r); +static void control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, double new_r); -static double control_move (grad_segment_t *range_l, - grad_segment_t *range_r, - double delta); +static double control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta); /* Control update/redraw functions */ @@ -379,8 +376,6 @@ static void cpopup_split_uniform_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_scale_update (GtkAdjustment *, gpointer); static void cpopup_split_uniform_split_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_split_uniform_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_split_uniform (grad_segment_t *lseg, int parts, grad_segment_t **newl, grad_segment_t **newr); @@ -398,8 +393,6 @@ static void cpopup_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_scale_update (GtkAdjustment *, gpointer); static void cpopup_do_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_replicate_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_blend_colors (GtkWidget *, gpointer); static void cpopup_blend_opacity (GtkWidget *, gpointer); @@ -668,13 +661,6 @@ grad_create_gradient_editor_init (gint need_show) gint i; gint select_pos; - static ActionAreaItem action_items[] = - { - { N_("Save"), ed_save_grads_callback, NULL, NULL }, - { N_("Refresh"), ed_refresh_grads_callback, NULL, NULL }, - { N_("Close"), ed_close_callback, NULL, NULL } - }; - /* If the editor already exists, just show it */ if (g_editor) { @@ -698,15 +684,20 @@ grad_create_gradient_editor_init (gint need_show) g_editor = g_new (gradient_editor_t, 1); /* Shell and main vbox */ - g_editor->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_editor", "Gimp"); - gtk_window_set_title (GTK_WINDOW (g_editor->shell), _("Gradient Editor")); + g_editor->shell = gimp_dialog_new (_("Gradient Editor"), "gradient_editor", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_callback), - NULL); + _("Save"), ed_save_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Refresh"), ed_refresh_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Close"), ed_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -881,7 +872,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (gvbox); /* Gradient preview */ - g_editor->preview_rows[0] = NULL; g_editor->preview_rows[1] = NULL; g_editor->preview_last_x = 0; @@ -905,7 +895,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (g_editor->preview); /* Gradient control */ - g_editor->control_pixmap = NULL; g_editor->control_drag_segment = NULL; g_editor->control_sel_l = NULL; @@ -967,9 +956,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_box_pack_start (GTK_BOX (vbox), g_editor->hint_label, FALSE, FALSE, 0); gtk_widget_show (g_editor->hint_label); - /* The action area */ - build_action_area (GTK_DIALOG (g_editor->shell), action_items, 3, 2); - /* Initialize other data */ g_editor->left_color_preview = NULL; g_editor->left_saved_segments = NULL; @@ -995,11 +981,8 @@ grad_create_gradient_editor_init (gint need_show) gtk_clist_moveto (GTK_CLIST (g_editor->clist), select_pos, 0, 0.0, 0.0); } - /***** Gradient editor functions *****/ -/*****/ - static void ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) { @@ -1319,17 +1302,20 @@ ed_initialize_saved_colors(void) /***** the "new gradient" dialog functions *****/ -/*****/ - static void ed_new_gradient_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box(_("New gradient"), - _("Enter a name for the new gradient"), - _("untitled"), - NULL, NULL, - ed_do_new_gradient_callback, NULL)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the new gradient"), + _("untitled"), + NULL, NULL, + ed_do_new_gradient_callback, NULL); + gtk_widget_show (qbox); } static void @@ -1373,12 +1359,11 @@ ed_do_new_gradient_callback (GtkWidget *widget, /***** The "copy gradient" dialog functions *****/ -/*****/ - static void ed_copy_gradient_callback (GtkWidget *widget, gpointer data) { + GtkWidget *qbox; gchar *name; if (curr_gradient == NULL) @@ -1386,13 +1371,16 @@ ed_copy_gradient_callback (GtkWidget *widget, name = g_strdup_printf (_("%s copy"), curr_gradient->name); - gtk_widget_show (query_string_box (_("Copy gradient"), - _("Enter a name for the copied gradient"), - name, - NULL, NULL, - ed_do_copy_gradient_callback, NULL)); + qbox = gimp_query_string_box (_("Copy gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the copied gradient"), + name, + NULL, NULL, + ed_do_copy_gradient_callback, NULL); + gtk_widget_show (qbox); - g_free(name); + g_free (name); } static void @@ -1460,21 +1448,24 @@ ed_do_copy_gradient_callback (GtkWidget *widget, /***** The "rename gradient" dialog functions *****/ -/*****/ - static void ed_rename_gradient_callback (GtkWidget *widget, - gpointer data) + gpointer data) { + GtkWidget *qbox; + if (curr_gradient == NULL) return; - gtk_widget_show (query_string_box (_("Rename gradient"), - _("Enter a new name for the gradient"), - curr_gradient->name, - NULL, NULL, - ed_do_rename_gradient_callback, - curr_gradient)); + qbox = gimp_query_string_box (_("Rename gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a new name for the gradient"), + curr_gradient->name, + NULL, NULL, + ed_do_rename_gradient_callback, + curr_gradient); + gtk_widget_show (qbox); } static void @@ -1536,8 +1527,6 @@ ed_do_rename_gradient_callback (GtkWidget *widget, /***** The "delete gradient" dialog functions *****/ -/*****/ - static void ed_delete_gradient_callback (GtkWidget *widget, gpointer data) @@ -1547,24 +1536,21 @@ ed_delete_gradient_callback (GtkWidget *widget, GtkWidget *label; gchar *str; - static ActionAreaItem action_items[] = - { - { N_("Delete"), ed_do_delete_gradient_callback, NULL, NULL }, - { N_("Cancel"), ed_cancel_delete_gradient_callback, NULL, NULL } - }; - if (num_gradients <= 1) return; - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "delete_gradient", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Delete gradient")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = gimp_dialog_new (_("Delete gradient"), "delete_gradient", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_delete_gradient_callback), - dialog); + _("Delete"), ed_do_delete_gradient_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), ed_cancel_delete_gradient_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -1572,9 +1558,9 @@ ed_delete_gradient_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); gtk_widget_show (vbox); - str = g_strdup_printf(_("Are you sure you want to delete\n" - "\"%s\" from the list and from disk?"), - curr_gradient->name); + str = g_strdup_printf (_("Are you sure you want to delete\n" + "\"%s\" from the list and from disk?"), + curr_gradient->name); label = gtk_label_new (str); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); @@ -1582,11 +1568,6 @@ ed_delete_gradient_callback (GtkWidget *widget, g_free (str); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1658,20 +1639,8 @@ ed_cancel_delete_gradient_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -ed_delete_delete_gradient_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_cancel_delete_gradient_callback (widget, data); - - return TRUE; -} - /***** The "save as pov" dialog functions *****/ -/*****/ - static void ed_save_pov_callback (GtkWidget *widget, gpointer data) @@ -1682,7 +1651,7 @@ ed_save_pov_callback (GtkWidget *widget, return; window = gtk_file_selection_new (_("Save as POV-Ray")); - gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); + gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button), "clicked", (GtkSignalFunc) ed_do_save_pov_callback, @@ -1696,6 +1665,10 @@ ed_save_pov_callback (GtkWidget *widget, (GdkEventFunc) ed_delete_save_pov_callback, window); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html"); + gtk_widget_show (window); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1771,8 +1744,6 @@ ed_delete_save_pov_callback (GtkWidget *widget, /***** The main dialog action area button callbacks *****/ -/*****/ - static void ed_save_grads_callback (GtkWidget *widget, gpointer data) @@ -1815,20 +1786,8 @@ ed_close_callback (GtkWidget *widget, gtk_widget_hide (g_editor->shell); } -static gint -ed_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_close_callback (widget, data); - - return TRUE; -} - /***** Zoom, scrollbar & instant update callbacks *****/ -/*****/ - static void ed_scrollbar_update (GtkAdjustment *adjustment, gpointer data) @@ -1942,8 +1901,6 @@ ed_instant_update_update (GtkWidget *widget, /***** Gradient preview functions *****/ -/*****/ - static gint prev_events (GtkWidget *widget, GdkEvent *event, @@ -2103,7 +2060,7 @@ prev_set_foreground (gint x) palette_set_foreground (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Foreground color set to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2126,7 +2083,7 @@ prev_set_background (gint x) palette_set_background (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Background color to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2229,54 +2186,58 @@ prev_update (gboolean recalculate) /*****/ static void -prev_fill_image(int width, int height, double left, double right) +prev_fill_image (int width, + int height, + double left, + double right) { - guchar *p0, *p1; - int x, y; - double dx, cur_x; - double r, g, b, a; - double c0, c1; + guchar *p0, *p1; + int x, y; + double dx, cur_x; + double r, g, b, a; + double c0, c1; - dx = (right - left) / (width - 1); - cur_x = left; - p0 = g_editor->preview_rows[0]; - p1 = g_editor->preview_rows[1]; + dx = (right - left) / (width - 1); + cur_x = left; + p0 = g_editor->preview_rows[0]; + p1 = g_editor->preview_rows[1]; - /* Create lines to fill the image */ + /* Create lines to fill the image */ + for (x = 0; x < width; x++) + { + grad_get_color_at (cur_x, &r, &g, &b, &a); - for (x = 0; x < width; x++) { - grad_get_color_at(cur_x, &r, &g, &b, &a); + if ((x / GRAD_CHECK_SIZE) & 1) + { + c0 = GRAD_CHECK_LIGHT; + c1 = GRAD_CHECK_DARK; + } + else + { + c0 = GRAD_CHECK_DARK; + c1 = GRAD_CHECK_LIGHT; + } - if ((x / GRAD_CHECK_SIZE) & 1) { - c0 = GRAD_CHECK_LIGHT; - c1 = GRAD_CHECK_DARK; - } else { - c0 = GRAD_CHECK_DARK; - c1 = GRAD_CHECK_LIGHT; - } /* else */ + *p0++ = (c0 + (r - c0) * a) * 255.0; + *p0++ = (c0 + (g - c0) * a) * 255.0; + *p0++ = (c0 + (b - c0) * a) * 255.0; - *p0++ = (c0 + (r - c0) * a) * 255.0; - *p0++ = (c0 + (g - c0) * a) * 255.0; - *p0++ = (c0 + (b - c0) * a) * 255.0; + *p1++ = (c1 + (r - c1) * a) * 255.0; + *p1++ = (c1 + (g - c1) * a) * 255.0; + *p1++ = (c1 + (b - c1) * a) * 255.0; - *p1++ = (c1 + (r - c1) * a) * 255.0; - *p1++ = (c1 + (g - c1) * a) * 255.0; - *p1++ = (c1 + (b - c1) * a) * 255.0; - - cur_x += dx; - } /* for */ - - /* Fill image */ - - for (y = 0; y < height; y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[1], 0, y, width); - else - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[0], 0, y, width); -} /* prev_fill_image */ + cur_x += dx; + } + /* Fill image */ + for (y = 0; y < height; y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[1], 0, y, width); + else + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[0], 0, y, width); +} /***** Gradient control functions *****/ @@ -2288,8 +2249,6 @@ prev_fill_image(int width, int height, double left, double right) * them yourself ;-) */ -/*****/ - static gint control_events (GtkWidget *widget, GdkEvent *event, @@ -2395,51 +2354,56 @@ control_events (GtkWidget *widget, /*****/ static void -control_do_hint(gint x, gint y) +control_do_hint (gint x, + gint y) { - grad_segment_t *seg; - control_drag_mode_t handle; - int in_handle; - double pos; + grad_segment_t *seg; + control_drag_mode_t handle; + gboolean in_handle; + double pos; - pos = control_calc_g_pos(x); + pos = control_calc_g_pos (x); - if ((pos < 0.0) || (pos > 1.0)) - return; + if ((pos < 0.0) || (pos > 1.0)) + return; - seg_get_closest_handle(curr_gradient, pos, &seg, &handle); + seg_get_closest_handle (curr_gradient, pos, &seg, &handle); - in_handle = control_point_in_handle(x, y, seg, handle); + in_handle = control_point_in_handle (x, y, seg, handle); - if (in_handle) { - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg != NULL) { - if (seg->prev != NULL) - ed_set_hint(_("Drag: move Shift+drag: move & compress")); - else - ed_set_hint(_("Click: select Shift+click: extend selection")); - } else - ed_set_hint(_("Click: select Shift+click: extend selection")); + if (in_handle) + { + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg != NULL) + { + if (seg->prev != NULL) + ed_set_hint (_("Drag: move Shift+drag: move & compress")); + else + ed_set_hint (_("Click: select Shift+click: extend selection")); + } + else + ed_set_hint (_("Click: select Shift+click: extend selection")); - break; + break; - case GRAD_DRAG_MIDDLE: - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move")); + case GRAD_DRAG_MIDDLE: + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move")); - break; - - default: - g_message ("control_do_hint: oops, in_handle is true " - "yet we got handle type %d", (int) handle); - break; - } /* switch */ - } else - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move Shift+drag: move & compress")); -} /* control_do_hint */ + break; + default: + g_message ("control_do_hint: oops, in_handle is true " + "yet we got handle type %d", (int) handle); + break; + } + } + else + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move Shift+drag: move & compress")); +} /*****/ @@ -2452,7 +2416,7 @@ control_button_press (gint x, grad_segment_t *seg; control_drag_mode_t handle; double xpos; - gint in_handle; + gboolean in_handle; /* See which button was pressed */ @@ -2592,343 +2556,370 @@ control_button_press (gint x, /*****/ -static int -control_point_in_handle(gint x, gint y, grad_segment_t *seg, control_drag_mode_t handle) +static gboolean +control_point_in_handle (gint x, + gint y, + grad_segment_t *seg, + control_drag_mode_t handle) { - gint handle_pos; + gint handle_pos; - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - handle_pos = control_calc_p_pos(seg->left); - else { - seg = seg_get_last_segment(curr_gradient->segments); + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + handle_pos = control_calc_p_pos (seg->left); + else + { + seg = seg_get_last_segment (curr_gradient->segments); - handle_pos = control_calc_p_pos(seg->right); - } /* else */ + handle_pos = control_calc_p_pos (seg->right); + } - break; + break; - case GRAD_DRAG_MIDDLE: - handle_pos = control_calc_p_pos(seg->middle); - break; + case GRAD_DRAG_MIDDLE: + handle_pos = control_calc_p_pos (seg->middle); + break; - default: - g_message ("control_point_in_handle(): oops, can not handle drag mode %d", - (int) handle); - return 0; - } /* switch */ + default: + g_message ("control_point_in_handle(): oops, can not handle drag mode %d", + (int) handle); + return FALSE; + } - y /= 2; - - if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) - return 1; - else - return 0; -} /* control_point_in_handle */ + y /= 2; + if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) + return TRUE; + else + return FALSE; +} /*****/ static void -control_select_single_segment(grad_segment_t *seg) +control_select_single_segment (grad_segment_t *seg) { - g_editor->control_sel_l = seg; - g_editor->control_sel_r = seg; -} /* control_select_single_segment */ - + g_editor->control_sel_l = seg; + g_editor->control_sel_r = seg; +} /*****/ static void -control_extend_selection(grad_segment_t *seg, double pos) +control_extend_selection (grad_segment_t *seg, + double pos) { - if (fabs(pos - g_editor->control_sel_l->left) < fabs(pos - g_editor->control_sel_r->right)) - g_editor->control_sel_l = seg; - else - g_editor->control_sel_r = seg; -} /* control_extend_selection */ - + if (fabs (pos - g_editor->control_sel_l->left) < + fabs(pos - g_editor->control_sel_r->right)) + g_editor->control_sel_l = seg; + else + g_editor->control_sel_r = seg; +} /*****/ static void -control_motion(gint x) +control_motion (gint x) { - grad_segment_t *seg; - double pos; - double delta; - char str[256]; + grad_segment_t *seg; + double pos; + double delta; + char str[256]; - seg = g_editor->control_drag_segment; + seg = g_editor->control_drag_segment; - switch (g_editor->control_drag_mode) { - case GRAD_DRAG_LEFT: - pos = control_calc_g_pos(x); + switch (g_editor->control_drag_mode) + { + case GRAD_DRAG_LEFT: + pos = control_calc_g_pos (x); - if (!g_editor->control_compress) - seg->prev->right = seg->left = BOUNDS(pos, - seg->prev->middle + EPSILON, - seg->middle - EPSILON); - else - control_compress_left(g_editor->control_sel_l, - g_editor->control_sel_r, - seg, pos); + if (!g_editor->control_compress) + seg->prev->right = seg->left = BOUNDS (pos, + seg->prev->middle + EPSILON, + seg->middle - EPSILON); + else + control_compress_left (g_editor->control_sel_l, + g_editor->control_sel_r, + seg, pos); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->left); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->left); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_MIDDLE: - pos = control_calc_g_pos(x); - seg->middle = BOUNDS(pos, seg->left + EPSILON, seg->right - EPSILON); + case GRAD_DRAG_MIDDLE: + pos = control_calc_g_pos (x); + seg->middle = BOUNDS (pos, seg->left + EPSILON, seg->right - EPSILON); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->middle); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->middle); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_ALL: - pos = control_calc_g_pos(x); - delta = pos - g_editor->control_last_gx; + case GRAD_DRAG_ALL: + pos = control_calc_g_pos (x); + delta = pos - g_editor->control_last_gx; - if ((seg->left >= g_editor->control_sel_l->left) && - (seg->right <= g_editor->control_sel_r->right)) - delta = control_move(g_editor->control_sel_l, g_editor->control_sel_r, delta); - else - delta = control_move(seg, seg, delta); + if ((seg->left >= g_editor->control_sel_l->left) && + (seg->right <= g_editor->control_sel_r->right)) + delta = control_move (g_editor->control_sel_l, + g_editor->control_sel_r, delta); + else + delta = control_move (seg, seg, delta); - g_editor->control_last_gx += delta; + g_editor->control_last_gx += delta; - g_snprintf(str, sizeof(str), _("Distance: %0.6f"), - g_editor->control_last_gx - g_editor->control_orig_pos); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Distance: %0.6f"), + g_editor->control_last_gx - g_editor->control_orig_pos); + ed_set_hint (str); - break; + break; - default: - gimp_fatal_error(_("control_motion(): Attempt to move bogus handle %d"), - (int) g_editor->control_drag_mode); - break; - } /* switch */ + default: + gimp_fatal_error (_("control_motion(): Attempt to move bogus handle %d"), + (int) g_editor->control_drag_mode); + break; + } - curr_gradient->dirty = 1; - - if (g_editor->instant_update) - ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); - else - ed_update_editor(GRAD_UPDATE_CONTROL); -} /* control_motion */ + curr_gradient->dirty = 1; + if (g_editor->instant_update) + ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); + else + ed_update_editor (GRAD_UPDATE_CONTROL); +} /*****/ static void -control_compress_left(grad_segment_t *range_l, grad_segment_t *range_r, - grad_segment_t *drag_seg, double pos) +control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, + double pos) { - grad_segment_t *seg; - double lbound, rbound; - int k; + grad_segment_t *seg; + double lbound, rbound; + int k; - /* Check what we have to compress */ + /* Check what we have to compress */ - if (!((drag_seg->left >= range_l->left) && - ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) { - /* We are compressing a segment outside the selection */ + if (!((drag_seg->left >= range_l->left) && + ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) + { + /* We are compressing a segment outside the selection */ - range_l = range_r = drag_seg; - } /* else */ + range_l = range_r = drag_seg; + } - /* Calculate left bound for dragged hadle */ + /* Calculate left bound for dragged hadle */ - if (drag_seg == range_l) - lbound = range_l->prev->left + 2.0 * EPSILON; - else { - /* Count number of segments to the left of the dragged handle */ + if (drag_seg == range_l) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + { + /* Count number of segments to the left of the dragged handle */ - seg = drag_seg; - k = 0; + seg = drag_seg; + k = 0; - while (seg != range_l) { - k++; - seg = seg->prev; - } /* while */ + while (seg != range_l) + { + k++; + seg = seg->prev; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - lbound = range_l->left + 2.0 * k * EPSILON; - } /* else */ + lbound = range_l->left + 2.0 * k * EPSILON; + } - /* Calculate right bound for dragged handle */ + /* Calculate right bound for dragged handle */ - if (drag_seg == range_r->next) - rbound = range_r->next->right - 2.0 * EPSILON; - else { - /* Count number of segments to the right of the dragged handle */ + if (drag_seg == range_r->next) + rbound = range_r->next->right - 2.0 * EPSILON; + else + { + /* Count number of segments to the right of the dragged handle */ - seg = drag_seg; - k = 1; + seg = drag_seg; + k = 1; - while (seg != range_r) { - k++; - seg = seg->next; - } /* while */ + while (seg != range_r) + { + k++; + seg = seg->next; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - rbound = range_r->right - 2.0 * k * EPSILON; - } /* else */ + rbound = range_r->right - 2.0 * k * EPSILON; + } - /* Calculate position */ + /* Calculate position */ - pos = BOUNDS(pos, lbound, rbound); + pos = BOUNDS (pos, lbound, rbound); - /* Compress segments to the left of the handle */ + /* Compress segments to the left of the handle */ - if (drag_seg == range_l) - control_compress_range(range_l->prev, range_l->prev, range_l->prev->left, pos); - else - control_compress_range(range_l, drag_seg->prev, range_l->left, pos); + if (drag_seg == range_l) + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, pos); + else + control_compress_range (range_l, drag_seg->prev, range_l->left, pos); - /* Compress segments to the right of the handle */ - - if (drag_seg != range_r->next) - control_compress_range(drag_seg, range_r, pos, range_r->right); - else - control_compress_range(drag_seg, drag_seg, pos, drag_seg->right); -} /* control_compress_left */ + /* Compress segments to the right of the handle */ + if (drag_seg != range_r->next) + control_compress_range (drag_seg, range_r, pos, range_r->right); + else + control_compress_range (drag_seg, drag_seg, pos, drag_seg->right); +} /*****/ static void -control_compress_range(grad_segment_t *range_l, grad_segment_t *range_r, - double new_l, double new_r) +control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, + double new_r) { - double orig_l, orig_r; - double scale; - grad_segment_t *seg, *aseg; + double orig_l, orig_r; + double scale; + grad_segment_t *seg, *aseg; - orig_l = range_l->left; - orig_r = range_r->right; + orig_l = range_l->left; + orig_r = range_r->right; - scale = (new_r - new_l) / (orig_r - orig_l); + scale = (new_r - new_l) / (orig_r - orig_l); - seg = range_l; + seg = range_l; - do { - seg->left = new_l + (seg->left - orig_l) * scale; - seg->middle = new_l + (seg->middle - orig_l) * scale; - seg->right = new_l + (seg->right - orig_l) * scale; + do + { + seg->left = new_l + (seg->left - orig_l) * scale; + seg->middle = new_l + (seg->middle - orig_l) * scale; + seg->right = new_l + (seg->right - orig_l) * scale; - /* Next */ - - aseg = seg; - seg = seg->next; - } while (aseg != range_r); -} /* control_compress_range */ + /* Next */ + aseg = seg; + seg = seg->next; + } while (aseg != range_r); +} /*****/ static double -control_move(grad_segment_t *range_l, grad_segment_t *range_r, double delta) +control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta) { - double lbound, rbound; - int is_first, is_last; - grad_segment_t *seg, *aseg; + double lbound, rbound; + int is_first, is_last; + grad_segment_t *seg, *aseg; - /* First or last segments in gradient? */ + /* First or last segments in gradient? */ - is_first = (range_l->prev == NULL); - is_last = (range_r->next == NULL); + is_first = (range_l->prev == NULL); + is_last = (range_r->next == NULL); - /* Calculate drag bounds */ + /* Calculate drag bounds */ - if (!g_editor->control_compress) { - if (!is_first) - lbound = range_l->prev->middle + EPSILON; - else - lbound = range_l->left + EPSILON; + if (!g_editor->control_compress) + { + if (!is_first) + lbound = range_l->prev->middle + EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->middle - EPSILON; - else - rbound = range_r->right - EPSILON; - } else { - if (!is_first) - lbound = range_l->prev->left + 2.0 * EPSILON; - else - lbound = range_l->left + EPSILON; + if (!is_last) + rbound = range_r->next->middle - EPSILON; + else + rbound = range_r->right - EPSILON; + } + else + { + if (!is_first) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->right - 2.0 * EPSILON; - else - rbound = range_r->right - EPSILON; - } /* if */ + if (!is_last) + rbound = range_r->next->right - 2.0 * EPSILON; + else + rbound = range_r->right - EPSILON; + } - /* Fix the delta if necessary */ + /* Fix the delta if necessary */ - if (delta < 0.0) { - if (!is_first) { - if (range_l->left + delta < lbound) - delta = lbound - range_l->left; - } else - if (range_l->middle + delta < lbound) - delta = lbound - range_l->middle; - } else { - if (!is_last) { - if (range_r->right + delta > rbound) - delta = rbound - range_r->right; - } else - if (range_r->middle + delta > rbound) - delta = rbound - range_r->middle; - } /* else */ + if (delta < 0.0) + { + if (!is_first) + { + if (range_l->left + delta < lbound) + delta = lbound - range_l->left; + } + else + if (range_l->middle + delta < lbound) + delta = lbound - range_l->middle; + } + else + { + if (!is_last) + { + if (range_r->right + delta > rbound) + delta = rbound - range_r->right; + } + else + if (range_r->middle + delta > rbound) + delta = rbound - range_r->middle; + } - /* Move all the segments inside the range */ + /* Move all the segments inside the range */ - seg = range_l; + seg = range_l; - do { - if (!((seg == range_l) && is_first)) - seg->left += delta; + do + { + if (!((seg == range_l) && is_first)) + seg->left += delta; - seg->middle += delta; + seg->middle += delta; - if (!((seg == range_r) && is_last)) - seg->right += delta; + if (!((seg == range_r) && is_last)) + seg->right += delta; - /* Next */ + /* Next */ - aseg = seg; - seg = seg->next; - } while (aseg != range_r); + aseg = seg; + seg = seg->next; + } + while (aseg != range_r); - /* Fix the segments that surround the range */ + /* Fix the segments that surround the range */ - if (!is_first) - { - if (!g_editor->control_compress) - range_l->prev->right = range_l->left; - else - control_compress_range(range_l->prev, range_l->prev, - range_l->prev->left, range_l->left); - } + if (!is_first) + { + if (!g_editor->control_compress) + range_l->prev->right = range_l->left; + else + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, range_l->left); + } - if (!is_last) - { - if (!g_editor->control_compress) - range_r->next->left = range_r->right; - else - control_compress_range(range_r->next, range_r->next, - range_r->right, range_r->next->right); - } - - return delta; -} /* control_move */ + if (!is_last) + { + if (!g_editor->control_compress) + range_r->next->left = range_r->right; + else + control_compress_range (range_r->next, range_r->next, + range_r->right, range_r->next->right); + } + return delta; +} /*****/ @@ -2990,158 +2981,162 @@ control_update (gboolean recalculate) /*****/ static void -control_draw(GdkPixmap *pixmap, int width, int height, double left, double right) +control_draw (GdkPixmap *pixmap, + int width, + int height, + double left, + double right) { - int sel_l, sel_r; - double g_pos; - grad_segment_t *seg; - control_drag_mode_t handle; + int sel_l, sel_r; + double g_pos; + grad_segment_t *seg; + control_drag_mode_t handle; - /* Clear the pixmap */ + /* Clear the pixmap */ - gdk_draw_rectangle(pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], - TRUE, 0, 0, width, height); + gdk_draw_rectangle (pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], + TRUE, 0, 0, width, height); - /* Draw selection */ + /* Draw selection */ - sel_l = control_calc_p_pos(g_editor->control_sel_l->left); - sel_r = control_calc_p_pos(g_editor->control_sel_r->right); + sel_l = control_calc_p_pos (g_editor->control_sel_l->left); + sel_r = control_calc_p_pos (g_editor->control_sel_r->right); - gdk_draw_rectangle(pixmap, g_editor->control->style->dark_gc[GTK_STATE_NORMAL], - TRUE, sel_l, 0, sel_r - sel_l + 1, height); + gdk_draw_rectangle (pixmap, + g_editor->control->style->dark_gc[GTK_STATE_NORMAL], + TRUE, sel_l, 0, sel_r - sel_l + 1, height); - /* Draw handles */ + /* Draw handles */ - seg = curr_gradient->segments; + seg = curr_gradient->segments; - while (seg) { - control_draw_normal_handle(pixmap, seg->left, height); - control_draw_middle_handle(pixmap, seg->middle, height); + while (seg) + { + control_draw_normal_handle (pixmap, seg->left, height); + control_draw_middle_handle (pixmap, seg->middle, height); - /* Draw right handle only if this is the last segment */ + /* Draw right handle only if this is the last segment */ - if (seg->next == NULL) - control_draw_normal_handle(pixmap, seg->right, height); + if (seg->next == NULL) + control_draw_normal_handle (pixmap, seg->right, height); - /* Next! */ + /* Next! */ - seg = seg->next; - } /* while */ + seg = seg->next; + } - /* Draw the handle which is closest to the mouse position */ + /* Draw the handle which is closest to the mouse position */ - g_pos = control_calc_g_pos(g_editor->control_last_x); + g_pos = control_calc_g_pos (g_editor->control_last_x); - seg_get_closest_handle(curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); + seg_get_closest_handle (curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - control_draw_normal_handle(pixmap, seg->left, height); - else { - seg = seg_get_last_segment(curr_gradient->segments); - control_draw_normal_handle(pixmap, seg->right, height); - } /* else */ + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + control_draw_normal_handle (pixmap, seg->left, height); + else + { + seg = seg_get_last_segment (curr_gradient->segments); + control_draw_normal_handle (pixmap, seg->right, height); + } - break; + break; - case GRAD_DRAG_MIDDLE: - control_draw_middle_handle(pixmap, seg->middle, height); - break; - - default: - break; - } /* switch */ -} /* control_draw */ + case GRAD_DRAG_MIDDLE: + control_draw_middle_handle (pixmap, seg->middle, height); + break; + default: + break; + } +} /*****/ static void -control_draw_normal_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_normal_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->black_gc, - control_calc_p_pos(pos), height); -} /* control_draw_normal_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->black_gc, + control_calc_p_pos (pos), height); +} static void -control_draw_middle_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_middle_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], - control_calc_p_pos(pos), height); -} /* control_draw_middle_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], + control_calc_p_pos(pos), height); +} static void -control_draw_handle(GdkPixmap *pixmap, GdkGC *border_gc, GdkGC *fill_gc, int xpos, int height) +control_draw_handle (GdkPixmap *pixmap, + GdkGC *border_gc, + GdkGC *fill_gc, + int xpos, + int height) { - int y; - int left, right, bottom; + int y; + int left, right, bottom; - for (y = 0; y < height; y++) - gdk_draw_line(pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); + for (y = 0; y < height; y++) + gdk_draw_line (pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); - bottom = height - 1; - left = xpos - bottom / 2; - right = xpos + bottom / 2; - - gdk_draw_line(pixmap, border_gc, xpos, 0, left, bottom); - gdk_draw_line(pixmap, border_gc, xpos, 0, right, bottom); - gdk_draw_line(pixmap, border_gc, left, bottom, right, bottom); -} /* control_draw_handle */ + bottom = height - 1; + left = xpos - bottom / 2; + right = xpos + bottom / 2; + gdk_draw_line (pixmap, border_gc, xpos, 0, left, bottom); + gdk_draw_line (pixmap, border_gc, xpos, 0, right, bottom); + gdk_draw_line (pixmap, border_gc, left, bottom, right, bottom); +} /*****/ static int -control_calc_p_pos(double pos) +control_calc_p_pos (double pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the position (in widget's coordinates) of the - * requested point from the gradient. Rounding is done to - * minimize mismatches between the rendered gradient preview - * and the gradient control's handles. - */ + /* Calculate the position (in widget's coordinates) of the + * requested point from the gradient. Rounding is done to + * minimize mismatches between the rendered gradient preview + * and the gradient control's handles. + */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); -} /* control_calc_p_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); +} /*****/ static double -control_calc_g_pos(int pos) +control_calc_g_pos (int pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the gradient position that corresponds to widget's coordinates */ + /* Calculate the gradient position that corresponds to widget's coordinates */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; -} /* control_calc_g_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; +} /***** Control popup functions *****/ -/*****/ - static void cpopup_create_main_menu (void) { @@ -3350,8 +3345,6 @@ cpopup_do_popup (void) /***** Create a single menu item *****/ -/*****/ - static GtkWidget * cpopup_create_color_item (GtkWidget **color_box, GtkWidget **label) @@ -3416,8 +3409,6 @@ cpopup_create_menu_item_with_label (gchar *str, /***** Update all menus *****/ -/*****/ - static void cpopup_adjust_menus (void) { @@ -3677,79 +3668,87 @@ cpopup_check_selection_params (gint *equal_blending, /*****/ static void -cpopup_render_color_box(GtkPreview *preview, double r, double g, double b, double a) +cpopup_render_color_box (GtkPreview *preview, + double r, + double g, + double b, + double a) { - guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; - int x, y; - int r0, g0, b0; - int r1, g1, b1; - guchar *p0, *p1, *p2; + guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; + int x, y; + int r0, g0, b0; + int r1, g1, b1; + guchar *p0, *p1, *p2; - /* Fill rows */ + /* Fill rows */ - r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; - r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; + r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; + r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; - g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; - g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; + g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; + g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; - b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; - b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; + b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; + b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; - p0 = rows[0]; - p1 = rows[1]; - p2 = rows[2]; + p0 = rows[0]; + p1 = rows[1]; + p2 = rows[2]; - for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) { - if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) { - *p0++ = 0; - *p0++ = 0; - *p0++ = 0; + for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) + { + if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) + { + *p0++ = 0; + *p0++ = 0; + *p0++ = 0; - *p1++ = 0; - *p1++ = 0; - *p1++ = 0; - } else - if ((x / GRAD_CHECK_SIZE) & 1) { - *p0++ = r1; - *p0++ = g1; - *p0++ = b1; + *p1++ = 0; + *p1++ = 0; + *p1++ = 0; + } + else + if ((x / GRAD_CHECK_SIZE) & 1) + { + *p0++ = r1; + *p0++ = g1; + *p0++ = b1; - *p1++ = r0; - *p1++ = g0; - *p1++ = b0; - } else { - *p0++ = r0; - *p0++ = g0; - *p0++ = b0; + *p1++ = r0; + *p1++ = g0; + *p1++ = b0; + } + else + { + *p0++ = r0; + *p0++ = g0; + *p0++ = b0; - *p1++ = r1; - *p1++ = g1; - *p1++ = b1; - } /* else */ + *p1++ = r1; + *p1++ = g1; + *p1++ = b1; + } - *p2++ = 0; - *p2++ = 0; - *p2++ = 0; - } /* for */ + *p2++ = 0; + *p2++ = 0; + *p2++ = 0; + } - /* Fill preview */ + /* Fill preview */ - gtk_preview_draw_row(preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); + gtk_preview_draw_row (preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); - for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); - else - gtk_preview_draw_row(preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); + for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); + else + gtk_preview_draw_row (preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); - gtk_preview_draw_row(preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); -} /* cpopup_render_color_box */ + gtk_preview_draw_row (preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); +} /***** Creale load & save menus *****/ -/*****/ - static GtkWidget * cpopup_create_load_menu (GtkWidget **color_boxes, GtkWidget **labels, @@ -3824,8 +3823,8 @@ cpopup_create_load_menu (GtkWidget **color_boxes, } static GtkWidget * -cpopup_create_save_menu (GtkWidget **color_boxes, - GtkWidget **labels, +cpopup_create_save_menu (GtkWidget **color_boxes, + GtkWidget **labels, GtkSignalFunc callback) { GtkWidget *menu; @@ -3846,324 +3845,328 @@ cpopup_create_save_menu (GtkWidget **color_boxes, return menu; } +/*****/ + +static void +cpopup_update_saved_color (int n, + double r, + double g, + double b, + double a) +{ + char str[256]; + + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_save_color_boxes[n]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_save_color_boxes[n]), + r, g, b, a); + + g_snprintf (str, sizeof (str), + _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + + gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + + g_editor->saved_colors[n].r = r; + g_editor->saved_colors[n].g = g; + g_editor->saved_colors[n].b = b; + g_editor->saved_colors[n].a = a; +} /*****/ static void -cpopup_update_saved_color(int n, double r, double g, double b, double a) +cpopup_load_left_callback (GtkWidget *widget, + gpointer data) { - char str[256]; + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_save_color_boxes[n]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_save_color_boxes[n]), - r, g, b, a); + switch ((long) data) + { + case 0: /* Fetch from left neighbor's right endpoint */ + if (g_editor->control_sel_l->prev != NULL) + seg = g_editor->control_sel_l->prev; + else + seg = seg_get_last_segment (g_editor->control_sel_l); - g_snprintf(str, sizeof(str), _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + cpopup_blend_endpoints (seg->r1, seg->g1, seg->b1, seg->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + case 1: /* Fetch from right endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - g_editor->saved_colors[n].r = r; - g_editor->saved_colors[n].g = g; - g_editor->saved_colors[n].b = b; - g_editor->saved_colors[n].a = a; -} /* cpopup_update_saved_color */ + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (fg_r, + fg_g, + fg_b, + fg_a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_left_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; +} + +static void +cpopup_load_right_callback (GtkWidget *widget, + gpointer data) +{ + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; + + switch ((long) data) + { + case 0: /* Fetch from right neighbor's left endpoint */ + if (g_editor->control_sel_r->next != NULL) + seg = g_editor->control_sel_r->next; + else + seg = curr_gradient->segments; + + cpopup_blend_endpoints (g_editor->control_sel_r->r0, + g_editor->control_sel_r->g0, + g_editor->control_sel_r->b0, + g_editor->control_sel_r->a0, + seg->r0, seg->g0, seg->b0, seg->a0, + TRUE, TRUE); + break; + + case 1: /* Fetch from left endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + TRUE, TRUE); + break; + + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + fg_r, + fg_g, + fg_b, + fg_a, + TRUE, TRUE); + break; + + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_right_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; +} /*****/ static void -cpopup_load_left_callback(GtkWidget *widget, gpointer data) +cpopup_set_color_selection_color (GtkColorSelection *cs, + double r, + double g, + double b, + double a) { - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; + gdouble color[4]; - switch ((long) data) { - case 0: /* Fetch from left neighbor's right endpoint */ - if (g_editor->control_sel_l->prev != NULL) - seg = g_editor->control_sel_l->prev; - else - seg = seg_get_last_segment(g_editor->control_sel_l); - - cpopup_blend_endpoints(seg->r1, seg->g1, seg->b1, seg->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 1: /* Fetch from right endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(fg_r, - fg_g, - fg_b, - fg_a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_left_callback */ + color[0] = r; + color[1] = g; + color[2] = b; + color[3] = a; + gtk_color_selection_set_color (cs, color); +} /*****/ static void -cpopup_save_left_callback(GtkWidget *widget, gpointer data) +cpopup_get_color_selection_color (GtkColorSelection *cs, + double *r, + double *g, + double *b, + double *a) { - g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; -} /* cpopup_save_left_callback */ + gdouble color[4]; + gtk_color_selection_get_color (cs, color); -/*****/ - -static void -cpopup_load_right_callback(GtkWidget *widget, gpointer data) -{ - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; - - switch ((long) data) { - case 0: /* Fetch from right neighbor's left endpoint */ - if (g_editor->control_sel_r->next != NULL) - seg = g_editor->control_sel_r->next; - else - seg = curr_gradient->segments; - - cpopup_blend_endpoints(g_editor->control_sel_r->r0, - g_editor->control_sel_r->g0, - g_editor->control_sel_r->b0, - g_editor->control_sel_r->a0, - seg->r0, seg->g0, seg->b0, seg->a0, - TRUE, TRUE); - break; - - case 1: /* Fetch from left endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - fg_r, - fg_g, - fg_b, - fg_a, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_right_callback */ - - -/*****/ - -static void -cpopup_save_right_callback(GtkWidget *widget, gpointer data) -{ - g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; -} /* cpopup_save_right_callback */ - - -/*****/ - -static void -cpopup_set_color_selection_color(GtkColorSelection *cs, - double r, double g, double b, double a) -{ - gdouble color[4]; - - color[0] = r; - color[1] = g; - color[2] = b; - color[3] = a; - - gtk_color_selection_set_color(cs, color); -} /* cpopup_set_color_selection_color */ - - -/*****/ - -static void -cpopup_get_color_selection_color(GtkColorSelection *cs, - double *r, double *g, double *b, double *a) -{ - gdouble color[4]; - - gtk_color_selection_get_color(cs, color); - - *r = color[0]; - *g = color[1]; - *b = color[2]; - *a = color[3]; -} /* cpopup_get_color_selection_color */ - + *r = color[0]; + *g = color[1]; + *b = color[2]; + *a = color[3]; +} /*****/ static grad_segment_t * -cpopup_save_selection(void) +cpopup_save_selection (void) { - grad_segment_t *seg, *prev, *tmp; - grad_segment_t *oseg, *oaseg; + grad_segment_t *seg, *prev, *tmp; + grad_segment_t *oseg, *oaseg; - prev = NULL; - oseg = g_editor->control_sel_l; - tmp = NULL; + prev = NULL; + oseg = g_editor->control_sel_l; + tmp = NULL; - do { - seg = seg_new_segment(); + do + { + seg = seg_new_segment (); - *seg = *oseg; /* Copy everything */ + *seg = *oseg; /* Copy everything */ - if (prev == NULL) - tmp = seg; /* Remember first segment */ - else - prev->next = seg; + if (prev == NULL) + tmp = seg; /* Remember first segment */ + else + prev->next = seg; - seg->prev = prev; - seg->next = NULL; + seg->prev = prev; + seg->next = NULL; - prev = seg; - oaseg = oseg; - oseg = oseg->next; - } while (oaseg != g_editor->control_sel_r); - - return tmp; -} /* cpopup_save_selection */ + prev = seg; + oaseg = oseg; + oseg = oseg->next; + } + while (oaseg != g_editor->control_sel_r); + return tmp; +} /*****/ static void -cpopup_free_selection(grad_segment_t *seg) +cpopup_free_selection (grad_segment_t *seg) { - seg_free_segments(seg); -} /* cpopup_free_selection */ - + seg_free_segments (seg); +} /*****/ static void -cpopup_replace_selection(grad_segment_t *replace_seg) +cpopup_replace_selection (grad_segment_t *replace_seg) { - grad_segment_t *lseg, *rseg; - grad_segment_t *replace_last; + grad_segment_t *lseg, *rseg; + grad_segment_t *replace_last; - /* Remember left and right segments */ + /* Remember left and right segments */ - lseg = g_editor->control_sel_l->prev; - rseg = g_editor->control_sel_r->next; + lseg = g_editor->control_sel_l->prev; + rseg = g_editor->control_sel_r->next; - replace_last = seg_get_last_segment(replace_seg); + replace_last = seg_get_last_segment (replace_seg); - /* Free old selection */ + /* Free old selection */ - g_editor->control_sel_r->next = NULL; + g_editor->control_sel_r->next = NULL; - seg_free_segments(g_editor->control_sel_l); + seg_free_segments (g_editor->control_sel_l); - /* Link in new segments */ + /* Link in new segments */ - if (lseg) - lseg->next = replace_seg; - else - curr_gradient->segments = replace_seg; + if (lseg) + lseg->next = replace_seg; + else + curr_gradient->segments = replace_seg; - replace_seg->prev = lseg; + replace_seg->prev = lseg; - if (rseg) - rseg->prev = replace_last; + if (rseg) + rseg->prev = replace_last; - replace_last->next = rseg; + replace_last->next = rseg; - g_editor->control_sel_l = replace_seg; - g_editor->control_sel_r = replace_last; + g_editor->control_sel_l = replace_seg; + g_editor->control_sel_r = replace_last; - curr_gradient->last_visited = NULL; /* Force re-search */ -} /* cpopup_replace_selection */ + curr_gradient->last_visited = NULL; /* Force re-search */ +} /***** Color dialogs for left and right endpoint *****/ -/*****/ - static void -cpopup_create_color_dialog (gchar *title, - double r, double g, double b, double a, - GtkSignalFunc color_changed_callback, - GtkSignalFunc ok_callback, - GtkSignalFunc cancel_callback, - GtkSignalFunc delete_callback) +cpopup_create_color_dialog (gchar *title, + double r, + double g, + double b, + double a, + GtkSignalFunc color_changed_callback, + GtkSignalFunc ok_callback, + GtkSignalFunc cancel_callback, + GtkSignalFunc delete_callback) { GtkWidget *window; GtkColorSelection *cs; @@ -4360,8 +4363,6 @@ cpopup_right_color_dialog_delete (GtkWidget *widget, /***** Blending menu *****/ -/*****/ - static GtkWidget * cpopup_create_blending_menu (void) { @@ -4432,8 +4433,6 @@ cpopup_blending_callback (GtkWidget *widget, /***** Coloring menu *****/ -/*****/ - static GtkWidget * cpopup_create_coloring_menu (void) { @@ -4593,26 +4592,23 @@ cpopup_split_uniform_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Split"), cpopup_split_uniform_split_callback, NULL, NULL }, - { N_("Cancel"), cpopup_split_uniform_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_segment_split_uniformly", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Split segment uniformly") : - _("Split segments uniformly")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Split segment uniformly") : + _("Split segments uniformly"), + "gradient_segment_split_uniformly", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_split_uniform_delete_callback), - dialog); + _("Split"), cpopup_split_uniform_split_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), cpopup_split_uniform_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -4646,11 +4642,6 @@ cpopup_split_uniform_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_split_uniform_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 0); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -4704,16 +4695,6 @@ cpopup_split_uniform_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_split_uniform_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_split_uniform_cancel_callback (widget, data); - - return TRUE; -} - static void cpopup_split_uniform (grad_segment_t *lseg, int parts, @@ -4958,8 +4939,6 @@ cpopup_redistribute_callback (GtkWidget *widget, /***** Control popup -> selection options functions *****/ -/*****/ - static GtkWidget * cpopup_create_sel_ops_menu (void) { @@ -5172,26 +5151,23 @@ cpopup_replicate_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Replicate"), cpopup_do_replicate_callback, NULL, NULL }, - { N_("Cancel"), cpopup_replicate_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), - "gradient_segment_replicate", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Replicate segment") : - _("Replicate selection")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Replicate segment") : + _("Replicate selection"), + "gradient_segment_replicate", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_replicate_delete_callback), - dialog); + _("Replicate"), cpopup_do_replicate_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), cpopup_replicate_cancel_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); @@ -5223,11 +5199,6 @@ cpopup_replicate_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_replicate_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -5370,16 +5341,6 @@ cpopup_replicate_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_replicate_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_replicate_cancel_callback (widget, data); - - return TRUE; -} - /*****/ static void @@ -5420,8 +5381,6 @@ cpopup_blend_opacity (GtkWidget *widget, /***** Main blend function *****/ -/*****/ - static void cpopup_blend_endpoints (double r0, double g0, double b0, double a0, double r1, double g1, double b1, double a1, @@ -5469,645 +5428,671 @@ cpopup_blend_endpoints (double r0, double g0, double b0, double a0, /***** Gradient functions *****/ -/*****/ - static gradient_t * -grad_new_gradient(void) +grad_new_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = g_malloc(sizeof(gradient_t)); + grad = g_new (gradient_t, 1); - grad->name = NULL; - grad->segments = NULL; - grad->last_visited = NULL; - grad->dirty = 0; - grad->filename = NULL; - grad->pixmap = NULL; + grad->name = NULL; + grad->segments = NULL; + grad->last_visited = NULL; + grad->dirty = 0; + grad->filename = NULL; + grad->pixmap = NULL; - return grad; -} /* grad_new_gradient */ - - -/*****/ - -static void -grad_free_gradient(gradient_t *grad) -{ - g_assert(grad != NULL); - - if (grad->name) - g_free(grad->name); - - if (grad->segments) - seg_free_segments(grad->segments); - - if (grad->filename) - g_free(grad->filename); - - g_free(grad); -} /* grad_free_gradient */ - - -/*****/ - -static void -grad_save_all(int need_free) -{ - GSList *node; - gradient_t *grad; - - node = gradients_list; - - while (node) { - grad = node->data; - - /* If gradient has dirty flag set, save it */ - - if (grad->dirty) - grad_save_gradient(grad, grad->filename); - - if(need_free) - grad_free_gradient(grad); - - node = g_slist_next(node); - } /* while */ + return grad; } /*****/ static void -grad_free_gradients(void) +grad_free_gradient (gradient_t *grad) { - grad_save_all(1); + g_assert (grad != NULL); + + if (grad->name) + g_free (grad->name); + + if (grad->segments) + seg_free_segments (grad->segments); + + if (grad->filename) + g_free (grad->filename); + + g_free (grad); +} + +/*****/ + +static void +grad_save_all (int need_free) +{ + GSList *node; + gradient_t *grad; + + node = gradients_list; + + while (node) + { + grad = node->data; + + /* If gradient has dirty flag set, save it */ + if (grad->dirty) + grad_save_gradient (grad, grad->filename); + + if (need_free) + grad_free_gradient (grad); + + node = g_slist_next (node); + } +} + +/*****/ + +static void +grad_free_gradients (void) +{ + grad_save_all (1); - g_slist_free(gradients_list); - - num_gradients = 0; - gradients_list = NULL; - curr_gradient = NULL; -} /* grad_free_gradients */ + g_slist_free (gradients_list); + num_gradients = 0; + gradients_list = NULL; + curr_gradient = NULL; +} /*****/ static void -grad_load_gradient(char *filename) +grad_load_gradient (char *filename) { - FILE *file; - gradient_t *grad; - grad_segment_t *seg, *prev; - int num_segments; - int i; - int type, color; - char line[1024]; + FILE *file; + gradient_t *grad; + grad_segment_t *seg, *prev; + int num_segments; + int i; + int type, color; + char line[1024]; - g_assert(filename != NULL); + g_assert (filename != NULL); - file = fopen(filename, "rb"); - if (!file) - return; + file = fopen (filename, "rb"); + if (!file) + return; - fgets(line, 1024, file); - if (strcmp(line, "GIMP Gradient\n") != 0) - return; + fgets (line, 1024, file); + if (strcmp (line, "GIMP Gradient\n") != 0) + return; - grad = grad_new_gradient(); + grad = grad_new_gradient (); - grad->filename = g_strdup(filename); - grad->name = g_strdup(g_basename(filename)); + grad->filename = g_strdup (filename); + grad->name = g_strdup (g_basename (filename)); - fgets(line, 1024, file); - num_segments = atoi(line); + fgets (line, 1024, file); + num_segments = atoi (line); - if (num_segments < 1) { - g_message (_("grad_load_gradient(): invalid number of segments in \"%s\""), filename); - g_free(grad); - return; - } /* if */ + if (num_segments < 1) + { + g_message (_("grad_load_gradient(): " + "invalid number of segments in \"%s\""), filename); + g_free (grad); + return; + } - prev = NULL; + prev = NULL; - for (i = 0; i < num_segments; i++) { - seg = seg_new_segment(); - seg->prev = prev; + for (i = 0; i < num_segments; i++) + { + seg = seg_new_segment (); + seg->prev = prev; - if (prev) - prev->next = seg; - else - grad->segments = seg; + if (prev) + prev->next = seg; + else + grad->segments = seg; - fgets(line, 1024, file); + fgets (line, 1024, file); - if (sscanf(line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", - &(seg->left), &(seg->middle), &(seg->right), - &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), - &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), - &type, &color) != 13) { - g_message (_("grad_load_gradient(): badly formatted " - "gradient segment %d in \"%s\" --- bad things may " - "happen soon"), i, filename); - } else { - seg->type = (grad_type_t) type; - seg->color = (grad_color_t) color; - } /* else */ + if (sscanf (line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", + &(seg->left), &(seg->middle), &(seg->right), + &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), + &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), + &type, &color) != 13) + { + g_message (_("grad_load_gradient(): badly formatted " + "gradient segment %d in \"%s\" --- bad things may " + "happen soon"), i, filename); + } + else + { + seg->type = (grad_type_t) type; + seg->color = (grad_color_t) color; + } - prev = seg; - } /* for */ + prev = seg; + } - fclose(file); + fclose (file); - grad_insert_in_gradients_list(grad); - - /* Check if this gradient is the default one */ - - if (strcmp(default_gradient, grad->name) == 0) - grad_default_gradient = grad; -} /* grad_load_gradient */ + grad_insert_in_gradients_list (grad); + /* Check if this gradient is the default one */ + if (strcmp (default_gradient, grad->name) == 0) + grad_default_gradient = grad; +} /*****/ static void -grad_save_gradient(gradient_t *grad, char *filename) +grad_save_gradient (gradient_t *grad, + char *filename) { - FILE *file; - int num_segments; - grad_segment_t *seg; + FILE *file; + int num_segments; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert (grad != NULL); - if (!filename) { - g_message (_("grad_save_gradient(): can not save gradient with NULL filename")); - return; - } /* if */ + if (!filename) + { + g_message (_("grad_save_gradient(): " + "can not save gradient with NULL filename")); + return; + } - file = fopen(filename, "wb"); - if (!file) { - g_message (_("grad_save_gradient(): can't open \"%s\""), filename); - return; - } /* if */ + file = fopen (filename, "wb"); + if (!file) + { + g_message (_("grad_save_gradient(): can't open \"%s\""), filename); + return; + } - /* File format is: - * - * GIMP Gradient - * number_of_segments - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * ... - */ + /* File format is: + * + * GIMP Gradient + * number_of_segments + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * ... + */ - fprintf(file, "GIMP Gradient\n"); + fprintf (file, "GIMP Gradient\n"); - /* Count number of segments */ + /* Count number of segments */ + num_segments = 0; + seg = grad->segments; - num_segments = 0; - seg = grad->segments; + while (seg) + { + num_segments++; + seg = seg->next; + } - while (seg) { - num_segments++; - seg = seg->next; - } /* while */ + /* Write rest of file */ + fprintf (file, "%d\n", num_segments); - /* Write rest of file */ + for (seg = grad->segments; seg; seg = seg->next) + fprintf (file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, (int) seg->color); - fprintf(file, "%d\n", num_segments); - - for (seg = grad->segments; seg; seg = seg->next) - fprintf(file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, (int) seg->color); - - fclose(file); - - grad->dirty = 0; -} /* grad_save_gradient */ + fclose(file); + grad->dirty = 0; +} /*****/ static gradient_t * -grad_create_default_gradient(void) +grad_create_default_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = grad_new_gradient(); - grad->segments = seg_new_segment(); - - return grad; -} /* grad_create_default_gradient */ + grad = grad_new_gradient(); + grad->segments = seg_new_segment (); + return grad; +} /*****/ static int -grad_insert_in_gradients_list(gradient_t *grad) +grad_insert_in_gradients_list (gradient_t *grad) { - GSList *tmp; - gradient_t *g; - int n; + GSList *tmp; + gradient_t *g; + int n; - /* We insert gradients in alphabetical order. Find the index - * of the gradient after which we will insert the current one. - */ + /* We insert gradients in alphabetical order. Find the index + * of the gradient after which we will insert the current one. + */ - n = 0; - tmp = gradients_list; + n = 0; + tmp = gradients_list; - while (tmp) { - g = tmp->data; + while (tmp) + { + g = tmp->data; - if (strcmp(grad->name, g->name) <= 0) - break; /* We found the one we want */ + if (strcmp (grad->name, g->name) <= 0) + break; /* We found the one we want */ - n++; - tmp = g_slist_next(tmp); - } /* while */ + n++; + tmp = g_slist_next (tmp); + } - num_gradients++; - gradients_list = g_slist_insert(gradients_list, grad, n); - - return n; -} /* grad_insert_in_gradients_list */ + num_gradients++; + gradients_list = g_slist_insert (gradients_list, grad, n); + return n; +} /*****/ static void -grad_dump_gradient(gradient_t *grad, FILE *file) +grad_dump_gradient (gradient_t *grad, + FILE *file) { - grad_segment_t *seg; + grad_segment_t *seg; - fprintf(file, "Name: \"%s\"\n", grad->name); - fprintf(file, "Dirty: %d\n", grad->dirty); - fprintf(file, "Filename: \"%s\"\n", grad->filename); + fprintf (file, "Name: \"%s\"\n", grad->name); + fprintf (file, "Dirty: %d\n", grad->dirty); + fprintf (file, "Filename: \"%s\"\n", grad->filename); - seg = grad->segments; + seg = grad->segments; - while (seg) { - fprintf(file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", - (seg == grad->last_visited) ? '>' : ' ', - seg, - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, - (int) seg->color, - seg->prev, seg->next); - - seg = seg->next; - } /* while */ -} /* grad_dump_gradient */ + while (seg) + { + fprintf (file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", + (seg == grad->last_visited) ? '>' : ' ', + seg, + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, + (int) seg->color, + seg->prev, seg->next); + seg = seg->next; + } +} /***** Segment functions *****/ -/*****/ - static grad_segment_t * -seg_new_segment(void) +seg_new_segment (void) { - grad_segment_t *seg; + grad_segment_t *seg; - seg = g_malloc(sizeof(grad_segment_t)); + seg = g_new (grad_segment_t, 1); - seg->left = 0.0; - seg->middle = 0.5; - seg->right = 1.0; + seg->left = 0.0; + seg->middle = 0.5; + seg->right = 1.0; - seg->r0 = seg->g0 = seg->b0 = 0.0; - seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; + seg->r0 = seg->g0 = seg->b0 = 0.0; + seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; - seg->type = GRAD_LINEAR; - seg->color = GRAD_RGB; + seg->type = GRAD_LINEAR; + seg->color = GRAD_RGB; - seg->prev = seg->next = NULL; - - return seg; -} /* seg_new_segment */ + seg->prev = seg->next = NULL; + return seg; +} /*****/ static void -seg_free_segment(grad_segment_t *seg) +seg_free_segment (grad_segment_t *seg) { - g_assert(seg != NULL); - - g_free(seg); -} /* seg_free_segment */ + g_assert (seg != NULL); + g_free (seg); +} /*****/ static void -seg_free_segments(grad_segment_t *seg) +seg_free_segments (grad_segment_t *seg) { - grad_segment_t *tmp; + grad_segment_t *tmp; - g_assert(seg != NULL); - - while (seg) { - tmp = seg->next; - seg_free_segment(seg); - seg = tmp; - } /* while */ -} /* seg_free_segments */ + g_assert (seg != NULL); + while (seg) + { + tmp = seg->next; + seg_free_segment(seg); + seg = tmp; + } +} /*****/ static grad_segment_t * -seg_get_segment_at(gradient_t *grad, double pos) +seg_get_segment_at (gradient_t *grad, + double pos) { - grad_segment_t *seg; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert(grad != NULL); - pos = BOUNDS(pos, 0.0, 1.0); /* to handle FP imprecision at the edges of the gradient */ + /* handle FP imprecision at the edges of the gradient */ + pos = BOUNDS (pos, 0.0, 1.0); - if (grad->last_visited) - seg = grad->last_visited; - else - seg = grad->segments; + if (grad->last_visited) + seg = grad->last_visited; + else + seg = grad->segments; - while (seg) - if (pos >= seg->left) { - if (pos <= seg->right) { - grad->last_visited = seg; /* for speed */ - return seg; - } else - seg = seg->next; - } else - seg = seg->prev; + while (seg) + { + if (pos >= seg->left) + { + if (pos <= seg->right) + { + grad->last_visited = seg; /* for speed */ + return seg; + } + else + { + seg = seg->next; + } + } + else + { + seg = seg->prev; + } + } - /* Oops: we should have found a segment, but we didn't */ - - grad_dump_gradient(curr_gradient, stderr); - gimp_fatal_error (_("seg_get_segment_at(): No matching segment for position %0.15f"), pos); - return NULL; /* To shut up -Wall */ -} /* seg_get_segment_at */ + /* Oops: we should have found a segment, but we didn't */ + grad_dump_gradient (curr_gradient, stderr); + gimp_fatal_error (_("seg_get_segment_at(): " + "No matching segment for position %0.15f"), pos); + return NULL; /* To shut up -Wall */ +} /*****/ static grad_segment_t * -seg_get_last_segment(grad_segment_t *seg) +seg_get_last_segment (grad_segment_t *seg) { - if (!seg) - return NULL; + if (!seg) + return NULL; - while (seg->next) - seg = seg->next; - - return seg; -} /* seg_get_last_segment */ + while (seg->next) + seg = seg->next; + return seg; +} /*****/ static void -seg_get_closest_handle(gradient_t *grad, double pos, - grad_segment_t **seg, control_drag_mode_t *handle) +seg_get_closest_handle (gradient_t *grad, + double pos, + grad_segment_t **seg, + control_drag_mode_t *handle) { - double l_delta, m_delta, r_delta; + double l_delta, m_delta, r_delta; - *seg = seg_get_segment_at(grad, pos); + *seg = seg_get_segment_at (grad, pos); - m_delta = fabs(pos - (*seg)->middle); + m_delta = fabs (pos - (*seg)->middle); - if (pos < (*seg)->middle) { - l_delta = fabs(pos - (*seg)->left); + if (pos < (*seg)->middle) + { + l_delta = fabs (pos - (*seg)->left); - if (l_delta < m_delta) - *handle = GRAD_DRAG_LEFT; - else - *handle = GRAD_DRAG_MIDDLE; - } else { - r_delta = fabs(pos - (*seg)->right); - - if (m_delta < r_delta) - *handle = GRAD_DRAG_MIDDLE; - else { - *seg = (*seg)->next; - *handle = GRAD_DRAG_LEFT; - } /* else */ - } /* else */ -} /* seg_get_closest_handle */ + if (l_delta < m_delta) + *handle = GRAD_DRAG_LEFT; + else + *handle = GRAD_DRAG_MIDDLE; + } + else + { + r_delta = fabs (pos - (*seg)->right); + if (m_delta < r_delta) + { + *handle = GRAD_DRAG_MIDDLE; + } + else + { + *seg = (*seg)->next; + *handle = GRAD_DRAG_LEFT; + } + } +} /***** Calculation functions *****/ -/*****/ - static double -calc_linear_factor(double middle, double pos) +calc_linear_factor (double middle, + double pos) { - if (pos <= middle) { - if (middle < EPSILON) - return 0.0; - else - return 0.5 * pos / middle; - } else { - pos -= middle; - middle = 1.0 - middle; - - if (middle < EPSILON) - return 1.0; - else - return 0.5 + 0.5 * pos / middle; - } /* else */ -} /* calc_linear_factor */ + if (pos <= middle) + { + if (middle < EPSILON) + return 0.0; + else + return 0.5 * pos / middle; + } + else + { + pos -= middle; + middle = 1.0 - middle; + if (middle < EPSILON) + return 1.0; + else + return 0.5 + 0.5 * pos / middle; + } +} /*****/ static double -calc_curved_factor(double middle, double pos) +calc_curved_factor (double middle, + double pos) { - if (middle < EPSILON) - middle = EPSILON; - - return pow(pos, log(0.5) / log(middle)); -} /* calc_curved_factor */ + if (middle < EPSILON) + middle = EPSILON; + return pow(pos, log (0.5) / log (middle)); +} /*****/ static double -calc_sine_factor(double middle, double pos) +calc_sine_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return (sin((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; -} /* calc_sine_factor */ + pos = calc_linear_factor (middle, pos); + return (sin ((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; +} /*****/ static double -calc_sphere_increasing_factor(double middle, double pos) +calc_sphere_increasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos) - 1.0; - - return sqrt(1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ -} /* calc_sphere_increasing_factor */ + pos = calc_linear_factor (middle, pos) - 1.0; + return sqrt (1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ +} /*****/ static double -calc_sphere_decreasing_factor(double middle, double pos) +calc_sphere_decreasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ -} /* calc_sphere_decreasing_factor */ + pos = calc_linear_factor (middle, pos); + return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ +} /*****/ static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, + double *g, + double *b) { - double red, green, blue; - double h, s, v; - double min, max; - double delta; + double red, green, blue; + double h, s, v; + double min, max; + double delta; - red = *r; - green = *g; - blue = *b; + red = *r; + green = *g; + blue = *b; - h = 0.0; /* Shut up -Wall */ + h = 0.0; /* Shut up -Wall */ - if (red > green) { - if (red > blue) - max = red; - else - max = blue; + if (red > green) + { + if (red > blue) + max = red; + else + max = blue; - if (green < blue) - min = green; - else - min = blue; - } else { - if (green > blue) - max = green; - else - max = blue; + if (green < blue) + min = green; + else + min = blue; + } + else + { + if (green > blue) + max = green; + else + max = blue; - if (red < blue) - min = red; - else - min = blue; - } /* else */ + if (red < blue) + min = red; + else + min = blue; + } - v = max; + v = max; - if (max != 0.0) - s = (max - min) / max; - else - s = 0.0; + if (max != 0.0) + s = (max - min) / max; + else + s = 0.0; - if (s == 0.0) - h = 0.0; - else { - delta = max - min; + if (s == 0.0) + { + h = 0.0; + } + else + { + delta = max - min; - if (red == max) - h = (green - blue) / delta; - else if (green == max) - h = 2 + (blue - red) / delta; - else if (blue == max) - h = 4 + (red - green) / delta; + if (red == max) + h = (green - blue) / delta; + else if (green == max) + h = 2 + (blue - red) / delta; + else if (blue == max) + h = 4 + (red - green) / delta; - h /= 6.0; + h /= 6.0; - if (h < 0.0) - h += 1.0; - else if (h > 1.0) - h -= 1.0; - } /* else */ - - *r = h; - *g = s; - *b = v; -} /* calc_rgb_to_hsv */ + if (h < 0.0) + h += 1.0; + else if (h > 1.0) + h -= 1.0; + } + *r = h; + *g = s; + *b = v; +} /*****/ static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, + double *s, + double *v) { - double hue, saturation, value; - double f, p, q, t; + double hue, saturation, value; + double f, p, q, t; - if (*s == 0.0) { - *h = *v; - *s = *v; - *v = *v; /* heh */ - } else { - hue = *h * 6.0; - saturation = *s; - value = *v; + if (*s == 0.0) + { + *h = *v; + *s = *v; + *v = *v; /* heh */ + } + else + { + hue = *h * 6.0; + saturation = *s; + value = *v; - if (hue == 6.0) - hue = 0.0; + if (hue == 6.0) + hue = 0.0; - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); + f = hue - (int) hue; + p = value * (1.0 - saturation); + q = value * (1.0 - saturation * f); + t = value * (1.0 - saturation * (1.0 - f)); - switch ((int) hue) { - case 0: - *h = value; - *s = t; - *v = p; - break; + switch ((int) hue) + { + case 0: + *h = value; + *s = t; + *v = p; + break; - case 1: - *h = q; - *s = value; - *v = p; - break; + case 1: + *h = q; + *s = value; + *v = p; + break; - case 2: - *h = p; - *s = value; - *v = t; - break; + case 2: + *h = p; + *s = value; + *v = t; + break; - case 3: - *h = p; - *s = q; - *v = value; - break; + case 3: + *h = p; + *s = q; + *v = value; + break; - case 4: - *h = t; - *s = p; - *v = value; - break; - - case 5: - *h = value; - *s = p; - *v = q; - break; - } /* switch */ - } /* else */ -} /* calc_hsv_to_rgb */ + case 4: + *h = t; + *s = p; + *v = value; + break; + case 5: + *h = value; + *s = p; + *v = q; + break; + } + } +} /***** Files and paths functions *****/ -/*****/ - static gchar * build_user_filename (gchar *name, gchar *path_str) diff --git a/app/gui/gradient-select.c b/app/gui/gradient-select.c index d54d8e091b..75591d0a96 100644 --- a/app/gui/gradient-select.c +++ b/app/gui/gradient-select.c @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /* This is the popup for the gradient selection stuff.. * idea is a cut down version of the gradient selection widget * just a clist on which each gradient can be selected. @@ -28,7 +27,6 @@ * setting the slection all need to be done as well. */ - /* Main structure for the dialog. There can be multiple of these * so every thing has to go into the strcuture and we have to have a list * the structures so we can find which one we are taking about. @@ -48,123 +46,125 @@ #include "colormaps.h" #include "cursorutil.h" #include "datafiles.h" +#include "dialog_handler.h" #include "errors.h" #include "general.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient.h" #include "gradient_header.h" #include "indicator_area.h" #include "interface.h" #include "palette.h" #include "session.h" -#include "actionarea.h" -#include "dialog_handler.h" #include "libgimp/gimpintl.h" GSList *grad_active_dialogs = NULL; /* List of active dialogs */ GradSelectP gradient_select_dialog = NULL; /* The main selection dialog */ -static void grad_select_close_callback (GtkWidget *, gpointer); +static void grad_select_close_callback (GtkWidget *, gpointer); static void grad_select_edit_callback (GtkWidget *, gpointer); -static void grad_change_callbacks(GradSelectP gsp, gint closing); -extern void import_palette_grad_update(gradient_t *); /* ALT Hmm... */ - - -static ActionAreaItem action_items[2] = -{ - { N_("Edit"), grad_select_edit_callback, NULL, NULL }, - { N_("Close"), grad_select_close_callback, NULL, NULL } -}; +static void grad_change_callbacks (GradSelectP gsp, gint closing); +extern void import_palette_grad_update (gradient_t *); /* ALT Hmm... */ void -grad_free_gradient_editor(void) +grad_free_gradient_editor (void) { if (gradient_select_dialog) - session_get_window_info (gradient_select_dialog->shell, &gradient_select_session_info); -} /* grad_free_gradient_editor */ + session_get_window_info (gradient_select_dialog->shell, + &gradient_select_session_info); +} void -grad_sel_rename_all(gint n, gradient_t *grad) +grad_sel_rename_all (gint n, + gradient_t *grad) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_set_text(GTK_CLIST(gsp->clist),n,1,grad->name); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_set_text (GTK_CLIST (gsp->clist), n, 1, grad->name); + list = g_slist_next (list); } if(gradient_select_dialog) { - gtk_clist_set_text(GTK_CLIST(gradient_select_dialog->clist),n,1,grad->name); + gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist), + n, 1, grad->name); } } void -grad_sel_new_all(gint pos, gradient_t *grad) +grad_sel_new_all (gint pos, + gradient_t *grad) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_freeze(GTK_CLIST(gsp->clist)); - ed_insert_in_gradients_listbox(gsp->gc,gsp->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gsp->clist)); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_freeze (GTK_CLIST (gsp->clist)); + ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gsp->clist)); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_freeze(GTK_CLIST(gradient_select_dialog->clist)); - ed_insert_in_gradients_listbox(gradient_select_dialog->gc,gradient_select_dialog->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gradient_select_dialog->clist)); + gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist)); + ed_insert_in_gradients_listbox (gradient_select_dialog->gc, + gradient_select_dialog->clist, + grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist)); } } void -grad_sel_copy_all(gint pos, gradient_t *grad) +grad_sel_copy_all (gint pos, + gradient_t *grad) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_freeze(GTK_CLIST(gsp->clist)); - ed_insert_in_gradients_listbox(gsp->gc,gsp->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gsp->clist)); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_freeze (GTK_CLIST (gsp->clist)); + ed_insert_in_gradients_listbox (gsp->gc, gsp->clist, grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gsp->clist)); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_freeze(GTK_CLIST(gradient_select_dialog->clist)); - ed_insert_in_gradients_listbox(gradient_select_dialog->gc,gradient_select_dialog->clist,grad, pos, 1); - gtk_clist_thaw(GTK_CLIST(gradient_select_dialog->clist)); + gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist)); + ed_insert_in_gradients_listbox (gradient_select_dialog->gc, + gradient_select_dialog->clist, + grad, pos, 1); + gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist)); } } void -grad_sel_delete_all(gint n) +grad_sel_delete_all (gint n) { GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_remove(GTK_CLIST(gsp->clist), n); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_remove (GTK_CLIST (gsp->clist), n); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_remove(GTK_CLIST(gradient_select_dialog->clist), n); + gtk_clist_remove (GTK_CLIST (gradient_select_dialog->clist), n); } } @@ -174,117 +174,119 @@ grad_sel_free_all() GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_freeze(GTK_CLIST(gsp->clist)); - gtk_clist_clear(GTK_CLIST(gsp->clist)); - gtk_clist_thaw(GTK_CLIST(gsp->clist)); - list = g_slist_next(list); + gsp = (GradSelectP) list->data; + gtk_clist_freeze (GTK_CLIST (gsp->clist)); + gtk_clist_clear (GTK_CLIST (gsp->clist)); + gtk_clist_thaw (GTK_CLIST (gsp->clist)); + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { - gtk_clist_freeze(GTK_CLIST(gradient_select_dialog->clist)); - gtk_clist_clear(GTK_CLIST(gradient_select_dialog->clist)); - gtk_clist_thaw(GTK_CLIST(gradient_select_dialog->clist)); + gtk_clist_freeze (GTK_CLIST (gradient_select_dialog->clist)); + gtk_clist_clear (GTK_CLIST (gradient_select_dialog->clist)); + gtk_clist_thaw (GTK_CLIST (gradient_select_dialog->clist)); } } void -grad_sel_refill_all() +grad_sel_refill_all () { GSList *list = grad_active_dialogs; GradSelectP gsp; int select_pos = -1; - while(list) + while (list) { - gsp = (GradSelectP)list->data; + gsp = (GradSelectP) list->data; gsp->grad = curr_gradient; - select_pos = ed_set_list_of_gradients(gsp->gc, - gsp->clist, - curr_gradient); - if(select_pos != -1) - gtk_clist_moveto(GTK_CLIST(gsp->clist),select_pos,0,0.0,0.0); - - list = g_slist_next(list); + select_pos = ed_set_list_of_gradients (gsp->gc, + gsp->clist, + curr_gradient); + if (select_pos != -1) + gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0); + + list = g_slist_next (list); } - if(gradient_select_dialog) + if (gradient_select_dialog) { gradient_select_dialog->grad = curr_gradient; - select_pos = ed_set_list_of_gradients(gradient_select_dialog->gc, - gradient_select_dialog->clist, - curr_gradient); - if(select_pos != -1) - gtk_clist_moveto(GTK_CLIST(gradient_select_dialog->clist),select_pos,0,0.0,0.0); + select_pos = ed_set_list_of_gradients (gradient_select_dialog->gc, + gradient_select_dialog->clist, + curr_gradient); + if (select_pos != -1) + gtk_clist_moveto (GTK_CLIST (gradient_select_dialog->clist), + select_pos, 0, 0.0, 0.0); } } - void -sel_update_dialogs(gint row, gradient_t *grad) +sel_update_dialogs (gint row, + gradient_t *grad) { /* Go around each updating the names and hopefully the previews */ GSList *list = grad_active_dialogs; GradSelectP gsp; - while(list) + while (list) { - gsp = (GradSelectP)list->data; - gtk_clist_set_text(GTK_CLIST(gsp->clist),row,1,grad->name); + gsp = (GradSelectP) list->data; + gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, grad->name); /* Are we updating one that is selected in a popup dialog? */ - if(grad == gsp->grad) - grad_change_callbacks(gsp, 0); - list = g_slist_next(list); + if (grad == gsp->grad) + grad_change_callbacks (gsp, 0); + list = g_slist_next (list); } - if(gradient_select_dialog) - gtk_clist_set_text(GTK_CLIST(gradient_select_dialog->clist),row,1,grad->name); + if (gradient_select_dialog) + gtk_clist_set_text (GTK_CLIST (gradient_select_dialog->clist), + row, 1, grad->name); gradient_area_update (); /* update the indicator_area */ - import_palette_grad_update(grad); + import_palette_grad_update (grad); } static void -sel_list_item_update(GtkWidget *widget, - gint row, - gint column, - GdkEventButton *event, - gpointer data) +sel_list_item_update (GtkWidget *widget, + gint row, + gint column, + GdkEventButton *event, + gpointer data) { - GradSelectP gsp = (GradSelectP)data; + GradSelectP gsp = (GradSelectP) data; - GSList* tmp = g_slist_nth(gradients_list,row); - gsp->grad = (gradient_t *)(tmp->data); + GSList* tmp = g_slist_nth (gradients_list, row); + gsp->grad = (gradient_t *) (tmp->data); /* If main one then make it the current selection */ - if(gsp == gradient_select_dialog) + if (gsp == gradient_select_dialog) { - grad_set_grad_to_name(gsp->grad->name); + grad_set_grad_to_name (gsp->grad->name); gradient_area_update (); /* update the indicator_area */ - import_palette_grad_update(gsp->grad); + import_palette_grad_update (gsp->grad); } else { - grad_change_callbacks(gsp, 0); + grad_change_callbacks (gsp, 0); } } static void -grad_select_edit_callback (GtkWidget *w, +grad_select_edit_callback (GtkWidget *widget, gpointer client_data) { GradSelectP gsp; gsp = (GradSelectP) client_data; - grad_create_gradient_editor_init(TRUE); + grad_create_gradient_editor_init (TRUE); - /* Set the current gradient in this dialog to the "real current"*/ - if(gsp && gsp->grad) - grad_set_grad_to_name(gsp->grad->name); + /* Set the current gradient in this dialog to the "real current"*/ + if (gsp && gsp->grad) + grad_set_grad_to_name (gsp->grad->name); } void @@ -292,21 +294,19 @@ grad_select_free (GradSelectP gsp) { if (gsp) { - if(gsp->callback_name) - g_free(gsp->callback_name); + if (gsp->callback_name) + g_free (gsp->callback_name); /* remove from active list */ - - grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp); + grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp); g_free (gsp); } } /* Close active dialogs that no longer have PDB registered for them */ - void -gradients_check_dialogs(void) +gradients_check_dialogs (void) { GSList *list; GradSelectP gsp; @@ -321,21 +321,21 @@ gradients_check_dialogs(void) list = list->next; name = gsp->callback_name; - prec = procedural_db_lookup(name); - - if(!prec) + prec = procedural_db_lookup (name); + + if (!prec) { - grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp); + grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp); /* Can alter grad_active_dialogs list*/ - grad_select_close_callback(NULL,gsp); + grad_select_close_callback (NULL, gsp); } } } - static void -grad_change_callbacks(GradSelectP gsp, gint closing) +grad_change_callbacks(GradSelectP gsp, + gint closing) { gchar * name; ProcRecord *prec = NULL; @@ -346,8 +346,8 @@ grad_change_callbacks(GradSelectP gsp, gint closing) /* Any procs registered to callback? */ Argument *return_vals; - - if(!gsp || !gsp->callback_name || busy != 0) + + if (!gsp || !gsp->callback_name || busy != 0) return; busy = 1; @@ -355,9 +355,9 @@ grad_change_callbacks(GradSelectP gsp, gint closing) grad = gsp->grad; /* If its still registered run it */ - prec = procedural_db_lookup(name); + prec = procedural_db_lookup (name); - if(prec && grad) + if (prec && grad) { gdouble *values, *pv; double pos, delta; @@ -366,30 +366,31 @@ grad_change_callbacks(GradSelectP gsp, gint closing) pos = 0.0; delta = 1.0 / (i - 1); - values = g_malloc(i * 4 * sizeof(gdouble)); + values = g_new (gdouble, 4 * i); pv = values; curr_gradient = grad; - while (i--) { - grad_get_color_at(pos, &r, &g, &b, &a); - - *pv++ = r; - *pv++ = g; - *pv++ = b; - *pv++ = a; - - pos += delta; - } /* while */ + while (i--) + { + grad_get_color_at (pos, &r, &g, &b, &a); + + *pv++ = r; + *pv++ = g; + *pv++ = b; + *pv++ = a; + + pos += delta; + } curr_gradient = oldgrad; - + return_vals = procedural_db_run_proc (name, &nreturn_vals, - PDB_STRING,grad->name, - PDB_INT32,gsp->sample_size*4, - PDB_FLOATARRAY,values, - PDB_INT32,closing, + PDB_STRING, grad->name, + PDB_INT32, gsp->sample_size*4, + PDB_FLOATARRAY, values, + PDB_INT32, closing, PDB_END); if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS) @@ -401,7 +402,7 @@ grad_change_callbacks(GradSelectP gsp, gint closing) } static void -grad_select_close_callback (GtkWidget *w, +grad_select_close_callback (GtkWidget *widget, gpointer client_data) { GradSelectP gsp; @@ -420,18 +421,9 @@ grad_select_close_callback (GtkWidget *w, } } -static gint -grad_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - grad_select_close_callback (w, client_data); - return TRUE; -} - GradSelectP -gsel_new_selection (gchar * title, - gchar * initial_gradient) +gsel_new_selection (gchar *title, + gchar *initial_gradient) { GradSelectP gsp; gradient_t *grad = NULL; @@ -448,23 +440,27 @@ gsel_new_selection (gchar * title, grad_create_gradient_editor_init(FALSE); } - gsp = g_malloc (sizeof (_GradSelect)); + gsp = g_new (_GradSelect, 1); gsp->callback_name = NULL; /* The shell and main vbox */ - gsp->shell = gtk_dialog_new (); + gsp->shell = gimp_dialog_new (title ? title : _("Gradient Selection"), + "gradient_selection", + gimp_standard_help_func, + "dialogs/gradient_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_window_set_wmclass (GTK_WINDOW (gsp->shell), "gradselection", "Gimp"); - gtk_window_set_policy (GTK_WINDOW (gsp->shell), FALSE, TRUE, FALSE); + _("Edit"), grad_select_edit_callback, + gsp, NULL, FALSE, FALSE, + _("Close"), grad_select_close_callback, + gsp, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (gsp->shell)->vbox), vbox, TRUE, TRUE, 0); - - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (gsp->shell), "delete_event", - GTK_SIGNAL_FUNC (grad_select_delete_callback), - gsp); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (gsp->shell)->vbox), vbox); /* clist preview of gradients */ scrolled_win = gtk_scrolled_window_new (NULL, NULL); @@ -498,23 +494,10 @@ gsel_new_selection (gchar * title, gdk_color_parse ("black", &gsp->black); gdk_color_alloc (colormap, &gsp->black); - gtk_signal_connect (GTK_OBJECT(gsp->clist), "select_row", - GTK_SIGNAL_FUNC(sel_list_item_update), + gtk_signal_connect (GTK_OBJECT (gsp->clist), "select_row", + GTK_SIGNAL_FUNC (sel_list_item_update), (gpointer) gsp); - action_items[0].user_data = gsp; - action_items[1].user_data = gsp; - build_action_area (GTK_DIALOG (gsp->shell), action_items, 2, 1); - - if(!title) - { - gtk_window_set_title (GTK_WINDOW (gsp->shell), _("Gradient Selection")); - } - else - { - gtk_window_set_title (GTK_WINDOW (gsp->shell), title); - } - if (initial_gradient && strlen (initial_gradient)) { list = gradients_list; @@ -547,31 +530,32 @@ gsel_new_selection (gchar * title, gtk_widget_show (gsp->shell); if (select_pos != -1) - gtk_clist_moveto (GTK_CLIST(gsp->clist),select_pos,0,0.0,0.0); + gtk_clist_moveto (GTK_CLIST (gsp->clist), select_pos, 0, 0.0, 0.0); return gsp; } void -grad_create_gradient_editor(void) +grad_create_gradient_editor (void) { - if(gradient_select_dialog == NULL) + if (gradient_select_dialog == NULL) { - gradient_select_dialog = gsel_new_selection(_("Gradients"),NULL); + gradient_select_dialog = gsel_new_selection (_("Gradients"), NULL); /* register this one only */ - dialog_register(gradient_select_dialog->shell); + dialog_register (gradient_select_dialog->shell); - session_set_window_geometry (gradient_select_dialog->shell, &gradient_select_session_info, TRUE); + session_set_window_geometry (gradient_select_dialog->shell, + &gradient_select_session_info, TRUE); } else { - if (!GTK_WIDGET_VISIBLE(gradient_select_dialog->shell)) + if (!GTK_WIDGET_VISIBLE (gradient_select_dialog->shell)) { - gtk_widget_show(gradient_select_dialog->shell); + gtk_widget_show (gradient_select_dialog->shell); } else - gdk_window_raise(gradient_select_dialog->shell->window); + gdk_window_raise (gradient_select_dialog->shell->window); return; } } diff --git a/app/gui/help-commands.c b/app/gui/help-commands.c index 344fd7017d..9dc31ff075 100644 --- a/app/gui/help-commands.c +++ b/app/gui/help-commands.c @@ -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) diff --git a/app/gui/help-commands.h b/app/gui/help-commands.h index aba3d13a1e..7dbf589d23 100644 --- a/app/gui/help-commands.h +++ b/app/gui/help-commands.h @@ -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__ */ diff --git a/app/gui/info-dialog.c b/app/gui/info-dialog.c index 6528ffb06f..63f7870bae 100644 --- a/app/gui/info-dialog.c +++ b/app/gui/info-dialog.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -143,8 +142,10 @@ info_dialog_delete_callback (GtkWidget *widget, } static InfoDialog * -info_dialog_new_extended (gchar *title, - gboolean in_notebook) +info_dialog_new_extended (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gboolean in_notebook) { InfoDialog *idialog; GtkWidget *shell; @@ -171,7 +172,7 @@ info_dialog_new_extended (gchar *title, info_table = gtk_table_new (2, 0, FALSE); - if( in_notebook) + if (in_notebook) { info_notebook = gtk_notebook_new (); gtk_notebook_append_page (GTK_NOTEBOOK (info_notebook), @@ -196,21 +197,28 @@ info_dialog_new_extended (gchar *title, gtk_widget_show (idialog->info_table); gtk_widget_show (idialog->vbox); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (idialog->shell, help_func, help_data); + return idialog; } /* public functions */ InfoDialog * -info_dialog_notebook_new (gchar *title) +info_dialog_notebook_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data) { - return info_dialog_new_extended (title, TRUE); + return info_dialog_new_extended (title, help_func, help_data, TRUE); } InfoDialog * -info_dialog_new (gchar *title) +info_dialog_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data) { - return info_dialog_new_extended (title, FALSE); + return info_dialog_new_extended (title, help_func, help_data, FALSE); } void @@ -236,7 +244,6 @@ info_dialog_free (InfoDialog *idialog) g_free (idialog); } - void info_dialog_popup (InfoDialog *idialog) { diff --git a/app/gui/info-dialog.h b/app/gui/info-dialog.h index 8bd9e24136..afe8027d24 100644 --- a/app/gui/info-dialog.h +++ b/app/gui/info-dialog.h @@ -18,7 +18,9 @@ #ifndef __INFO_DIALOG_H__ #define __INFO_DIALOG_H__ -#include "gtk/gtk.h" +#include + +#include "gimphelp.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpunit.h" @@ -61,8 +63,12 @@ struct _InfoDialog /* Info Dialog functions */ -InfoDialog *info_dialog_new (gchar *title); -InfoDialog *info_dialog_notebook_new (gchar *title); +InfoDialog *info_dialog_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data); +InfoDialog *info_dialog_notebook_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data); void info_dialog_free (InfoDialog *idialog); void info_dialog_popup (InfoDialog *idialog); diff --git a/app/gui/info-window.c b/app/gui/info-window.c index d3c894fdb6..46ab01d1ca 100644 --- a/app/gui/info-window.c +++ b/app/gui/info-window.c @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -283,10 +283,12 @@ info_window_create (void *gdisp_ptr) /* create the info dialog */ title_buf = g_strdup_printf (_("%s: Window Info"), title); - info_win = info_dialog_notebook_new (title_buf); + info_win = info_dialog_notebook_new (title_buf, + gimp_standard_help_func, + "dialogs/info_window.html"); g_free (title_buf); - iwd = (InfoWinData *) g_malloc (sizeof (InfoWinData)); + iwd = g_new (InfoWinData, 1); info_win->user_data = iwd; iwd->dimensions_str[0] = '\0'; iwd->resolution_str[0] = '\0'; diff --git a/app/gui/input-dialog.c b/app/gui/input-dialog.c index 9faa2b0ea4..4ca834935d 100644 --- a/app/gui/input-dialog.c +++ b/app/gui/input-dialog.c @@ -15,19 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "config.h" #include #include #include "appenv.h" -#include "actionarea.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "devices.h" #include "interface.h" #include "gimprc.h" +#include "gimpui.h" #include "palette.h" #include "session.h" #include "tools.h" @@ -63,7 +62,7 @@ struct _DeviceInfo { GimpBrushP brush; GPatternP pattern; ToolType tool; - unsigned char foreground[3]; + guchar foreground[3]; }; typedef struct _DeviceInfoDialog DeviceInfoDialog; @@ -115,13 +114,6 @@ static void device_status_drop_pattern (GtkWidget *, /* Global data */ int current_device = GDK_CORE_POINTER; -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Save"), (ActionCallback)devices_write_rc, NULL, NULL }, - { N_("Close"), devices_close_callback, NULL, NULL } -}; - /* dnd stuff */ static GtkTargetEntry color_area_target_table[] = { @@ -151,17 +143,17 @@ create_input_dialog (void) if (!inputd) { - inputd = gtk_input_dialog_new(); + inputd = gtk_input_dialog_new (); /* register this one only */ - dialog_register(inputd); + dialog_register (inputd); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area), FALSE); - hbbox = gtk_hbutton_box_new(); - gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbbox), 4); + hbbox = gtk_hbutton_box_new (); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox); GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button, @@ -170,46 +162,52 @@ create_input_dialog (void) GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button, GTK_CAN_DEFAULT); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, - FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, + FALSE, FALSE, 0); gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button); gtk_widget_show(hbbox); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button), + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button), "clicked", - GTK_SIGNAL_FUNC(devices_write_rc), NULL); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), + GTK_SIGNAL_FUNC (devices_write_rc), NULL); + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button), "clicked", - GTK_SIGNAL_FUNC(devices_close_callback), inputd); + GTK_SIGNAL_FUNC (devices_close_callback), inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "destroy", - (GtkSignalFunc)input_dialog_destroy_callback, + gtk_signal_connect (GTK_OBJECT (inputd), "destroy", + (GtkSignalFunc) input_dialog_destroy_callback, &inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "enable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); - gtk_signal_connect (GTK_OBJECT(inputd), "disable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "enable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "disable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (inputd, + gimp_standard_help_func, + "dialogs/input_devices_dialog.html"); + gtk_widget_show (inputd); } else { - if (!GTK_WIDGET_MAPPED(inputd)) - gtk_widget_show(inputd); + if (!GTK_WIDGET_MAPPED (inputd)) + gtk_widget_show (inputd); else - gdk_window_raise(inputd->window); + gdk_window_raise (inputd->window); } } void -input_dialog_able_callback (GtkWidget *w, - guint32 deviceid, +input_dialog_able_callback (GtkWidget *widget, + guint32 deviceid, gpointer data) { device_status_update (deviceid); } static void -input_dialog_destroy_callback (GtkWidget *w, +input_dialog_destroy_callback (GtkWidget *widget, gpointer call_data) { *((GtkWidget **)call_data) = NULL; @@ -223,7 +221,7 @@ devices_init (void) /* Create device info structures for present devices */ tmp_list = gdk_input_list_devices (); - + while (tmp_list) { GdkDeviceInfo *gdk_info = (GdkDeviceInfo *)tmp_list->data; @@ -528,7 +526,7 @@ devices_save_current_info (void) device_info->is_init = TRUE; device_info->device = current_device; device_info->brush = get_active_brush (); - device_info->pattern = get_active_pattern(); + device_info->pattern = get_active_pattern (); if (active_tool) device_info->tool = active_tool->type; else @@ -539,7 +537,7 @@ devices_save_current_info (void) } static void -devices_write_rc_device (DeviceInfo *device_info, +devices_write_rc_device (DeviceInfo *device_info, FILE *fp) { GdkDeviceInfo *gdk_info; @@ -552,7 +550,7 @@ devices_write_rc_device (DeviceInfo *device_info, { /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ - tmp_list = gdk_input_list_devices(); + tmp_list = gdk_input_list_devices (); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; @@ -566,7 +564,7 @@ devices_write_rc_device (DeviceInfo *device_info, } } - fprintf(fp, "(device \"%s\"",device_info->name); + fprintf (fp, "(device \"%s\"",device_info->name); switch (gdk_info ? gdk_info->mode : device_info->mode) { @@ -581,9 +579,10 @@ devices_write_rc_device (DeviceInfo *device_info, break; } - fprintf(fp, "\n (mode %s)",mode); + fprintf (fp, "\n (mode %s)", mode); - fprintf(fp, "\n (axes %d",gdk_info ? gdk_info->num_axes : device_info->num_axes); + fprintf (fp, "\n (axes %d", + gdk_info ? gdk_info->num_axes : device_info->num_axes); for (i=0; i<(gdk_info ? gdk_info->num_axes : device_info->num_axes); i++) { @@ -615,19 +614,20 @@ devices_write_rc_device (DeviceInfo *device_info, break; #endif /* GTK_HAVE_SIX_VALUATORS */ } - fprintf(fp, " %s",axis_type); + fprintf (fp, " %s",axis_type); } - fprintf(fp,")"); + fprintf (fp,")"); - fprintf(fp, "\n (keys %d", gdk_info ? gdk_info->num_keys : device_info->num_keys); + fprintf (fp, "\n (keys %d", + gdk_info ? gdk_info->num_keys : device_info->num_keys); - for (i=0; i<(gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) + for (i=0; i < (gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) { GdkModifierType modifiers = gdk_info ? gdk_info->keys[i].modifiers : device_info->keys[i].modifiers; guint keyval = gdk_info ? gdk_info->keys[i].keyval : device_info->keys[i].keyval; - + if (keyval) { /* FIXME: integrate this back with menus_install_accelerator */ @@ -650,22 +650,22 @@ devices_write_rc_device (DeviceInfo *device_info, else fprintf (fp, " \"\""); } - fprintf(fp,")"); + fprintf (fp,")"); if (device_info->is_init) { if (device_info->brush) - fprintf(fp, "\n (brush \"%s\")",device_info->brush->name); + fprintf (fp, "\n (brush \"%s\")",device_info->brush->name); if (device_info->pattern) - fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name); + fprintf (fp, "\n (pattern \"%s\")",device_info->pattern->name); /* Fixme: hard coded last tool.... see gimprc */ if (device_info->tool && device_info->tool <= LAST_TOOLBOX_TOOL) - fprintf(fp, "\n (tool \"%s\")", - tool_info[device_info->tool].tool_name); - fprintf(fp, "\n (foreground %d %d %d)", - device_info->foreground[0], - device_info->foreground[1], - device_info->foreground[2]); + fprintf (fp, "\n (tool \"%s\")", + tool_info[device_info->tool].tool_name); + fprintf (fp, "\n (foreground %d %d %d)", + device_info->foreground[0], + device_info->foreground[1], + device_info->foreground[2]); } fprintf(fp,")\n"); @@ -702,18 +702,25 @@ create_device_status (void) if (deviceD == NULL) { deviceD = g_new (DeviceInfoDialog, 1); - deviceD->shell = gtk_dialog_new (); + + deviceD->shell = + gimp_dialog_new (_("Device Status"), "device_status", + gimp_standard_help_func, + "dialogs/device_status_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, TRUE, + + _("Save"), (GtkSignalFunc) devices_write_rc, + NULL, NULL, FALSE, FALSE, + _("Close"), devices_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* register this one only */ - dialog_register(deviceD->shell); - - gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status")); - gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE); - /* don't set the dialog's size, as the number of devices may have - * changed since the last session - */ - session_set_window_geometry (deviceD->shell, - &device_status_session_info, FALSE); + dialog_register (deviceD->shell); + session_set_window_geometry (deviceD->shell, &device_status_session_info, + FALSE); deviceD->num_devices = 0; tmp_list = devices_info; @@ -723,10 +730,10 @@ create_device_status (void) deviceD->num_devices++; tmp_list = tmp_list->next; } -/* devices table */ + /* devices table */ deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE); - gtk_container_set_border_width (GTK_CONTAINER(deviceD->table), 3); - gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox), + gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox), deviceD->table); gtk_widget_realize (deviceD->table); gtk_widget_show (deviceD->table); @@ -841,9 +848,6 @@ create_device_status (void) i++; } - action_items[1].user_data = deviceD->shell; - build_action_area (GTK_DIALOG (deviceD->shell), action_items, 2, 1); - deviceD->current = 0xffffffff; /* random, but doesn't matter */ device_status_update_current (); @@ -878,7 +882,7 @@ device_status_destroy_callback (void) } static void -devices_close_callback (GtkWidget *w, +devices_close_callback (GtkWidget *widget, gpointer data) { gtk_widget_hide (GTK_WIDGET(data)); diff --git a/app/gui/layers-dialog.c b/app/gui/layers-dialog.c index 450813694e..85efe70682 100644 --- a/app/gui/layers-dialog.c +++ b/app/gui/layers-dialog.c @@ -18,7 +18,6 @@ #include #include #include "gdk/gdkkeysyms.h" -#include "actionarea.h" #include "appenv.h" #include "buildmenu.h" #include "colormaps.h" @@ -30,6 +29,7 @@ #include "gimage_mask.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "layers_dialog.h" @@ -3256,16 +3256,6 @@ new_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -new_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - new_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void new_layer_query_fill_type_callback (GtkWidget *widget, gpointer data) @@ -3293,11 +3283,6 @@ layers_dialog_new_layer_query (GimpImage* gimage) GSList *group; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), new_layer_query_ok_callback, NULL, NULL }, - { N_("Cancel"), new_layer_query_cancel_callback, NULL, NULL } - }; static gchar *button_names[] = { N_("Foreground"), @@ -3313,16 +3298,19 @@ layers_dialog_new_layer_query (GimpImage* gimage) options->gimage = gimage; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), - "new_layer_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("New Layer Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("New Layer Options"), "new_layer_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (new_layer_query_delete_callback), - options); + _("OK"), new_layer_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), new_layer_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3439,10 +3427,6 @@ layers_dialog_new_layer_query (GimpImage* gimage) gtk_widget_show (radio_box); gtk_widget_show (radio_frame); - 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 (vbox); gtk_widget_show (options->query_box); } @@ -3506,16 +3490,6 @@ edit_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -edit_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - edit_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_edit_layer_query (LayerWidget *layer_widget) { @@ -3524,29 +3498,25 @@ layers_dialog_edit_layer_query (LayerWidget *layer_widget) GtkWidget *hbox; GtkWidget *label; - static ActionAreaItem action_items[] = - { - { N_("OK"), edit_layer_query_ok_callback, NULL, NULL }, - { N_("Cancel"), edit_layer_query_cancel_callback, NULL, NULL } - }; - /* The new options structure */ options = g_new (EditLayerOptions, 1); options->layer = layer_widget->layer; options->gimage = layer_widget->gimage; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), - "edit_layer_attrributes", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), - _("Edit Layer Attributes")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Edit Layer Attributes"), "edit_layer_attributes", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (edit_layer_query_delete_callback), - options); + _("OK"), edit_layer_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), edit_layer_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3572,10 +3542,6 @@ layers_dialog_edit_layer_query (LayerWidget *layer_widget) gtk_widget_show (hbox); - 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 (vbox); gtk_widget_show (options->query_box); } @@ -3626,16 +3592,6 @@ add_mask_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -add_mask_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - add_mask_query_cancel_callback (widget, data); - - return TRUE; -} - static void add_mask_query_fill_type_callback (GtkWidget *widget, gpointer data) @@ -3659,11 +3615,6 @@ layers_dialog_add_mask_query (Layer *layer) GSList *group = NULL; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), add_mask_query_ok_callback, NULL, NULL }, - { N_("Cancel"), add_mask_query_cancel_callback, NULL, NULL } - }; static gchar *button_names[] = { N_("White (Full Opacity)"), @@ -3678,15 +3629,19 @@ layers_dialog_add_mask_query (Layer *layer) options->add_mask_type = ADD_WHITE_MASK; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), "add_mask_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("Add Mask Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Add Mask Options"), "add_mask_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (add_mask_query_delete_callback), - options); + _("OK"), add_mask_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), add_mask_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3719,10 +3674,6 @@ layers_dialog_add_mask_query (Layer *layer) gtk_widget_show (radio_box); gtk_widget_show (radio_frame); - 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 (vbox); gtk_widget_show (options->query_box); } @@ -3778,16 +3729,6 @@ apply_mask_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -apply_mask_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - apply_mask_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_apply_mask_query (Layer *layer) { @@ -3795,27 +3736,26 @@ layers_dialog_apply_mask_query (Layer *layer) GtkWidget *vbox; GtkWidget *label; - static ActionAreaItem action_items[] = - { - { N_("Apply"), apply_mask_query_apply_callback, NULL, NULL }, - { N_("Discard"), apply_mask_query_discard_callback, NULL, NULL }, - { N_("Cancel"), apply_mask_query_cancel_callback, NULL, NULL } - }; - /* The new options structure */ options = g_new (ApplyMaskOptions, 1); options->layer = layer; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), "layer_mask_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("Layer Mask Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Layer Mask Options"), "layer_mask_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (apply_mask_query_delete_callback), - options); + _("Apply"), apply_mask_query_apply_callback, + options, NULL, TRUE, FALSE, + _("Discard"), apply_mask_query_discard_callback, + options, NULL, FALSE, FALSE, + _("Cancel"), apply_mask_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3828,11 +3768,6 @@ layers_dialog_apply_mask_query (Layer *layer) gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); - action_items[0].user_data = options; - action_items[1].user_data = options; - action_items[2].user_data = options; - build_action_area (GTK_DIALOG (options->query_box), action_items, 3, 0); - gtk_widget_show (vbox); gtk_widget_show (options->query_box); } @@ -3898,16 +3833,6 @@ scale_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -scale_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - scale_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_scale_layer_query (GImage *gimage, Layer *layer) @@ -3928,7 +3853,6 @@ layers_dialog_scale_layer_query (GImage *gimage, TRUE, scale_layer_query_ok_callback, scale_layer_query_cancel_callback, - scale_layer_query_delete_callback, options); gtk_widget_show (options->resize->resize_shell); @@ -3997,16 +3921,6 @@ resize_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -resize_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - resize_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_resize_layer_query (GImage *gimage, Layer *layer) @@ -4027,7 +3941,6 @@ layers_dialog_resize_layer_query (GImage *gimage, TRUE, resize_layer_query_ok_callback, resize_layer_query_cancel_callback, - resize_layer_query_delete_callback, options); gtk_widget_show (options->resize->resize_shell); @@ -4077,16 +3990,6 @@ layer_merge_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -layer_merge_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - layer_merge_query_cancel_callback (widget, data); - - return TRUE; -} - static void layer_merge_query_type_callback (GtkWidget *widget, gpointer data) @@ -4112,11 +4015,6 @@ layers_dialog_layer_merge_query (GImage *gimage, GSList *group = NULL; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), layer_merge_query_ok_callback, NULL, NULL }, - { N_("Cancel"), layer_merge_query_cancel_callback, NULL, NULL } - }; static gchar *button_names[] = { N_("Expanded as necessary"), @@ -4132,15 +4030,19 @@ layers_dialog_layer_merge_query (GImage *gimage, options->merge_type = EXPAND_AS_NECESSARY; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), "layer_merge_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("Layer Merge Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Layer Merge Options"), "layer_merge_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (layer_merge_query_delete_callback), - options); + _("OK"), layer_merge_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), layer_merge_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -4176,10 +4078,6 @@ layers_dialog_layer_merge_query (GImage *gimage, gtk_widget_show (radio_box); gtk_widget_show (radio_frame); - 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 (vbox); gtk_widget_show (options->query_box); } diff --git a/app/gui/menus.c b/app/gui/menus.c index a49ed3c3e1..5550911d3a 100644 --- a/app/gui/menus.c +++ b/app/gui/menus.c @@ -69,6 +69,7 @@ static GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Open"), "O", file_open_cmd_callback, 0 }, { N_("/File/Acquire"), NULL, NULL, 0, "" }, { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, + { N_("/File/Help..."), NULL, gimp_help_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, diff --git a/app/gui/module-browser.c b/app/gui/module-browser.c index 3f0487d9b6..a2fb3ebda5 100644 --- a/app/gui/module-browser.c +++ b/app/gui/module-browser.c @@ -36,10 +36,10 @@ #include "gimpsignal.h" #include "gimprc.h" #include "datafiles.h" -#include "actionarea.h" #include "gimpset.h" -#include "libgimp/gimpenv.h" +#include "gimpui.h" +#include "libgimp/gimpenv.h" #include "libgimp/gimpmodule.h" #include "libgimp/gimpintl.h" @@ -258,19 +258,21 @@ module_db_browser_new (void) GtkWidget *listbox; GtkWidget *button; browser_st *st; - ActionAreaItem action_items[] = - { - { N_("OK"), browser_popdown_callback, NULL, NULL } - }; + shell = gimp_dialog_new (_("Module DB"), "module_db_dialog", + gimp_standard_help_func, + "dialogs/module_db_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (shell), "module_db_dialog", "Gimp"); - gtk_window_set_title (GTK_WINDOW (shell), _("Module DB")); + _("OK"), browser_popdown_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 5); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox); gtk_widget_show (vbox); listbox = gtk_scrolled_window_new (NULL, NULL); @@ -333,12 +335,6 @@ module_db_browser_new (void) gtk_signal_connect (GTK_OBJECT (shell), "destroy", browser_destroy_callback, st); - action_items[0].user_data = shell; - build_action_area (GTK_DIALOG (shell), - action_items, - sizeof( action_items)/sizeof( ActionAreaItem), - 0); - return shell; } diff --git a/app/gui/palette-editor.c b/app/gui/palette-editor.c index 6a4672a1bf..9e405239c6 100644 --- a/app/gui/palette-editor.c +++ b/app/gui/palette-editor.c @@ -31,7 +31,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "color_area.h" @@ -41,9 +40,9 @@ #include "errors.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient_header.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "palette_entries.h" #include "session.h" @@ -1075,11 +1074,16 @@ static void palette_new_entries_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box (_("New Palette"), - _("Enter a name for new palette"), - NULL, - NULL, NULL, - palette_add_entries_callback, data)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New Palette"), + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + _("Enter a name for new palette"), + NULL, + NULL, NULL, + palette_add_entries_callback, data); + gtk_widget_show (qbox); } static void @@ -1375,17 +1379,6 @@ palette_close_callback (GtkWidget *widget, } } -static gint -palette_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - palette_close_callback (widget, data); - - return TRUE; -} - - static void color_name_entry_changed (GtkWidget *widget, gpointer data) @@ -2015,18 +2008,6 @@ create_palette_dialog (gint vert) GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; - - static ActionAreaItem vert_action_items[] = - { - { N_("Edit"), palette_edit_palette_callback, NULL, NULL }, - { N_("Close"), palette_close_callback, NULL, NULL } - }; - static ActionAreaItem horz_action_items[] = - { - { N_("Save"), palette_save_palettes_callback, NULL, NULL }, - { N_("Refresh"), palette_refresh_callback, NULL, NULL }, - { N_("Close"), palette_close_callback, NULL, NULL } - }; palette = g_new (PaletteDialog, 1); @@ -2039,26 +2020,42 @@ create_palette_dialog (gint vert) palette->columns_valid = TRUE; palette->freeze_update = FALSE; - palette->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (palette->shell), "color_palette", "Gimp"); - if (!vert) { + palette->shell = + gimp_dialog_new (_("Color Palette Edit"), "color_palette_edit", + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Save"), palette_save_palettes_callback, + palette, NULL, FALSE, FALSE, + _("Refresh"), palette_refresh_callback, + palette, NULL, FALSE, FALSE, + _("Close"), palette_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); gtk_widget_set_usize (palette->shell, 615, 200); - gtk_window_set_title (GTK_WINDOW (palette->shell), - _("Color Palette Edit")); } else { - gtk_widget_set_usize (palette->shell, 230, 300); - gtk_window_set_title (GTK_WINDOW (palette->shell), - _("Color Palette")); - } + palette->shell = + gimp_dialog_new (_("Color Palette"), "color_palette", + gimp_standard_help_func, + "dialogs/color_palette_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (palette->shell), "delete_event", - GTK_SIGNAL_FUNC (palette_dialog_delete_callback), - palette); + _("Edit"), palette_edit_palette_callback, + palette, NULL, FALSE, FALSE, + _("Close"), palette_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); + gtk_widget_set_usize (palette->shell, 230, 300); + } /* The main container widget */ if (vert) @@ -2260,20 +2257,6 @@ create_palette_dialog (gint vert) gtk_widget_show (button); } - if (!vert) - { - horz_action_items[0].user_data = palette; - horz_action_items[1].user_data = palette; - horz_action_items[2].user_data = palette; - build_action_area (GTK_DIALOG (palette->shell), horz_action_items, 3, 2); - } - else - { - vert_action_items[0].user_data = palette; - vert_action_items[1].user_data = palette; - build_action_area (GTK_DIALOG (palette->shell), vert_action_items, 2, 1); - } - palette->gc = gdk_gc_new (palette->shell->window); palette_popup_menu (palette); @@ -2441,17 +2424,6 @@ import_dialog_import_callback (GtkWidget *widget, } } -static gint -import_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - import_dialog_close_callback (widget, data); - - return TRUE; -} - - static void palette_merge_entries_callback (GtkWidget *widget, gpointer data, @@ -2508,12 +2480,17 @@ static void palette_merge_dialog_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box (_("Merge Palette"), - _("Enter a name for merged palette"), - NULL, - NULL, NULL, - palette_merge_entries_callback, - data)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("Merge Palette"), + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + _("Enter a name for merged palette"), + NULL, + NULL, NULL, + palette_merge_entries_callback, + data); + gtk_widget_show (qbox); } static void @@ -2845,24 +2822,23 @@ palette_import_dialog (PaletteDialog *palette) GtkWidget *image; GtkWidget *hscale; - static ActionAreaItem action_items[] = - { - { N_("Import"), import_dialog_import_callback, NULL, NULL }, - { N_("Close"), import_dialog_close_callback, NULL, NULL } - }; - import_dialog = g_new (ImportDialog, 1); import_dialog->image_list = NULL; import_dialog->gimage = NULL; - import_dialog->dialog = dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "import_palette", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Import Palette")); + import_dialog->dialog = dialog = + gimp_dialog_new (_("Import Palette"), "import_palette", + gimp_standard_help_func, + "dialogs/import_palette_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (import_dialog_delete_callback), - (gpointer)palette); + _("Import"), import_dialog_import_callback, + palette, NULL, FALSE, FALSE, + _("Close"), import_dialog_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 4); @@ -2986,11 +2962,6 @@ palette_import_dialog (PaletteDialog *palette) gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); - /* The action area */ - action_items[0].user_data = palette; - action_items[1].user_data = palette; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Fill with the selected gradient */ palette_import_fill_grad_preview (image, curr_gradient); import_dialog->import_type = GRAD_IMPORT; diff --git a/app/gui/palette-select.c b/app/gui/palette-select.c index a758600dbe..07599ce323 100644 --- a/app/gui/palette-select.c +++ b/app/gui/palette-select.c @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -27,13 +26,13 @@ #include #include -#include "actionarea.h" #include "colormaps.h" #include "color_area.h" #include "color_select.h" #include "datafiles.h" #include "errors.h" #include "gimprc.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" #include "palette_entries.h" @@ -49,12 +48,6 @@ static GSList *active_dialogs = NULL; static void palette_select_close_callback (GtkWidget *, gpointer); static void palette_select_edit_callback (GtkWidget *, gpointer); -static ActionAreaItem action_items[] = -{ - { N_("Edit"), palette_select_edit_callback, NULL, NULL }, - { N_("Close"), palette_select_close_callback, NULL, NULL } -}; - void palette_select_set_text_all (PaletteEntriesP entries) { @@ -219,16 +212,6 @@ palette_select_close_callback (GtkWidget *widget, /* } */ } -static gint -palette_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - palette_select_close_callback (widget, client_data); - - return TRUE; -} - PaletteSelectP palette_new_selection (gchar *title, gchar *initial_palette) @@ -244,29 +227,33 @@ palette_new_selection (gchar *title, palette_select_palette_init (); - psp = g_malloc (sizeof (struct _PaletteSelect)); + psp = g_new (struct _PaletteSelect, 1); psp->callback_name = NULL; /* The shell and main vbox */ - psp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "paletteselection", "Gimp"); - - gtk_window_set_policy (GTK_WINDOW (psp->shell), FALSE, TRUE, FALSE); + psp->shell = gimp_dialog_new (title ? title : _("Palette Selection"), + "palette_selection", + gimp_standard_help_func, + "dialogs/palette_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Edit"), palette_select_edit_callback, + psp, NULL, TRUE, FALSE, + _("Close"), palette_select_close_callback, + psp, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (psp->shell)->vbox), vbox, TRUE, TRUE, 0); - - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (psp->shell), "delete_event", - GTK_SIGNAL_FUNC (palette_select_delete_callback), - psp); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox); /* clist preview of gradients */ scrolled_win = gtk_scrolled_window_new (NULL, NULL); psp->clist = gtk_clist_new (3); - gtk_clist_set_shadow_type (GTK_CLIST(psp->clist), GTK_SHADOW_IN); + gtk_clist_set_shadow_type (GTK_CLIST (psp->clist), GTK_SHADOW_IN); gtk_clist_set_row_height (GTK_CLIST (psp->clist), SM_PREVIEW_HEIGHT + 2); @@ -275,10 +262,9 @@ palette_new_selection (gchar *title, gtk_clist_set_column_title (GTK_CLIST (psp->clist), 1, _("Ncols")); gtk_clist_set_column_title (GTK_CLIST (psp->clist), 2, _("Name")); gtk_clist_column_titles_show (GTK_CLIST(psp->clist)); - gtk_clist_set_column_width (GTK_CLIST (psp->clist), 0, SM_PREVIEW_WIDTH+2); + gtk_clist_set_column_width (GTK_CLIST (psp->clist), 0, SM_PREVIEW_WIDTH + 2); hbox = gtk_hbox_new (FALSE, 8); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); @@ -295,19 +281,6 @@ palette_new_selection (gchar *title, /* GTK_SIGNAL_FUNC(sel_list_item_update), */ /* (gpointer) gsp); */ - action_items[0].user_data = psp; - action_items[1].user_data = psp; - build_action_area (GTK_DIALOG (psp->shell), action_items, 2, 0); - - if (!title) - { - gtk_window_set_title (GTK_WINDOW (psp->shell), _("Palette Selection")); - } - else - { - gtk_window_set_title (GTK_WINDOW (psp->shell), title); - } - select_pos = -1; if (initial_palette && strlen (initial_palette)) { diff --git a/app/gui/paths-dialog.c b/app/gui/paths-dialog.c index e519b733d8..fafffaaa49 100644 --- a/app/gui/paths-dialog.c +++ b/app/gui/paths-dialog.c @@ -27,7 +27,6 @@ #include "appenv.h" #include "draw_core.h" -#include "actionarea.h" #include "colormaps.h" #include "drawable.h" #include "errors.h" @@ -39,7 +38,7 @@ #include "gdisplay.h" #include "gimprc.h" #include "gimpset.h" -#include "general.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "lc_dialogP.h" @@ -50,7 +49,6 @@ #include "pathsP.h" #include "paths_dialog.h" #include "paths_dialogP.h" -#include "resize.h" #include "session.h" #include "undo.h" @@ -1216,6 +1214,7 @@ do_rename_paths_callback(GtkWidget *widget, gpointer call_data, gpointer client_ static void paths_dialog_edit_path_query (GtkWidget *widget) { + GtkWidget *qbox; GdkBitmap *mask; gchar *text; gint ret; @@ -1229,11 +1228,14 @@ paths_dialog_edit_path_query (GtkWidget *widget) NULL, &mask); - gtk_widget_show (query_string_box (_("Rename path"), - _("Enter a new name for the path"), - text, - NULL, NULL, - do_rename_paths_callback, widget)); + qbox = gimp_query_string_box (_("Rename path"), + gimp_standard_help_func, + "dialogs/paths_dialog.html", + _("Enter a new name for the path"), + text, + NULL, NULL, + do_rename_paths_callback, widget); + gtk_widget_show (qbox); } static gint @@ -1275,7 +1277,7 @@ paths_list_events (GtkWidget *widget, { if(this_colunm == 1) { - paths_dialog_edit_path_query(widget); + paths_dialog_edit_path_query (widget); return TRUE; } else diff --git a/app/gui/pattern-select.c b/app/gui/pattern-select.c index 22478e73bf..dc4bb3b6f5 100644 --- a/app/gui/pattern-select.c +++ b/app/gui/pattern-select.c @@ -17,11 +17,11 @@ */ #include #include "appenv.h" -#include "actionarea.h" #include "patterns.h" #include "pattern_select.h" #include "colormaps.h" #include "errors.h" +#include "gimpui.h" #include "session.h" #include "libgimp/gimpintl.h" @@ -55,7 +55,6 @@ static void preview_calc_scrollbar (PatternSelectP); static void pattern_select_show_selected (PatternSelectP, int, int); static void update_active_pattern_field (PatternSelectP); static void pattern_select_close_callback (GtkWidget *, gpointer); -static gint pattern_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void pattern_select_refresh_callback (GtkWidget *, gpointer); static gint pattern_select_events (GtkWidget *, GdkEvent *, PatternSelectP); static gint pattern_select_resize (GtkWidget *, GdkEvent *, PatternSelectP); @@ -81,12 +80,6 @@ pattern_select_new (gchar *title, GtkWidget *sbar; GtkWidget *label_box; - static ActionAreaItem action_items[2] = - { - { N_("Refresh"), pattern_select_refresh_callback, NULL, NULL }, - { N_("Close"), pattern_select_close_callback, NULL, NULL } - }; - psp = g_new (_PatternSelect, 1); psp->preview = NULL; psp->old_col = psp->old_row = 0; @@ -97,23 +90,44 @@ pattern_select_new (gchar *title, psp->NUM_PATTERN_ROWS = STD_PATTERN_COLUMNS; /* The shell and main vbox */ - psp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "patternselection", "Gimp"); + if (title) + { + psp->shell = + gimp_dialog_new (title, "pattern_selection", + gimp_standard_help_func, + "dialogs/pattern_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Close"), pattern_select_close_callback, + psp, NULL, TRUE, TRUE, + + NULL); - if(!title) - { - gtk_window_set_title (GTK_WINDOW (psp->shell), _("Pattern Selection")); - session_set_window_geometry (psp->shell, &pattern_select_session_info, - TRUE); - } - else - { - gtk_window_set_title (GTK_WINDOW (psp->shell), title); if (initial_pattern && strlen (initial_pattern)) { active = pattern_list_get_pattern (pattern_list, initial_pattern); } } + else + { + psp->shell = + gimp_dialog_new (_("Pattern Selection"), "pattern_selection", + gimp_standard_help_func, + "dialogs/pattern_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Refresh"), pattern_select_refresh_callback, + psp, NULL, FALSE, FALSE, + _("Close"), pattern_select_close_callback, + psp, NULL, TRUE, TRUE, + + NULL); + + session_set_window_geometry (psp->shell, &pattern_select_session_info, + TRUE); + } /* update the active selection */ if (!active) @@ -121,13 +135,6 @@ pattern_select_new (gchar *title, psp->pattern = active; - gtk_window_set_policy (GTK_WINDOW (psp->shell), FALSE, TRUE, FALSE); - - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (psp->shell), "delete_event", - GTK_SIGNAL_FUNC (pattern_select_delete_callback), - psp); - /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -190,14 +197,6 @@ pattern_select_new (gchar *title, gtk_widget_show (hbox); gtk_widget_show (frame); - /* The action area */ - action_items[0].user_data = psp; - action_items[1].user_data = psp; - if (title) - build_action_area (GTK_DIALOG (psp->shell), &action_items[1], 1, 0); - else - build_action_area (GTK_DIALOG (psp->shell), action_items, 2, 1); - gtk_widget_show (psp->options_box); gtk_widget_show (vbox); gtk_widget_show (psp->shell); @@ -799,18 +798,8 @@ pattern_select_events (GtkWidget *widget, return FALSE; } -static gint -pattern_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - pattern_select_close_callback (widget, client_data); - - return TRUE; -} - static void -pattern_select_close_callback (GtkWidget *w, +pattern_select_close_callback (GtkWidget *widget, gpointer client_data) { PatternSelectP psp; @@ -831,7 +820,7 @@ pattern_select_close_callback (GtkWidget *w, } static void -pattern_select_refresh_callback (GtkWidget *w, +pattern_select_refresh_callback (GtkWidget *widget, gpointer client_data) { PatternSelectP psp; @@ -892,7 +881,7 @@ pattern_select_scroll_update (GtkAdjustment *adjustment, /* Close active dialogs that no longer have PDB registered for them */ void -patterns_check_dialogs(void) +patterns_check_dialogs (void) { GSList *list; PatternSelectP psp; @@ -908,13 +897,13 @@ patterns_check_dialogs(void) name = psp->callback_name; prec = procedural_db_lookup(name); - - if(!prec) + + if (!prec) { - pattern_active_dialogs = g_slist_remove(pattern_active_dialogs,psp); + pattern_active_dialogs = g_slist_remove (pattern_active_dialogs,psp); /* Can alter pattern_active_dialogs list*/ - pattern_select_close_callback(NULL,psp); + pattern_select_close_callback (NULL, psp); } } } diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index af84450451..0a61751d03 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -23,6 +23,7 @@ #include "gdisplay_ops.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "lc_dialog.h" @@ -107,6 +108,7 @@ static int old_max_new_image_size; static int old_thumbnail_mode; static int old_show_indicators; static int old_trust_dirty_flag; +static int old_use_help; /* variables which can't be changed on the fly */ static int edit_stingy_memory_use; @@ -531,7 +533,12 @@ file_prefs_save_callback (GtkWidget *widget, update = g_list_append (update, "trust-dirty-flag"); remove = g_list_append (update, "dont-trust-dirty-flag"); } - + if (use_help != old_use_help) + { + update = g_list_append (update, "use-help"); + remove = g_list_append (remove, "dont-use-help"); + } + save_gimprc (&update, &remove); if (using_xserver_resolution) @@ -597,6 +604,7 @@ file_prefs_cancel_callback (GtkWidget *widget, thumbnail_mode = old_thumbnail_mode; show_indicators = old_show_indicators; trust_dirty_flag = old_trust_dirty_flag; + use_help = old_use_help; if (preview_size != old_preview_size) { @@ -703,6 +711,8 @@ file_prefs_toggle_callback (GtkWidget *widget, val = data; *val = (long) gtk_object_get_user_data (GTK_OBJECT (widget)); } + else if (data == &use_help) + use_help = GTK_TOGGLE_BUTTON (widget)->active; else { /* Are you a gimp-hacker who is getting this message? You @@ -972,360 +982,6 @@ file_prefs_monitor_resolution_callback (GtkWidget *widget, monitor_yres = yres; } -/* ******************************************************************** - * convenience constructors test site ;) - */ - -/* local callbacks of gimp_dialog_new () */ -static int -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; -} - -/* -#include "/home/mitschel/gimpfiles/wilber.xpm" - -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], - wilber_xpm); - - gdk_window_set_icon (widget->window, NULL, - wilber_pixmap, wilber_mask); -} -*/ - -/* this is an experimental one - * I tried to fold the entire dialog creation and the ActionArea stuff - * into one function. Might be not general enough. - */ -GtkWidget* -gimp_dialog_new (const gchar *title, - const gchar *wmclass_name, - GtkWindowPosition position, - gint allow_shrink, - gint allow_grow, - gint auto_shrink, - - /* specify action area buttons as va_list: - * gchar *label, - * GtkSignalFunc callback, - * gpointer data, - * gboolean default_action, - * gboolean connect_delete, - */ - - ...) -{ - GtkWidget *dialog; - GtkWidget *hbbox; - GtkWidget *button; - - /* action area variables */ - gchar *label; - GtkSignalFunc callback; - gpointer data; - gboolean default_action; - gboolean connect_delete; - - va_list args; - gboolean delete_connected = FALSE; - - 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_grow, allow_shrink, auto_shrink); - - /* prepare the action_area */ - gtk_container_set_border_width - (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (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 (GTK_DIALOG (dialog)->action_area), hbbox, - FALSE, FALSE, 0); - gtk_widget_show (hbbox); - - /* the action_area buttons */ - va_start (args, auto_shrink); - label = va_arg (args, gchar*); - while (label) - { - callback = va_arg (args, GtkSignalFunc); - data = 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 (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*); - } - va_end (args); - - /* catch the WM delete event if not already done */ - if (! delete_connected) - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - (GdkEventFunc) gimp_dialog_delete_callback, - NULL); - - /* the realize callback sets the WM icon */ - /* - gtk_signal_connect (GTK_OBJECT (dialog), "realize", - (GtkSignalFunc) gimp_dialog_realize_callback, - NULL); - - */ - return dialog; -} - -GtkWidget* -gimp_option_menu_new (GtkSignalFunc menu_item_callback, - gpointer initial, /* user_data */ - - /* specify menu items as va_list: - * gchar *label, - * gpointer data, - * gpointer user_data, - */ - - ...) -{ - GtkWidget *menu; - GtkWidget *menuitem; - GtkWidget *optionmenu; - - /* menu item variables */ - gchar *label; - gpointer data; - gpointer user_data; - - va_list args; - gint i; - gint initial_index; - - menu = gtk_menu_new (); - - /* create the menu items */ - initial_index = 0; - va_start (args, initial); - label = va_arg (args, gchar*); - for (i = 0; label; i++) - { - data = va_arg (args, gpointer); - user_data = va_arg (args, gpointer); - - menuitem = gtk_menu_item_new_with_label (label); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - menu_item_callback, data); - gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data); - gtk_widget_show (menuitem); - - /* remember the initial menu item */ - if (user_data == initial) - initial_index = i; - - label = va_arg (args, gchar*); - } - va_end (args); - - optionmenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); - - /* select the initial menu item */ - gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index); - - return optionmenu; -} - -GtkWidget* -gimp_radio_group_new (GtkSignalFunc radio_button_callback, - gpointer initial, /* user_data */ - - /* specify radio buttons as va_list: - * gchar *label, - * gpointer data, - * gpointer user_data, - */ - - ...) -{ - GtkWidget *vbox; - GtkWidget *button; - GSList *group; - - /* radio button variables */ - gchar *label; - gpointer data; - gpointer user_data; - - va_list args; - - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - group = NULL; - - /* create the radio buttons */ - va_start (args, initial); - label = va_arg (args, gchar*); - while (label) - { - data = va_arg (args, gpointer); - user_data = va_arg (args, gpointer); - - button = gtk_radio_button_new_with_label (group, label); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) radio_button_callback, - data); - gtk_object_set_user_data (GTK_OBJECT (button), user_data); - - /* press the initially active radio button */ - if (user_data == initial) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - - gtk_widget_show (button); - - label = va_arg (args, gchar*); - } - va_end (args); - - return vbox; -} - -/* this might be the standard gimp spinbutton */ -GtkWidget* -gimp_spin_button_new (GtkObject **adjustment, /* return value */ - gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - gfloat page_size, - gfloat climb_rate, - guint digits) -{ - GtkWidget *spinbutton; - - *adjustment = gtk_adjustment_new (value, lower, upper, - step_increment, page_increment, page_size); - - spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment), - climb_rate, digits); - gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), - GTK_SHADOW_NONE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); - gtk_widget_set_usize (spinbutton, 75, 0); - - return spinbutton; -} - -/* add aligned label & widget to a two-column table */ -void -gimp_table_attach_aligned (GtkTable *table, - gint row, - gchar *text, - gfloat xalign, - gfloat yalign, - GtkWidget *widget, - gboolean left_adjust) -{ - GtkWidget *label; - - label = gtk_label_new (text); - gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); - gtk_table_attach (table, GTK_WIDGET (label), 0, 1, row, row + 1, - GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - gtk_widget_show (label); - - if (left_adjust) - { - GtkWidget *alignment; - - alignment = gtk_alignment_new (0.0, 1.0, 0.0, 0.0); - gtk_table_attach_defaults (table, alignment, 1, 2, row, row + 1); - gtk_widget_show (alignment); - gtk_container_add (GTK_CONTAINER (alignment), widget); - } - else - { - gtk_table_attach_defaults (table, widget, 1, 2, row, row + 1); - } - - gtk_widget_show (widget); -} - - -/********************************************************************** - * preferences-specific GUI helpers - */ - /* create a new notebook page */ static GtkWidget* file_prefs_notebook_append_page (GtkNotebook *notebook, @@ -1492,6 +1148,7 @@ file_pref_cmd_callback (GtkWidget *widget, old_thumbnail_mode = thumbnail_mode; old_show_indicators = show_indicators; old_trust_dirty_flag = trust_dirty_flag; + old_use_help = use_help; file_prefs_strset (&old_temp_path, edit_temp_path); file_prefs_strset (&old_swap_path, edit_swap_path); @@ -1506,20 +1163,24 @@ file_pref_cmd_callback (GtkWidget *widget, /* Create the dialog */ prefs_dlg = gimp_dialog_new (_("Preferences"), "gimp_preferences", - GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, - _("OK"), file_prefs_ok_callback, NULL, - FALSE, FALSE, - _("Save"), file_prefs_save_callback, NULL, - FALSE, FALSE, - _("Cancel"), file_prefs_cancel_callback, NULL, - TRUE, TRUE, + gimp_standard_help_func, + "dialogs/preferences_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, + + _("OK"), file_prefs_ok_callback, + NULL, NULL, FALSE, FALSE, + _("Save"), file_prefs_save_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), file_prefs_cancel_callback, + NULL, NULL, TRUE, TRUE, + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (prefs_dlg)->vbox), - hbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (prefs_dlg)->vbox), hbox); gtk_widget_show (hbox); /* The categories tree */ @@ -1849,7 +1510,7 @@ file_pref_cmd_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); - button = gtk_check_button_new_with_label(_("Show Tool Tips")); + button = gtk_check_button_new_with_label (_("Show Tool Tips")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), show_tool_tips); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); @@ -1858,6 +1519,16 @@ file_pref_cmd_callback (GtkWidget *widget, &show_tool_tips); gtk_widget_show (button); + button = + gtk_check_button_new_with_label (_("Context Sensitive Help with \"F1\"")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + use_help); + gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "toggled", + (GtkSignalFunc) file_prefs_toggle_callback, + &use_help); + gtk_widget_show (button); + /* Interface / Image Windows */ vbox = file_prefs_notebook_append_page (GTK_NOTEBOOK (notebook), _("Image Windows Settings"), diff --git a/app/gui/preferences-dialog.h b/app/gui/preferences-dialog.h index de5b153e12..ed92c84cea 100644 --- a/app/gui/preferences-dialog.h +++ b/app/gui/preferences-dialog.h @@ -20,14 +20,5 @@ #define __PREFERENCES_DIALOG_H__ void file_pref_cmd_callback (GtkWidget *, gpointer); -GtkWidget* gimp_spin_button_new (GtkObject **, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - guint); #endif /* __PREFERENCES_DIALOG_H__ */ diff --git a/app/gui/qmask-commands.c b/app/gui/qmask-commands.c index 29c2706729..5dea7de4c1 100644 --- a/app/gui/qmask-commands.c +++ b/app/gui/qmask-commands.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/gui/resize-dialog.c b/app/gui/resize-dialog.c index 7a0ef0f835..7e2925d1db 100644 --- a/app/gui/resize-dialog.c +++ b/app/gui/resize-dialog.c @@ -19,8 +19,8 @@ #include "config.h" #include "appenv.h" #include "resize.h" -#include "actionarea.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpchainbutton.h" #include "libgimp/gimplimits.h" @@ -91,9 +91,6 @@ resize_widget_new (ResizeType type, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, - gint (*delete_cb) (GtkWidget *, - GdkEvent *, - gpointer), gpointer user_data) { Resize *resize; @@ -110,12 +107,6 @@ resize_widget_new (ResizeType type, GtkWidget *alignment; GtkObject *adjustment; - static ActionAreaItem action_items[] = - { - { N_("OK"), NULL, NULL, NULL }, - { N_("Cancel"), NULL, NULL, NULL } - }; - alignment = NULL; frame = NULL; @@ -149,52 +140,62 @@ resize_widget_new (ResizeType type, /* dialog box */ { - const char *wmclass = NULL; - const char *window_title = NULL; + const gchar *wmclass = NULL; + const gchar *window_title = NULL; + gchar *help_page = NULL; - switch (type) { - case ScaleWidget: - switch (target) { - case ResizeLayer: + switch (type) + { + case ScaleWidget: + switch (target) + { + case ResizeLayer: wmclass = "scale_layer"; window_title = _("Scale Layer"); + help_page = "dialogs/scale_layer_dialog.html"; frame = gtk_frame_new (_("Size")); break; - case ResizeImage: + case ResizeImage: wmclass = "image_scale"; window_title = _("Image Scale"); + help_page = "dialogs/scale_image_dialog.html"; frame = gtk_frame_new (_("Pixel Dimensions")); break; - } + } break; - case ResizeWidget: - switch (target) { - case ResizeLayer: + case ResizeWidget: + switch (target) + { + case ResizeLayer: wmclass = "resize_layer"; window_title = _("Resize Layer"); + help_page = "dialogs/resize_layer_dialog.html"; break; - case ResizeImage: + case ResizeImage: wmclass = "image_resize"; window_title = _("Image Resize"); + help_page = "dialogs/resize_image_dialog.html"; break; - } + } frame = gtk_frame_new (_("Size")); break; - } + } - resize->resize_shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (resize->resize_shell), wmclass,"Gimp"); - gtk_window_set_title (GTK_WINDOW (resize->resize_shell), window_title); - gtk_window_set_policy(GTK_WINDOW (resize->resize_shell), FALSE,FALSE,TRUE); - gtk_window_position (GTK_WINDOW (resize->resize_shell), GTK_WIN_POS_MOUSE); + resize->resize_shell = + gimp_dialog_new (window_title, wmclass, + gimp_standard_help_func, help_page, + GTK_WIN_POS_MOUSE, + FALSE, FALSE, TRUE, + + _("OK"), ok_cb, + user_data, NULL, TRUE, FALSE, + _("Cancel"), cancel_cb, + user_data, NULL, FALSE, TRUE, + + NULL); } - /* handle the wm close singal */ - if (delete_cb) - gtk_signal_connect (GTK_OBJECT (resize->resize_shell), "delete_event", - GTK_SIGNAL_FUNC (delete_cb), user_data); - /* handle the image disappearing under our feet */ if (object) { @@ -203,16 +204,9 @@ resize_widget_new (ResizeType type, signame = (target == ResizeLayer) ? "removed" : "destroy"; private->object = object; private->object_destroy_handler = - gtk_signal_connect(GTK_OBJECT (object), signame, cancel_cb, user_data); + gtk_signal_connect (GTK_OBJECT (object), signame, cancel_cb, user_data); } - /* the action area */ - action_items[0].user_data = user_data; - action_items[0].callback = ok_cb; - action_items[1].user_data = user_data; - action_items[1].callback = cancel_cb; - build_action_area (GTK_DIALOG (resize->resize_shell), action_items, 2, 0); - /* the main vbox */ vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); diff --git a/app/gui/resize-dialog.h b/app/gui/resize-dialog.h index 8163f142ba..7a9dced007 100644 --- a/app/gui/resize-dialog.h +++ b/app/gui/resize-dialog.h @@ -73,9 +73,6 @@ Resize * resize_widget_new (ResizeType type, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, - gint (*delete_cb) (GtkWidget *, - GdkEvent *, - gpointer), gpointer user_data); void resize_widget_free (Resize * resize); diff --git a/app/gui/user-install-dialog.c b/app/gui/user-install-dialog.c index 1ae0bc2571..2c6233c258 100644 --- a/app/gui/user-install-dialog.c +++ b/app/gui/user-install-dialog.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,9 +28,9 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "install.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" #include "libgimp/gimpenv.h" @@ -49,13 +48,13 @@ # define USER_INSTALL "user_install.bat" #endif -static void install_run (InstallCallback); -static void install_help (InstallCallback); -static void help_install_callback (GtkWidget *, gpointer); -static void help_ignore_callback (GtkWidget *, gpointer); -static void help_quit_callback (GtkWidget *, gpointer); +static void install_run (InstallCallback); +static void install_help (InstallCallback); +static void help_install_callback (GtkWidget *, gpointer); +static void help_ignore_callback (GtkWidget *, gpointer); +static void help_quit_callback (GtkWidget *, gpointer); static void install_continue_callback (GtkWidget *, gpointer); -static void install_quit_callback (GtkWidget *, gpointer); +static void install_quit_callback (GtkWidget *, gpointer); static GtkWidget *help_widget; static GtkWidget *install_widget; @@ -100,12 +99,6 @@ install_verify (InstallCallback install_callback) static void install_help (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Install"), help_install_callback, NULL, NULL }, - { N_("Ignore"), help_ignore_callback, NULL, NULL }, - { N_("Quit"), help_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -175,7 +168,7 @@ install_help (InstallCallback callback) { 1, N_("generated_brushes\n") }, { 0, N_("\t\tThis is a subdirectory which is used to store brushes\n" "\t\tthat are created with the brush editor. The default\n" - "\t\gimprc file checks this subdirectory when searching for\n" + "\t\tgimprc file checks this subdirectory when searching for\n" "\t\tgenerated brushes.\n") }, { 1, N_("gradients\n") }, @@ -254,13 +247,24 @@ install_help (InstallCallback callback) gint nhelp_lines = sizeof (help_lines) / sizeof (help_lines[0]); gint i; - help_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (help_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (help_widget), "gimp_installation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (help_widget), _("GIMP Installation")); - gtk_window_position (GTK_WINDOW (help_widget), GTK_WIN_POS_CENTER); + help_widget = gimp_dialog_new (_("GIMP Installation"), "gimp_installation", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Install"), help_install_callback, + callback, NULL, TRUE, FALSE, + _("Ignore"), help_ignore_callback, + callback, NULL, FALSE, FALSE, + _("Quit"), help_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (help_widget)->vbox), table); vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); @@ -268,25 +272,12 @@ install_help (InstallCallback callback) gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_widget_set_usize (text, 450, 475); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - action_items[2].user_data = (void *) callback; - build_action_area (GTK_DIALOG (help_widget), action_items, 3, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (help_widget)->vbox), table, - TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, 0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font_emphasis = gdk_font_load ("-*-helvetica-medium-o-normal-*-*-100-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*"); @@ -392,11 +383,6 @@ quote_spaces (char *string) static void install_run (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Continue"), install_continue_callback, NULL, NULL }, - { N_("Quit"), install_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -409,27 +395,28 @@ install_run (InstallCallback callback) int err; int executable = TRUE; - install_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (install_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (install_widget), "installation_log", "Gimp"); - gtk_window_set_title (GTK_WINDOW (install_widget), _("Installation Log")); - gtk_window_position (GTK_WINDOW (install_widget), GTK_WIN_POS_CENTER); + install_widget = gimp_dialog_new (_("Installation Log"), "installation_log", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Continue"), install_continue_callback, + callback, NULL, TRUE, FALSE, + _("Quit"), install_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (install_widget)->vbox), table); + vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); text = gtk_text_new (NULL, vadj); gtk_widget_set_usize (text, 384, 356); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - build_action_area (GTK_DIALOG (install_widget), action_items, 2, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (install_widget)->vbox), table, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, @@ -437,8 +424,6 @@ install_run (InstallCallback callback) GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"); diff --git a/app/histogram_tool.c b/app/histogram_tool.c index 80542b4e5a..2169ca4225 100644 --- a/app/histogram_tool.c +++ b/app/histogram_tool.c @@ -15,15 +15,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "drawable.h" #include "gdisplay.h" +#include "gimpui.h" #include "histogram_tool.h" #include "image_map.h" #include "interface.h" @@ -54,7 +53,6 @@ static void histogram_tool_control (Tool *, ToolAction, gpointer); static HistogramToolDialog * histogram_tool_new_dialog (void); static void histogram_tool_close_callback (GtkWidget *, gpointer); -static gint histogram_tool_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void histogram_tool_value_callback (GtkWidget *, gpointer); static void histogram_tool_red_callback (GtkWidget *, gpointer); static void histogram_tool_green_callback (GtkWidget *, gpointer); @@ -257,12 +255,7 @@ histogram_tool_new_dialog () gint i; gint x, y; - static ActionAreaItem action_items[] = - { - { N_("Close"), histogram_tool_close_callback, NULL, NULL } - }; - - static char * histogram_info_names[] = + static gchar * histogram_info_names[] = { N_("Mean:"), N_("Std Dev:"), @@ -282,23 +275,24 @@ histogram_tool_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - htd = (HistogramToolDialog *) g_malloc (sizeof (HistogramToolDialog)); + htd = g_new (HistogramToolDialog, 1); htd->channel = HISTOGRAM_VALUE; for (i = 0; i < 4; i++) color_option_items [i].user_data = (gpointer) htd; - + htd->hist = gimp_histogram_new (); /* The shell and main vbox */ - htd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (htd->shell), "histogram", "Gimp"); - gtk_window_set_title (GTK_WINDOW (htd->shell), _("Histogram")); + htd->shell = gimp_dialog_new (_("Histogram"), "histogram", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (htd->shell), "delete_event", - (GtkSignalFunc) histogram_tool_delete_callback, - htd); + _("Close"), histogram_tool_close_callback, + htd, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -365,10 +359,6 @@ histogram_tool_new_dialog () gtk_widget_show (htd->info_labels[i]); } - /* The action area */ - action_items[0].user_data = htd; - build_action_area (GTK_DIALOG (htd->shell), action_items, 1, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (htd->shell); @@ -388,16 +378,6 @@ histogram_tool_close_callback (GtkWidget *widget, gtk_widget_hide (htd->shell); } -static gint -histogram_tool_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - histogram_tool_close_callback (widget, client_data); - - return TRUE; -} - static void histogram_tool_value_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/hue_saturation.c b/app/hue_saturation.c index 941aa8221a..33fab136a9 100644 --- a/app/hue_saturation.c +++ b/app/hue_saturation.c @@ -18,6 +18,7 @@ #include #include #include + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -25,6 +26,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "hue_saturation.h" #include "interface.h" @@ -88,8 +90,6 @@ static void hue_saturation_update (HueSaturationDialog *, static void hue_saturation_preview (HueSaturationDialog *); static void hue_saturation_ok_callback (GtkWidget *, gpointer); static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static gint hue_saturation_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void hue_saturation_master_callback (GtkWidget *, gpointer); static void hue_saturation_R_callback (GtkWidget *, gpointer); static void hue_saturation_Y_callback (GtkWidget *, gpointer); @@ -223,7 +223,7 @@ hue_saturation (PixelRegion *srcPR, } -/* by_color select action functions */ +/* hue saturation action functions */ static void hue_saturation_control (Tool *tool, @@ -281,7 +281,7 @@ tools_free_hue_saturation (Tool *tool) color_bal = (HueSaturation *) tool->private; - /* Close the color select dialog */ + /* Close the hue saturation dialog */ if (hue_saturation_dialog) hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog); @@ -299,7 +299,7 @@ hue_saturation_initialize (GDisplay *gdisp) return; } - /* The "hue-saturation color" dialog */ + /* The "hue-saturation" dialog */ if (!hue_saturation_dialog) hue_saturation_dialog = hue_saturation_new_dialog (); else @@ -354,15 +354,9 @@ hue_saturation_new_dialog () GtkWidget *frame; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), hue_saturation_ok_callback, NULL, NULL }, - { N_("Cancel"), hue_saturation_cancel_callback, NULL, NULL } - }; - - char *hue_partition_names[] = + gchar *hue_partition_names[] = { N_("Master"), N_("R"), @@ -384,23 +378,26 @@ hue_saturation_new_dialog () hue_saturation_M_callback }; - hsd = g_malloc (sizeof (HueSaturationDialog)); + hsd = g_new (HueSaturationDialog, 1); hsd->hue_partition = 0; - hsd->preview = TRUE; + hsd->preview = TRUE; /* The shell and main vbox */ - hsd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (hsd->shell), "hue_saturation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (hsd->shell), _("Hue-Saturation")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (hsd->shell), "delete_event", - GTK_SIGNAL_FUNC (hue_saturation_delete_callback), - hsd); + hsd->shell = gimp_dialog_new (_("Hue-Saturation"), "hue_satiration", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), hue_saturation_ok_callback, + hsd, NULL, TRUE, FALSE, + _("Cancel"), hue_saturation_cancel_callback, + hsd, NULL, FALSE, TRUE, + + NULL); main_vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (hsd->shell)->vbox), main_vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (hsd->shell)->vbox), main_vbox); /* The main hbox containing hue partitions and sliders */ main_hbox = gtk_hbox_new (FALSE, 2); @@ -579,12 +576,6 @@ hue_saturation_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = hsd; - action_items[1].user_data = hsd; - build_action_area (GTK_DIALOG (hsd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (main_hbox); @@ -699,16 +690,6 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -hue_saturation_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - hue_saturation_cancel_callback (w, client_data); - - return TRUE; -} - static void hue_saturation_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/info_dialog.c b/app/info_dialog.c index 6528ffb06f..63f7870bae 100644 --- a/app/info_dialog.c +++ b/app/info_dialog.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -143,8 +142,10 @@ info_dialog_delete_callback (GtkWidget *widget, } static InfoDialog * -info_dialog_new_extended (gchar *title, - gboolean in_notebook) +info_dialog_new_extended (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gboolean in_notebook) { InfoDialog *idialog; GtkWidget *shell; @@ -171,7 +172,7 @@ info_dialog_new_extended (gchar *title, info_table = gtk_table_new (2, 0, FALSE); - if( in_notebook) + if (in_notebook) { info_notebook = gtk_notebook_new (); gtk_notebook_append_page (GTK_NOTEBOOK (info_notebook), @@ -196,21 +197,28 @@ info_dialog_new_extended (gchar *title, gtk_widget_show (idialog->info_table); gtk_widget_show (idialog->vbox); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (idialog->shell, help_func, help_data); + return idialog; } /* public functions */ InfoDialog * -info_dialog_notebook_new (gchar *title) +info_dialog_notebook_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data) { - return info_dialog_new_extended (title, TRUE); + return info_dialog_new_extended (title, help_func, help_data, TRUE); } InfoDialog * -info_dialog_new (gchar *title) +info_dialog_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data) { - return info_dialog_new_extended (title, FALSE); + return info_dialog_new_extended (title, help_func, help_data, FALSE); } void @@ -236,7 +244,6 @@ info_dialog_free (InfoDialog *idialog) g_free (idialog); } - void info_dialog_popup (InfoDialog *idialog) { diff --git a/app/info_dialog.h b/app/info_dialog.h index 8bd9e24136..afe8027d24 100644 --- a/app/info_dialog.h +++ b/app/info_dialog.h @@ -18,7 +18,9 @@ #ifndef __INFO_DIALOG_H__ #define __INFO_DIALOG_H__ -#include "gtk/gtk.h" +#include + +#include "gimphelp.h" #include "libgimp/gimpsizeentry.h" #include "libgimp/gimpunit.h" @@ -61,8 +63,12 @@ struct _InfoDialog /* Info Dialog functions */ -InfoDialog *info_dialog_new (gchar *title); -InfoDialog *info_dialog_notebook_new (gchar *title); +InfoDialog *info_dialog_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data); +InfoDialog *info_dialog_notebook_new (gchar *title, + GimpHelpFunc help_func, + gpointer help_data); void info_dialog_free (InfoDialog *idialog); void info_dialog_popup (InfoDialog *idialog); diff --git a/app/info_window.c b/app/info_window.c index d3c894fdb6..46ab01d1ca 100644 --- a/app/info_window.c +++ b/app/info_window.c @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -283,10 +283,12 @@ info_window_create (void *gdisp_ptr) /* create the info dialog */ title_buf = g_strdup_printf (_("%s: Window Info"), title); - info_win = info_dialog_notebook_new (title_buf); + info_win = info_dialog_notebook_new (title_buf, + gimp_standard_help_func, + "dialogs/info_window.html"); g_free (title_buf); - iwd = (InfoWinData *) g_malloc (sizeof (InfoWinData)); + iwd = g_new (InfoWinData, 1); info_win->user_data = iwd; iwd->dimensions_str[0] = '\0'; iwd->resolution_str[0] = '\0'; diff --git a/app/install.c b/app/install.c index 1ae0bc2571..2c6233c258 100644 --- a/app/install.c +++ b/app/install.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,9 +28,9 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "install.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" #include "libgimp/gimpenv.h" @@ -49,13 +48,13 @@ # define USER_INSTALL "user_install.bat" #endif -static void install_run (InstallCallback); -static void install_help (InstallCallback); -static void help_install_callback (GtkWidget *, gpointer); -static void help_ignore_callback (GtkWidget *, gpointer); -static void help_quit_callback (GtkWidget *, gpointer); +static void install_run (InstallCallback); +static void install_help (InstallCallback); +static void help_install_callback (GtkWidget *, gpointer); +static void help_ignore_callback (GtkWidget *, gpointer); +static void help_quit_callback (GtkWidget *, gpointer); static void install_continue_callback (GtkWidget *, gpointer); -static void install_quit_callback (GtkWidget *, gpointer); +static void install_quit_callback (GtkWidget *, gpointer); static GtkWidget *help_widget; static GtkWidget *install_widget; @@ -100,12 +99,6 @@ install_verify (InstallCallback install_callback) static void install_help (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Install"), help_install_callback, NULL, NULL }, - { N_("Ignore"), help_ignore_callback, NULL, NULL }, - { N_("Quit"), help_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -175,7 +168,7 @@ install_help (InstallCallback callback) { 1, N_("generated_brushes\n") }, { 0, N_("\t\tThis is a subdirectory which is used to store brushes\n" "\t\tthat are created with the brush editor. The default\n" - "\t\gimprc file checks this subdirectory when searching for\n" + "\t\tgimprc file checks this subdirectory when searching for\n" "\t\tgenerated brushes.\n") }, { 1, N_("gradients\n") }, @@ -254,13 +247,24 @@ install_help (InstallCallback callback) gint nhelp_lines = sizeof (help_lines) / sizeof (help_lines[0]); gint i; - help_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (help_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (help_widget), "gimp_installation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (help_widget), _("GIMP Installation")); - gtk_window_position (GTK_WINDOW (help_widget), GTK_WIN_POS_CENTER); + help_widget = gimp_dialog_new (_("GIMP Installation"), "gimp_installation", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Install"), help_install_callback, + callback, NULL, TRUE, FALSE, + _("Ignore"), help_ignore_callback, + callback, NULL, FALSE, FALSE, + _("Quit"), help_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (help_widget)->vbox), table); vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); @@ -268,25 +272,12 @@ install_help (InstallCallback callback) gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_widget_set_usize (text, 450, 475); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - action_items[2].user_data = (void *) callback; - build_action_area (GTK_DIALOG (help_widget), action_items, 3, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (help_widget)->vbox), table, - TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, 0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font_emphasis = gdk_font_load ("-*-helvetica-medium-o-normal-*-*-100-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*"); @@ -392,11 +383,6 @@ quote_spaces (char *string) static void install_run (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Continue"), install_continue_callback, NULL, NULL }, - { N_("Quit"), install_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -409,27 +395,28 @@ install_run (InstallCallback callback) int err; int executable = TRUE; - install_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (install_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (install_widget), "installation_log", "Gimp"); - gtk_window_set_title (GTK_WINDOW (install_widget), _("Installation Log")); - gtk_window_position (GTK_WINDOW (install_widget), GTK_WIN_POS_CENTER); + install_widget = gimp_dialog_new (_("Installation Log"), "installation_log", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Continue"), install_continue_callback, + callback, NULL, TRUE, FALSE, + _("Quit"), install_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (install_widget)->vbox), table); + vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); text = gtk_text_new (NULL, vadj); gtk_widget_set_usize (text, 384, 356); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - build_action_area (GTK_DIALOG (install_widget), action_items, 2, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (install_widget)->vbox), table, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, @@ -437,8 +424,6 @@ install_run (InstallCallback callback) GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"); diff --git a/app/interface.c b/app/interface.c index 7a5450b845..05c4875d05 100644 --- a/app/interface.c +++ b/app/interface.c @@ -20,7 +20,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "app_procs.h" #include "colormaps.h" #include "color_area.h" @@ -34,7 +33,9 @@ #include "gdisplay_ops.h" #include "gimage.h" #include "gimpdnd.h" +#include "gimphelp.h" #include "gimprc.h" +#include "gimpui.h" #include "gtkhwrapbox.h" #include "gtkvwrapbox.h" #include "indicator_area.h" @@ -50,7 +51,6 @@ #include "pixmaps/qmasknosel.xpm" #include "pixmaps/navbutton.xpm" -#include "libgimp/gimpsizeentry.h" #include "libgimp/gimpintl.h" /* local functions */ @@ -305,9 +305,10 @@ create_color_area (GtkWidget *parent) col_area = color_area_create (54, 42, default_pixmap, swap_pixmap); gtk_container_add (GTK_CONTAINER (alignment), col_area); - gtk_tooltips_set_tip (tool_tips, col_area, _("Foreground & background colors. The black " - "and white squares reset colors. The arrows swap colors. Double " - "click to select a color from a colorrequester."), + gtk_tooltips_set_tip (tool_tips, col_area, + _("Foreground & background colors. The black " + "and white squares reset colors. The arrows swap colors. Double " + "click to select a color from a colorrequester."), NULL); gtk_widget_show (col_area); gtk_widget_show (alignment); @@ -524,7 +525,7 @@ create_toolbox (void) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* Register dialog */ - dialog_register_toolbox(window); + dialog_register_toolbox (window); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp"); gtk_window_set_title (GTK_WINDOW (window), _("The GIMP")); @@ -587,6 +588,11 @@ create_toolbox (void) /* Install the accelerator table in the main window */ gtk_window_add_accel_group (GTK_WINDOW (window), table); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, + gimp_standard_help_func, + "dialogs/toolbox.html"); + wbox = gtk_vwrap_box_new (FALSE); gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_FILL); gtk_container_set_border_width (GTK_CONTAINER (wbox), 0); @@ -626,7 +632,7 @@ void toolbox_raise_callback (GtkWidget *widget, gpointer client_data) { - gdk_window_raise(toolbox_shell->window); + gdk_window_raise (toolbox_shell->window); } void @@ -873,7 +879,7 @@ create_display_shell (GDisplay* gdisp, gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0); - /* sneak in an extra table here */ + /* sneak in an extra table here */ gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1, GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -939,12 +945,17 @@ create_display_shell (GDisplay* gdisp, gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton, FALSE, TRUE, 0); gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE); - /* the popup menu */ + /* the popup menu */ gdisp->popup = image_popup_menu; - /* the accelerator table for images */ + /* The accelerator table for images */ gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (gdisp->shell, + gimp_standard_help_func, + "dialogs/image_window.html"); + gtk_widget_show (arrow); gtk_widget_show (gdisp->qmaskon); gtk_widget_show (gdisp->qmaskoff); @@ -981,492 +992,12 @@ create_display_shell (GDisplay* gdisp, #warning DODGY? #endif /*__GNUC__ */ gtk_widget_realize (gdisp->canvas); - gdk_window_set_back_pixmap(gdisp->canvas->window, NULL, 0); + gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, 0); /* set the focus to the canvas area */ gtk_widget_grab_focus (gdisp->canvas); - } - -/* - * String, integer, double and size query boxes - */ - -typedef struct _QueryBox QueryBox; - -struct _QueryBox -{ - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *entry; - GtkWidget *ok_button; - GtkObject *object; - QueryFunc callback; - gpointer data; -}; - -static QueryBox * create_query_box (gchar *, gchar *, GtkObject *, gchar *, - QueryFunc, gpointer); -static gint query_box_delete_callback (GtkWidget *, GdkEvent *, gpointer); -static void query_box_cancel_callback (GtkWidget *, gpointer); -static void string_query_box_ok_callback (GtkWidget *, gpointer); -static void int_query_box_ok_callback (GtkWidget *, gpointer); -static void double_query_box_ok_callback (GtkWidget *, gpointer); -static void size_query_box_ok_callback (GtkWidget *, gpointer); - -/* create a generic query box without any entry widget */ -static QueryBox * -create_query_box (gchar *title, - gchar *message, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *label; - - static ActionAreaItem action_items[] = - { - { N_("OK"), (ActionCallback) NULL, NULL, NULL }, - { N_("Cancel"), (ActionCallback) query_box_cancel_callback, NULL, NULL } - }; - - query_box = (QueryBox *) g_malloc (sizeof (QueryBox)); - - qbox = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (qbox), title); - gtk_window_set_wmclass (GTK_WINDOW (qbox), "query_box", "Gimp"); - gtk_window_position (GTK_WINDOW (qbox), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (qbox), "delete_event", - (GtkSignalFunc) query_box_delete_callback, - query_box); - - /* if we are associated with an object, connect to the provided signal */ - if (object && GTK_IS_OBJECT (object) && signal) - gtk_signal_connect (GTK_OBJECT (object), signal, - (GtkSignalFunc) query_box_cancel_callback, - query_box); - else - object = NULL; - - /* The action area */ - action_items[1].user_data = query_box; - build_action_area (GTK_DIALOG (qbox), action_items, 2, 0); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (qbox)->vbox), vbox); - gtk_widget_show (vbox); - - label = gtk_label_new (message); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - query_box->qbox = qbox; - query_box->vbox = vbox; - query_box->entry = NULL; - query_box->ok_button = action_items[0].widget; - query_box->object = object; - query_box->callback = callback; - query_box->data = data; - - return query_box; -} - -GtkWidget * -query_string_box (gchar *title, - gchar *message, - gchar *initial, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *entry; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) string_query_box_ok_callback, - query_box); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); - if (initial) - gtk_entry_set_text (GTK_ENTRY (entry), initial); - gtk_widget_grab_focus (entry); - gtk_widget_show (entry); - - query_box->entry = entry; - - return query_box->qbox; -} - -GtkWidget * -query_int_box (gchar *title, - gchar *message, - gint initial, - gint lower, - gint upper, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkAdjustment* adjustment; - GtkWidget *spinbutton; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) int_query_box_ok_callback, - query_box); - adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); - spinbutton = gtk_spin_button_new (adjustment, 1.0, 0); - gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); - gtk_widget_grab_focus (spinbutton); - gtk_widget_show (spinbutton); - - query_box->entry = spinbutton; - - return query_box->qbox; -} - -GtkWidget * -query_double_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkAdjustment* adjustment; - GtkWidget *spinbutton; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) double_query_box_ok_callback, - query_box); - adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); - spinbutton = gtk_spin_button_new (adjustment, 1.0, digits); - gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); - gtk_widget_grab_focus (spinbutton); - gtk_widget_show (spinbutton); - - query_box->entry = spinbutton; - - return query_box->qbox; -} - -GtkWidget * -query_size_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GUnit unit, - gdouble resolution, - gint dot_for_dot, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data) -{ - QueryBox *query_box; - GtkWidget *sizeentry; - - query_box = create_query_box (title, message, object, signal, callback, data); - - gtk_signal_connect (GTK_OBJECT (query_box->ok_button), "clicked", - (GtkSignalFunc) size_query_box_ok_callback, - query_box); - - sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, - GIMP_SIZE_ENTRY_UPDATE_SIZE); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, - resolution, FALSE); - gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); - gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0, - lower, upper); - gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial); - - gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0); - gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry)); - gtk_widget_show (sizeentry); - - query_box->entry = sizeentry; - - return query_box->qbox; -} - -static gint -query_box_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - query_box_cancel_callback (widget, client_data); - - return TRUE; -} - -static void -query_box_cancel_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - - query_box = (QueryBox *) client_data; - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -string_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gchar *string; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the entry data */ - string = g_strdup (gtk_entry_get_text (GTK_ENTRY (query_box->entry))); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, (gpointer) string); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -int_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gint *integer_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the spinbutton data */ - integer_value = g_malloc (sizeof (gint)); - *integer_value = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry)); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) integer_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -double_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gdouble *double_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the spinbutton data */ - double_value = g_malloc (sizeof (gdouble)); - *double_value = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (query_box->entry)); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) double_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -size_query_box_ok_callback (GtkWidget *widget, - gpointer client_data) -{ - QueryBox *query_box; - gdouble *double_value; - - query_box = (QueryBox *) client_data; - - gtk_widget_set_sensitive (query_box->qbox, FALSE); - - /* disconnect, if we are connected to some signal */ - if (query_box->object) - gtk_signal_disconnect_by_data (query_box->object, query_box); - - /* Get the sizeentry data */ - double_value = g_malloc (sizeof (gdouble)); - *double_value = - gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0); - - /* Pass the selected unit to the callback */ - gtk_object_set_data - (GTK_OBJECT (widget), "size_query_unit", - (gpointer) gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry))); - - /* Call the user defined callback */ - (* query_box->callback) (query_box->qbox, query_box->data, - (gpointer) double_value); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - - -/* - * Message Boxes... - */ - -typedef struct _MessageBox MessageBox; - -struct _MessageBox -{ - GtkWidget *mbox; - GtkCallback callback; - gpointer data; -}; - -static void message_box_close_callback (GtkWidget *, gpointer); -static gint message_box_delete_callback (GtkWidget *, GdkEvent *, gpointer); - -GtkWidget * -message_box (gchar *message, - GtkCallback callback, - gpointer data) -{ - MessageBox *msg_box; - GtkWidget *mbox; - GtkWidget *vbox; - GtkWidget *label; - GtkWidget *button; - - if (! message) - return NULL; - - msg_box = (MessageBox *) g_malloc (sizeof (MessageBox)); - - mbox = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (mbox), "gimp_message", "Gimp"); - gtk_window_set_title (GTK_WINDOW (mbox), _("GIMP Message")); - gtk_window_position (GTK_WINDOW (mbox), GTK_WIN_POS_MOUSE); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (mbox)->action_area), 2); - - gtk_signal_connect (GTK_OBJECT (mbox), "delete_event", - GTK_SIGNAL_FUNC (message_box_delete_callback), - msg_box); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) message_box_close_callback, - msg_box); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (mbox)->action_area), button, - TRUE, TRUE, 0); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (mbox)->vbox), vbox); - gtk_widget_show (vbox); - - label = gtk_label_new (message); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); - gtk_widget_show (label); - - msg_box->mbox = mbox; - msg_box->callback = callback; - msg_box->data = data; - - gtk_widget_show (mbox); - - return mbox; -} - -static gint -message_box_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - message_box_close_callback (widget, client_data); - - return TRUE; -} - -static void -message_box_close_callback (GtkWidget *widget, - gpointer client_data) -{ - MessageBox *msg_box; - - msg_box = (MessageBox *) client_data; - - /* If there is a valid callback, invoke it */ - if (msg_box->callback) - (* msg_box->callback) (widget, msg_box->data); - - /* Destroy the box */ - gtk_widget_destroy (msg_box->mbox); - - g_free (msg_box); -} - - /* DnD functions */ static void toolbox_set_drag_dest (GtkWidget *object) diff --git a/app/interface.h b/app/interface.h index d0cb420d0f..3c9828fc03 100644 --- a/app/interface.h +++ b/app/interface.h @@ -20,85 +20,30 @@ #include "toolsF.h" #include "gdisplayF.h" -#include "libgimp/gimpunit.h" - -/* typedefs */ -typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer); /* externed variables */ extern GtkWidget * tool_widgets[]; extern GtkTooltips * tool_tips; /* function declarations */ -GtkWidget * create_pixmap_widget (GdkWindow *parent, - gchar **data, - gint width, - gint height); +GtkWidget * create_pixmap_widget (GdkWindow *parent, + gchar **data, + gint width, + gint height); -GdkPixmap * create_tool_pixmap (GtkWidget *parent, - ToolType type); +GdkPixmap * create_tool_pixmap (GtkWidget *parent, + ToolType type); void create_toolbox (void); void toolbox_free (void); -void toolbox_raise_callback (GtkWidget *widget, - gpointer client_data); +void toolbox_raise_callback (GtkWidget *widget, + gpointer client_data); -void create_display_shell (GDisplay *gdisp, - gint width, - gint height, - gchar *title, - gint type); - -/* some simple query dialogs - * if object != NULL then the query boxes will connect their cancel callback - * to the provided signal of this object - * - * it's the caller's job to show the returned widgets - */ -GtkWidget * query_string_box (gchar *title, - gchar *message, - gchar *initial, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_int_box (gchar *title, - char *message, - gint initial, - gint lower, - gint upper, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_double_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); -GtkWidget * query_size_box (gchar *title, - gchar *message, - gdouble initial, - gdouble lower, - gdouble upper, - gint digits, - GUnit unit, - gdouble resolution, - gint dot_for_dot, - GtkObject *object, - gchar *signal, - QueryFunc callback, - gpointer data); - -/* a simple message box */ -GtkWidget * message_box (gchar *message, - GtkCallback callback, - gpointer data); +void create_display_shell (GDisplay *gdisp, + gint width, + gint height, + gchar *title, + gint type); #endif /* __INTERFACE_H__ */ diff --git a/app/layers_dialog.c b/app/layers_dialog.c index 450813694e..85efe70682 100644 --- a/app/layers_dialog.c +++ b/app/layers_dialog.c @@ -18,7 +18,6 @@ #include #include #include "gdk/gdkkeysyms.h" -#include "actionarea.h" #include "appenv.h" #include "buildmenu.h" #include "colormaps.h" @@ -30,6 +29,7 @@ #include "gimage_mask.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "layers_dialog.h" @@ -3256,16 +3256,6 @@ new_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -new_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - new_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void new_layer_query_fill_type_callback (GtkWidget *widget, gpointer data) @@ -3293,11 +3283,6 @@ layers_dialog_new_layer_query (GimpImage* gimage) GSList *group; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), new_layer_query_ok_callback, NULL, NULL }, - { N_("Cancel"), new_layer_query_cancel_callback, NULL, NULL } - }; static gchar *button_names[] = { N_("Foreground"), @@ -3313,16 +3298,19 @@ layers_dialog_new_layer_query (GimpImage* gimage) options->gimage = gimage; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), - "new_layer_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("New Layer Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("New Layer Options"), "new_layer_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (new_layer_query_delete_callback), - options); + _("OK"), new_layer_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), new_layer_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3439,10 +3427,6 @@ layers_dialog_new_layer_query (GimpImage* gimage) gtk_widget_show (radio_box); gtk_widget_show (radio_frame); - 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 (vbox); gtk_widget_show (options->query_box); } @@ -3506,16 +3490,6 @@ edit_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -edit_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - edit_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_edit_layer_query (LayerWidget *layer_widget) { @@ -3524,29 +3498,25 @@ layers_dialog_edit_layer_query (LayerWidget *layer_widget) GtkWidget *hbox; GtkWidget *label; - static ActionAreaItem action_items[] = - { - { N_("OK"), edit_layer_query_ok_callback, NULL, NULL }, - { N_("Cancel"), edit_layer_query_cancel_callback, NULL, NULL } - }; - /* The new options structure */ options = g_new (EditLayerOptions, 1); options->layer = layer_widget->layer; options->gimage = layer_widget->gimage; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), - "edit_layer_attrributes", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), - _("Edit Layer Attributes")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Edit Layer Attributes"), "edit_layer_attributes", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (edit_layer_query_delete_callback), - options); + _("OK"), edit_layer_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), edit_layer_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3572,10 +3542,6 @@ layers_dialog_edit_layer_query (LayerWidget *layer_widget) gtk_widget_show (hbox); - 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 (vbox); gtk_widget_show (options->query_box); } @@ -3626,16 +3592,6 @@ add_mask_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -add_mask_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - add_mask_query_cancel_callback (widget, data); - - return TRUE; -} - static void add_mask_query_fill_type_callback (GtkWidget *widget, gpointer data) @@ -3659,11 +3615,6 @@ layers_dialog_add_mask_query (Layer *layer) GSList *group = NULL; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), add_mask_query_ok_callback, NULL, NULL }, - { N_("Cancel"), add_mask_query_cancel_callback, NULL, NULL } - }; static gchar *button_names[] = { N_("White (Full Opacity)"), @@ -3678,15 +3629,19 @@ layers_dialog_add_mask_query (Layer *layer) options->add_mask_type = ADD_WHITE_MASK; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), "add_mask_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("Add Mask Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Add Mask Options"), "add_mask_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (add_mask_query_delete_callback), - options); + _("OK"), add_mask_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), add_mask_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3719,10 +3674,6 @@ layers_dialog_add_mask_query (Layer *layer) gtk_widget_show (radio_box); gtk_widget_show (radio_frame); - 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 (vbox); gtk_widget_show (options->query_box); } @@ -3778,16 +3729,6 @@ apply_mask_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -apply_mask_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - apply_mask_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_apply_mask_query (Layer *layer) { @@ -3795,27 +3736,26 @@ layers_dialog_apply_mask_query (Layer *layer) GtkWidget *vbox; GtkWidget *label; - static ActionAreaItem action_items[] = - { - { N_("Apply"), apply_mask_query_apply_callback, NULL, NULL }, - { N_("Discard"), apply_mask_query_discard_callback, NULL, NULL }, - { N_("Cancel"), apply_mask_query_cancel_callback, NULL, NULL } - }; - /* The new options structure */ options = g_new (ApplyMaskOptions, 1); options->layer = layer; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), "layer_mask_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("Layer Mask Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Layer Mask Options"), "layer_mask_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (apply_mask_query_delete_callback), - options); + _("Apply"), apply_mask_query_apply_callback, + options, NULL, TRUE, FALSE, + _("Discard"), apply_mask_query_discard_callback, + options, NULL, FALSE, FALSE, + _("Cancel"), apply_mask_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -3828,11 +3768,6 @@ layers_dialog_apply_mask_query (Layer *layer) gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); - action_items[0].user_data = options; - action_items[1].user_data = options; - action_items[2].user_data = options; - build_action_area (GTK_DIALOG (options->query_box), action_items, 3, 0); - gtk_widget_show (vbox); gtk_widget_show (options->query_box); } @@ -3898,16 +3833,6 @@ scale_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -scale_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - scale_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_scale_layer_query (GImage *gimage, Layer *layer) @@ -3928,7 +3853,6 @@ layers_dialog_scale_layer_query (GImage *gimage, TRUE, scale_layer_query_ok_callback, scale_layer_query_cancel_callback, - scale_layer_query_delete_callback, options); gtk_widget_show (options->resize->resize_shell); @@ -3997,16 +3921,6 @@ resize_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -resize_layer_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - resize_layer_query_cancel_callback (widget, data); - - return TRUE; -} - static void layers_dialog_resize_layer_query (GImage *gimage, Layer *layer) @@ -4027,7 +3941,6 @@ layers_dialog_resize_layer_query (GImage *gimage, TRUE, resize_layer_query_ok_callback, resize_layer_query_cancel_callback, - resize_layer_query_delete_callback, options); gtk_widget_show (options->resize->resize_shell); @@ -4077,16 +3990,6 @@ layer_merge_query_cancel_callback (GtkWidget *widget, g_free (options); } -static gint -layer_merge_query_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - layer_merge_query_cancel_callback (widget, data); - - return TRUE; -} - static void layer_merge_query_type_callback (GtkWidget *widget, gpointer data) @@ -4112,11 +4015,6 @@ layers_dialog_layer_merge_query (GImage *gimage, GSList *group = NULL; gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), layer_merge_query_ok_callback, NULL, NULL }, - { N_("Cancel"), layer_merge_query_cancel_callback, NULL, NULL } - }; static gchar *button_names[] = { N_("Expanded as necessary"), @@ -4132,15 +4030,19 @@ layers_dialog_layer_merge_query (GImage *gimage, options->merge_type = EXPAND_AS_NECESSARY; /* The dialog */ - options->query_box = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (options->query_box), "layer_merge_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options->query_box), _("Layer Merge Options")); - gtk_window_position (GTK_WINDOW (options->query_box), GTK_WIN_POS_MOUSE); + options->query_box = + gimp_dialog_new (_("Layer Merge Options"), "layer_merge_options", + gimp_standard_help_func, + "dialogs/layers_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (layer_merge_query_delete_callback), - options); + _("OK"), layer_merge_query_ok_callback, + options, NULL, TRUE, FALSE, + _("Cancel"), layer_merge_query_cancel_callback, + options, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -4176,10 +4078,6 @@ layers_dialog_layer_merge_query (GImage *gimage, gtk_widget_show (radio_box); gtk_widget_show (radio_frame); - 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 (vbox); gtk_widget_show (options->query_box); } diff --git a/app/lc_dialog.c b/app/lc_dialog.c index 02a4bf0c98..1e7a8ef205 100644 --- a/app/lc_dialog.c +++ b/app/lc_dialog.c @@ -16,15 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "dialog_handler.h" #include "gimage.h" #include "gimpcontext.h" #include "gimprc.h" #include "gimpset.h" -#include "interface.h" +#include "gimpui.h" #include "image_render.h" #include "lc_dialog.h" #include "lc_dialogP.h" @@ -100,17 +100,19 @@ lc_dialog_create (GimpImage* gimage) return; } - lc_dialog = g_malloc (sizeof (LCDialog)); - lc_dialog->shell = gtk_dialog_new (); + lc_dialog = g_new (LCDialog, 1); + lc_dialog->shell = + gimp_dialog_new (_("Layers & Channels"), "layers_and_channels", + gimp_standard_help_func, + "dialogs/layers_and_channels_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + NULL); lc_dialog->gimage = NULL; lc_dialog->auto_follow_active = TRUE; /* Register the dialog */ dialog_register (lc_dialog->shell); - - gtk_window_set_title (GTK_WINDOW (lc_dialog->shell), _("Layers & Channels")); - gtk_window_set_wmclass (GTK_WINDOW (lc_dialog->shell), - "layers_and_channels", "Gimp"); session_set_window_geometry (lc_dialog->shell, &lc_dialog_session_info, TRUE); /* Handle the WM delete event */ @@ -275,7 +277,7 @@ lc_dialog_flush () } static gint -image_menu_preview_update_do(GimpImage *gimage) +image_menu_preview_update_do (GimpImage *gimage) { if(lc_dialog) { @@ -296,7 +298,7 @@ lc_dialog_menu_preview_dirty (GtkObject *obj, } void -lc_dialog_preview_update(GimpImage *gimage) +lc_dialog_preview_update (GimpImage *gimage) { if(!preview_size) return; diff --git a/app/levels.c b/app/levels.c index caa19c3814..e29e1e4658 100644 --- a/app/levels.c +++ b/app/levels.c @@ -21,7 +21,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "drawable.h" @@ -29,6 +28,7 @@ #include "gdisplay.h" #include "histogramwidget.h" #include "gimphistogram.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" #include "levels.h" @@ -138,7 +138,6 @@ static void levels_alpha_callback (GtkWidget *, gpointer); static void levels_auto_levels_callback (GtkWidget *, gpointer); static void levels_ok_callback (GtkWidget *, gpointer); static void levels_cancel_callback (GtkWidget *, gpointer); -static gint levels_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void levels_load_callback (GtkWidget *, gpointer); static void levels_save_callback (GtkWidget *, gpointer); static void levels_preview_update (GtkWidget *, gpointer); @@ -342,37 +341,34 @@ levels_new_dialog () GtkWidget *menu; GtkWidget *hbbox; GtkWidget *button; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("Auto Levels"), levels_auto_levels_callback, NULL, NULL }, - { N_("OK"), levels_ok_callback, NULL, NULL }, - { N_("Cancel"), levels_cancel_callback, NULL, NULL } - }; - - ld = g_malloc (sizeof (LevelsDialog)); + ld = g_new (LevelsDialog, 1); ld->preview = TRUE; - - ld->lut = gimp_lut_new(); - ld->hist = gimp_histogram_new(); + ld->lut = gimp_lut_new(); + ld->hist = gimp_histogram_new(); for (i = 0; i < 5; i++) color_option_items [i].user_data = (gpointer) ld; /* The shell and main vbox */ - ld->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (ld->shell), "levels", "Gimp"); - gtk_window_set_title (GTK_WINDOW (ld->shell), _("Levels")); + ld->shell = gimp_dialog_new (_("Levels"), "levels", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (ld->shell), "delete_event", - GTK_SIGNAL_FUNC (levels_delete_callback), - ld); + _("Auto Levels"), levels_auto_levels_callback, + ld, NULL, FALSE, FALSE, + _("OK"), levels_ok_callback, + ld, NULL, TRUE, FALSE, + _("Cancel"), levels_cancel_callback, + ld, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (ld->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ld->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -571,12 +567,6 @@ levels_new_dialog () gtk_widget_show (hbbox); - /* The action area */ - action_items[0].user_data = ld; - action_items[1].user_data = ld; - action_items[2].user_data = ld; - build_action_area (GTK_DIALOG (ld->shell), action_items, 3, 0); - gtk_widget_show (vbox); gtk_widget_show (ld->shell); @@ -1015,16 +1005,6 @@ levels_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -levels_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - levels_cancel_callback (w, client_data); - - return TRUE; -} - static void levels_cancel_callback (GtkWidget *widget, gpointer client_data) @@ -1409,9 +1389,8 @@ static void file_ok_callback (GtkWidget *widget, gpointer data) { - FILE *f; - char *filename; - int i; + FILE *f; + gchar *filename; filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_dlg)); diff --git a/app/measure.c b/app/measure.c index d3683b7c12..caa4a71711 100644 --- a/app/measure.c +++ b/app/measure.c @@ -18,12 +18,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include "actionarea.h" #include "appenv.h" #include "draw_core.h" +#include "gimphelp.h" #include "info_dialog.h" #include "measure.h" #include "tool_options_ui.h" @@ -266,11 +266,13 @@ measure_tool_button_press (Tool *tool, if (!measure_tool_info && (measure_tool_options->use_info_window || !GTK_WIDGET_VISIBLE (gdisp->statusarea))) { - measure_tool_info = info_dialog_new (_("Measure Tool")); + measure_tool_info = info_dialog_new (_("Measure Tool"), + tools_help_func, NULL); info_dialog_add_label (measure_tool_info, _("Distance:"), distance_buf); info_dialog_add_label (measure_tool_info, _("Angle:"), angle_buf); action_items[0].user_data = measure_tool_info; - build_action_area (GTK_DIALOG (measure_tool_info->shell), action_items, 1, 0); + build_action_area (GTK_DIALOG (measure_tool_info->shell), + action_items, 1, 0); } gdk_pointer_grab (gdisp->canvas->window, FALSE, diff --git a/app/menus.c b/app/menus.c index a49ed3c3e1..5550911d3a 100644 --- a/app/menus.c +++ b/app/menus.c @@ -69,6 +69,7 @@ static GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Open"), "O", file_open_cmd_callback, 0 }, { N_("/File/Acquire"), NULL, NULL, 0, "" }, { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, + { N_("/File/Help..."), NULL, gimp_help_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, diff --git a/app/menus/menus.c b/app/menus/menus.c index a49ed3c3e1..5550911d3a 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -69,6 +69,7 @@ static GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Open"), "O", file_open_cmd_callback, 0 }, { N_("/File/Acquire"), NULL, NULL, 0, "" }, { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, + { N_("/File/Help..."), NULL, gimp_help_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, diff --git a/app/module_db.c b/app/module_db.c index 3f0487d9b6..a2fb3ebda5 100644 --- a/app/module_db.c +++ b/app/module_db.c @@ -36,10 +36,10 @@ #include "gimpsignal.h" #include "gimprc.h" #include "datafiles.h" -#include "actionarea.h" #include "gimpset.h" -#include "libgimp/gimpenv.h" +#include "gimpui.h" +#include "libgimp/gimpenv.h" #include "libgimp/gimpmodule.h" #include "libgimp/gimpintl.h" @@ -258,19 +258,21 @@ module_db_browser_new (void) GtkWidget *listbox; GtkWidget *button; browser_st *st; - ActionAreaItem action_items[] = - { - { N_("OK"), browser_popdown_callback, NULL, NULL } - }; + shell = gimp_dialog_new (_("Module DB"), "module_db_dialog", + gimp_standard_help_func, + "dialogs/module_db_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (shell), "module_db_dialog", "Gimp"); - gtk_window_set_title (GTK_WINDOW (shell), _("Module DB")); + _("OK"), browser_popdown_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 5); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox); gtk_widget_show (vbox); listbox = gtk_scrolled_window_new (NULL, NULL); @@ -333,12 +335,6 @@ module_db_browser_new (void) gtk_signal_connect (GTK_OBJECT (shell), "destroy", browser_destroy_callback, st); - action_items[0].user_data = shell; - build_action_area (GTK_DIALOG (shell), - action_items, - sizeof( action_items)/sizeof( ActionAreaItem), - 0); - return shell; } diff --git a/app/nav_window.c b/app/nav_window.c index 9df75642b8..d6e08dd238 100644 --- a/app/nav_window.c +++ b/app/nav_window.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,6 +28,7 @@ #include "info_window.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimphelp.h" #include "gximage.h" #include "interface.h" #include "scroll.h" @@ -1144,19 +1144,21 @@ nav_window_create (void *gdisp_ptr) /* create the info dialog */ title_buf = g_strdup_printf (_("%s: Window Navigation"), title); - info_win = info_dialog_new (title_buf); - dialog_register(info_win->shell); + info_win = info_dialog_new (title_buf, + gimp_standard_help_func, + "dialogs/navigation_window.html"); + dialog_register (info_win->shell); gtk_signal_connect (GTK_OBJECT (info_win->shell), "destroy", (GtkSignalFunc) nav_window_destroy_callback, info_win); g_free (title_buf); - - iwd = create_dummy_iwd(gdisp_ptr,NAV_WINDOW); + + iwd = create_dummy_iwd (gdisp_ptr, NAV_WINDOW); info_win->user_data = iwd; iwd->info_win = info_win; /* Add preview */ - container = info_window_image_preview_new(info_win); + container = info_window_image_preview_new (info_win); gtk_table_attach_defaults (GTK_TABLE (info_win->info_table), container, 0, 2, 0, 1); /* Create the action area */ diff --git a/app/palette.c b/app/palette.c index 6a4672a1bf..9e405239c6 100644 --- a/app/palette.c +++ b/app/palette.c @@ -31,7 +31,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "color_area.h" @@ -41,9 +40,9 @@ #include "errors.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient_header.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "palette_entries.h" #include "session.h" @@ -1075,11 +1074,16 @@ static void palette_new_entries_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box (_("New Palette"), - _("Enter a name for new palette"), - NULL, - NULL, NULL, - palette_add_entries_callback, data)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New Palette"), + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + _("Enter a name for new palette"), + NULL, + NULL, NULL, + palette_add_entries_callback, data); + gtk_widget_show (qbox); } static void @@ -1375,17 +1379,6 @@ palette_close_callback (GtkWidget *widget, } } -static gint -palette_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - palette_close_callback (widget, data); - - return TRUE; -} - - static void color_name_entry_changed (GtkWidget *widget, gpointer data) @@ -2015,18 +2008,6 @@ create_palette_dialog (gint vert) GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; - - static ActionAreaItem vert_action_items[] = - { - { N_("Edit"), palette_edit_palette_callback, NULL, NULL }, - { N_("Close"), palette_close_callback, NULL, NULL } - }; - static ActionAreaItem horz_action_items[] = - { - { N_("Save"), palette_save_palettes_callback, NULL, NULL }, - { N_("Refresh"), palette_refresh_callback, NULL, NULL }, - { N_("Close"), palette_close_callback, NULL, NULL } - }; palette = g_new (PaletteDialog, 1); @@ -2039,26 +2020,42 @@ create_palette_dialog (gint vert) palette->columns_valid = TRUE; palette->freeze_update = FALSE; - palette->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (palette->shell), "color_palette", "Gimp"); - if (!vert) { + palette->shell = + gimp_dialog_new (_("Color Palette Edit"), "color_palette_edit", + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Save"), palette_save_palettes_callback, + palette, NULL, FALSE, FALSE, + _("Refresh"), palette_refresh_callback, + palette, NULL, FALSE, FALSE, + _("Close"), palette_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); gtk_widget_set_usize (palette->shell, 615, 200); - gtk_window_set_title (GTK_WINDOW (palette->shell), - _("Color Palette Edit")); } else { - gtk_widget_set_usize (palette->shell, 230, 300); - gtk_window_set_title (GTK_WINDOW (palette->shell), - _("Color Palette")); - } + palette->shell = + gimp_dialog_new (_("Color Palette"), "color_palette", + gimp_standard_help_func, + "dialogs/color_palette_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (palette->shell), "delete_event", - GTK_SIGNAL_FUNC (palette_dialog_delete_callback), - palette); + _("Edit"), palette_edit_palette_callback, + palette, NULL, FALSE, FALSE, + _("Close"), palette_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); + gtk_widget_set_usize (palette->shell, 230, 300); + } /* The main container widget */ if (vert) @@ -2260,20 +2257,6 @@ create_palette_dialog (gint vert) gtk_widget_show (button); } - if (!vert) - { - horz_action_items[0].user_data = palette; - horz_action_items[1].user_data = palette; - horz_action_items[2].user_data = palette; - build_action_area (GTK_DIALOG (palette->shell), horz_action_items, 3, 2); - } - else - { - vert_action_items[0].user_data = palette; - vert_action_items[1].user_data = palette; - build_action_area (GTK_DIALOG (palette->shell), vert_action_items, 2, 1); - } - palette->gc = gdk_gc_new (palette->shell->window); palette_popup_menu (palette); @@ -2441,17 +2424,6 @@ import_dialog_import_callback (GtkWidget *widget, } } -static gint -import_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - import_dialog_close_callback (widget, data); - - return TRUE; -} - - static void palette_merge_entries_callback (GtkWidget *widget, gpointer data, @@ -2508,12 +2480,17 @@ static void palette_merge_dialog_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box (_("Merge Palette"), - _("Enter a name for merged palette"), - NULL, - NULL, NULL, - palette_merge_entries_callback, - data)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("Merge Palette"), + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + _("Enter a name for merged palette"), + NULL, + NULL, NULL, + palette_merge_entries_callback, + data); + gtk_widget_show (qbox); } static void @@ -2845,24 +2822,23 @@ palette_import_dialog (PaletteDialog *palette) GtkWidget *image; GtkWidget *hscale; - static ActionAreaItem action_items[] = - { - { N_("Import"), import_dialog_import_callback, NULL, NULL }, - { N_("Close"), import_dialog_close_callback, NULL, NULL } - }; - import_dialog = g_new (ImportDialog, 1); import_dialog->image_list = NULL; import_dialog->gimage = NULL; - import_dialog->dialog = dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "import_palette", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Import Palette")); + import_dialog->dialog = dialog = + gimp_dialog_new (_("Import Palette"), "import_palette", + gimp_standard_help_func, + "dialogs/import_palette_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (import_dialog_delete_callback), - (gpointer)palette); + _("Import"), import_dialog_import_callback, + palette, NULL, FALSE, FALSE, + _("Close"), import_dialog_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 4); @@ -2986,11 +2962,6 @@ palette_import_dialog (PaletteDialog *palette) gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); - /* The action area */ - action_items[0].user_data = palette; - action_items[1].user_data = palette; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Fill with the selected gradient */ palette_import_fill_grad_preview (image, curr_gradient); import_dialog->import_type = GRAD_IMPORT; diff --git a/app/palette_select.c b/app/palette_select.c index a758600dbe..07599ce323 100644 --- a/app/palette_select.c +++ b/app/palette_select.c @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -27,13 +26,13 @@ #include #include -#include "actionarea.h" #include "colormaps.h" #include "color_area.h" #include "color_select.h" #include "datafiles.h" #include "errors.h" #include "gimprc.h" +#include "gimpui.h" #include "interface.h" #include "palette.h" #include "palette_entries.h" @@ -49,12 +48,6 @@ static GSList *active_dialogs = NULL; static void palette_select_close_callback (GtkWidget *, gpointer); static void palette_select_edit_callback (GtkWidget *, gpointer); -static ActionAreaItem action_items[] = -{ - { N_("Edit"), palette_select_edit_callback, NULL, NULL }, - { N_("Close"), palette_select_close_callback, NULL, NULL } -}; - void palette_select_set_text_all (PaletteEntriesP entries) { @@ -219,16 +212,6 @@ palette_select_close_callback (GtkWidget *widget, /* } */ } -static gint -palette_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - palette_select_close_callback (widget, client_data); - - return TRUE; -} - PaletteSelectP palette_new_selection (gchar *title, gchar *initial_palette) @@ -244,29 +227,33 @@ palette_new_selection (gchar *title, palette_select_palette_init (); - psp = g_malloc (sizeof (struct _PaletteSelect)); + psp = g_new (struct _PaletteSelect, 1); psp->callback_name = NULL; /* The shell and main vbox */ - psp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "paletteselection", "Gimp"); - - gtk_window_set_policy (GTK_WINDOW (psp->shell), FALSE, TRUE, FALSE); + psp->shell = gimp_dialog_new (title ? title : _("Palette Selection"), + "palette_selection", + gimp_standard_help_func, + "dialogs/palette_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Edit"), palette_select_edit_callback, + psp, NULL, TRUE, FALSE, + _("Close"), palette_select_close_callback, + psp, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 1); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (psp->shell)->vbox), vbox, TRUE, TRUE, 0); - - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (psp->shell), "delete_event", - GTK_SIGNAL_FUNC (palette_select_delete_callback), - psp); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox); /* clist preview of gradients */ scrolled_win = gtk_scrolled_window_new (NULL, NULL); psp->clist = gtk_clist_new (3); - gtk_clist_set_shadow_type (GTK_CLIST(psp->clist), GTK_SHADOW_IN); + gtk_clist_set_shadow_type (GTK_CLIST (psp->clist), GTK_SHADOW_IN); gtk_clist_set_row_height (GTK_CLIST (psp->clist), SM_PREVIEW_HEIGHT + 2); @@ -275,10 +262,9 @@ palette_new_selection (gchar *title, gtk_clist_set_column_title (GTK_CLIST (psp->clist), 1, _("Ncols")); gtk_clist_set_column_title (GTK_CLIST (psp->clist), 2, _("Name")); gtk_clist_column_titles_show (GTK_CLIST(psp->clist)); - gtk_clist_set_column_width (GTK_CLIST (psp->clist), 0, SM_PREVIEW_WIDTH+2); + gtk_clist_set_column_width (GTK_CLIST (psp->clist), 0, SM_PREVIEW_WIDTH + 2); hbox = gtk_hbox_new (FALSE, 8); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); @@ -295,19 +281,6 @@ palette_new_selection (gchar *title, /* GTK_SIGNAL_FUNC(sel_list_item_update), */ /* (gpointer) gsp); */ - action_items[0].user_data = psp; - action_items[1].user_data = psp; - build_action_area (GTK_DIALOG (psp->shell), action_items, 2, 0); - - if (!title) - { - gtk_window_set_title (GTK_WINDOW (psp->shell), _("Palette Selection")); - } - else - { - gtk_window_set_title (GTK_WINDOW (psp->shell), title); - } - select_pos = -1; if (initial_palette && strlen (initial_palette)) { diff --git a/app/paths_dialog.c b/app/paths_dialog.c index e519b733d8..fafffaaa49 100644 --- a/app/paths_dialog.c +++ b/app/paths_dialog.c @@ -27,7 +27,6 @@ #include "appenv.h" #include "draw_core.h" -#include "actionarea.h" #include "colormaps.h" #include "drawable.h" #include "errors.h" @@ -39,7 +38,7 @@ #include "gdisplay.h" #include "gimprc.h" #include "gimpset.h" -#include "general.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "lc_dialogP.h" @@ -50,7 +49,6 @@ #include "pathsP.h" #include "paths_dialog.h" #include "paths_dialogP.h" -#include "resize.h" #include "session.h" #include "undo.h" @@ -1216,6 +1214,7 @@ do_rename_paths_callback(GtkWidget *widget, gpointer call_data, gpointer client_ static void paths_dialog_edit_path_query (GtkWidget *widget) { + GtkWidget *qbox; GdkBitmap *mask; gchar *text; gint ret; @@ -1229,11 +1228,14 @@ paths_dialog_edit_path_query (GtkWidget *widget) NULL, &mask); - gtk_widget_show (query_string_box (_("Rename path"), - _("Enter a new name for the path"), - text, - NULL, NULL, - do_rename_paths_callback, widget)); + qbox = gimp_query_string_box (_("Rename path"), + gimp_standard_help_func, + "dialogs/paths_dialog.html", + _("Enter a new name for the path"), + text, + NULL, NULL, + do_rename_paths_callback, widget); + gtk_widget_show (qbox); } static gint @@ -1275,7 +1277,7 @@ paths_list_events (GtkWidget *widget, { if(this_colunm == 1) { - paths_dialog_edit_path_query(widget); + paths_dialog_edit_path_query (widget); return TRUE; } else diff --git a/app/pattern_select.c b/app/pattern_select.c index 22478e73bf..dc4bb3b6f5 100644 --- a/app/pattern_select.c +++ b/app/pattern_select.c @@ -17,11 +17,11 @@ */ #include #include "appenv.h" -#include "actionarea.h" #include "patterns.h" #include "pattern_select.h" #include "colormaps.h" #include "errors.h" +#include "gimpui.h" #include "session.h" #include "libgimp/gimpintl.h" @@ -55,7 +55,6 @@ static void preview_calc_scrollbar (PatternSelectP); static void pattern_select_show_selected (PatternSelectP, int, int); static void update_active_pattern_field (PatternSelectP); static void pattern_select_close_callback (GtkWidget *, gpointer); -static gint pattern_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void pattern_select_refresh_callback (GtkWidget *, gpointer); static gint pattern_select_events (GtkWidget *, GdkEvent *, PatternSelectP); static gint pattern_select_resize (GtkWidget *, GdkEvent *, PatternSelectP); @@ -81,12 +80,6 @@ pattern_select_new (gchar *title, GtkWidget *sbar; GtkWidget *label_box; - static ActionAreaItem action_items[2] = - { - { N_("Refresh"), pattern_select_refresh_callback, NULL, NULL }, - { N_("Close"), pattern_select_close_callback, NULL, NULL } - }; - psp = g_new (_PatternSelect, 1); psp->preview = NULL; psp->old_col = psp->old_row = 0; @@ -97,23 +90,44 @@ pattern_select_new (gchar *title, psp->NUM_PATTERN_ROWS = STD_PATTERN_COLUMNS; /* The shell and main vbox */ - psp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "patternselection", "Gimp"); + if (title) + { + psp->shell = + gimp_dialog_new (title, "pattern_selection", + gimp_standard_help_func, + "dialogs/pattern_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Close"), pattern_select_close_callback, + psp, NULL, TRUE, TRUE, + + NULL); - if(!title) - { - gtk_window_set_title (GTK_WINDOW (psp->shell), _("Pattern Selection")); - session_set_window_geometry (psp->shell, &pattern_select_session_info, - TRUE); - } - else - { - gtk_window_set_title (GTK_WINDOW (psp->shell), title); if (initial_pattern && strlen (initial_pattern)) { active = pattern_list_get_pattern (pattern_list, initial_pattern); } } + else + { + psp->shell = + gimp_dialog_new (_("Pattern Selection"), "pattern_selection", + gimp_standard_help_func, + "dialogs/pattern_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Refresh"), pattern_select_refresh_callback, + psp, NULL, FALSE, FALSE, + _("Close"), pattern_select_close_callback, + psp, NULL, TRUE, TRUE, + + NULL); + + session_set_window_geometry (psp->shell, &pattern_select_session_info, + TRUE); + } /* update the active selection */ if (!active) @@ -121,13 +135,6 @@ pattern_select_new (gchar *title, psp->pattern = active; - gtk_window_set_policy (GTK_WINDOW (psp->shell), FALSE, TRUE, FALSE); - - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (psp->shell), "delete_event", - GTK_SIGNAL_FUNC (pattern_select_delete_callback), - psp); - /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -190,14 +197,6 @@ pattern_select_new (gchar *title, gtk_widget_show (hbox); gtk_widget_show (frame); - /* The action area */ - action_items[0].user_data = psp; - action_items[1].user_data = psp; - if (title) - build_action_area (GTK_DIALOG (psp->shell), &action_items[1], 1, 0); - else - build_action_area (GTK_DIALOG (psp->shell), action_items, 2, 1); - gtk_widget_show (psp->options_box); gtk_widget_show (vbox); gtk_widget_show (psp->shell); @@ -799,18 +798,8 @@ pattern_select_events (GtkWidget *widget, return FALSE; } -static gint -pattern_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - pattern_select_close_callback (widget, client_data); - - return TRUE; -} - static void -pattern_select_close_callback (GtkWidget *w, +pattern_select_close_callback (GtkWidget *widget, gpointer client_data) { PatternSelectP psp; @@ -831,7 +820,7 @@ pattern_select_close_callback (GtkWidget *w, } static void -pattern_select_refresh_callback (GtkWidget *w, +pattern_select_refresh_callback (GtkWidget *widget, gpointer client_data) { PatternSelectP psp; @@ -892,7 +881,7 @@ pattern_select_scroll_update (GtkAdjustment *adjustment, /* Close active dialogs that no longer have PDB registered for them */ void -patterns_check_dialogs(void) +patterns_check_dialogs (void) { GSList *list; PatternSelectP psp; @@ -908,13 +897,13 @@ patterns_check_dialogs(void) name = psp->callback_name; prec = procedural_db_lookup(name); - - if(!prec) + + if (!prec) { - pattern_active_dialogs = g_slist_remove(pattern_active_dialogs,psp); + pattern_active_dialogs = g_slist_remove (pattern_active_dialogs,psp); /* Can alter pattern_active_dialogs list*/ - pattern_select_close_callback(NULL,psp); + pattern_select_close_callback (NULL, psp); } } } diff --git a/app/perspective_tool.c b/app/perspective_tool.c index eff27a770a..8cf983f639 100644 --- a/app/perspective_tool.c +++ b/app/perspective_tool.c @@ -57,7 +57,8 @@ perspective_tool_transform (Tool *tool, if (!transform_info) { transform_info = - info_dialog_new (_("Perspective Transform Information")); + info_dialog_new (_("Perspective Transform Information"), + tools_help_func, NULL); info_dialog_add_label (transform_info, "Matrix:", matrix_row_buf[0]); info_dialog_add_label (transform_info, "", matrix_row_buf[1]); diff --git a/app/posterize.c b/app/posterize.c index bd1a963823..465dff30ed 100644 --- a/app/posterize.c +++ b/app/posterize.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -23,13 +22,13 @@ #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "gdisplay.h" #include "image_map.h" #include "interface.h" #include "posterize.h" #include "gimplut.h" +#include "gimpui.h" #include "lut_funcs.h" #include "libgimp/gimpintl.h" @@ -77,7 +76,6 @@ static void posterize_ok_callback (GtkWidget *, gpointer); static void posterize_cancel_callback (GtkWidget *, gpointer); static void posterize_preview_update (GtkWidget *, gpointer); static void posterize_levels_text_update (GtkWidget *, gpointer); -static gint posterize_delete_callback (GtkWidget *, GdkEvent *, gpointer); /* posterize select action functions */ @@ -190,29 +188,28 @@ posterize_new_dialog () GtkWidget *label; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), posterize_ok_callback, NULL, NULL }, - { N_("Cancel"), posterize_cancel_callback, NULL, NULL } - }; - - pd = g_malloc (sizeof (PosterizeDialog)); + pd = g_new (PosterizeDialog, 1); pd->preview = TRUE; - pd->levels = 3; - pd->lut = gimp_lut_new(); + pd->levels = 3; + pd->lut = gimp_lut_new (); /* The shell and main vbox */ - pd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (pd->shell), "posterize", "Gimp"); - gtk_window_set_title (GTK_WINDOW (pd->shell), _("Posterize")); + pd->shell = + gimp_dialog_new (_("Posterize"), "posterize", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (pd->shell), "delete_event", - GTK_SIGNAL_FUNC (posterize_delete_callback), - pd); + _("OK"), posterize_ok_callback, + pd, NULL, TRUE, FALSE, + _("Cancel"), posterize_cancel_callback, + pd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pd->shell)->vbox), vbox); /* Horizontal box for levels text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -250,11 +247,6 @@ posterize_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = pd; - action_items[1].user_data = pd; - build_action_area (GTK_DIALOG (pd->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (pd->shell); @@ -304,14 +296,6 @@ posterize_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -posterize_delete_callback (GtkWidget *w, GdkEvent *e, gpointer data) -{ - posterize_cancel_callback (w, data); - - return TRUE; -} - static void posterize_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/preferences_dialog.c b/app/preferences_dialog.c index af84450451..0a61751d03 100644 --- a/app/preferences_dialog.c +++ b/app/preferences_dialog.c @@ -23,6 +23,7 @@ #include "gdisplay_ops.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimpui.h" #include "image_render.h" #include "interface.h" #include "lc_dialog.h" @@ -107,6 +108,7 @@ static int old_max_new_image_size; static int old_thumbnail_mode; static int old_show_indicators; static int old_trust_dirty_flag; +static int old_use_help; /* variables which can't be changed on the fly */ static int edit_stingy_memory_use; @@ -531,7 +533,12 @@ file_prefs_save_callback (GtkWidget *widget, update = g_list_append (update, "trust-dirty-flag"); remove = g_list_append (update, "dont-trust-dirty-flag"); } - + if (use_help != old_use_help) + { + update = g_list_append (update, "use-help"); + remove = g_list_append (remove, "dont-use-help"); + } + save_gimprc (&update, &remove); if (using_xserver_resolution) @@ -597,6 +604,7 @@ file_prefs_cancel_callback (GtkWidget *widget, thumbnail_mode = old_thumbnail_mode; show_indicators = old_show_indicators; trust_dirty_flag = old_trust_dirty_flag; + use_help = old_use_help; if (preview_size != old_preview_size) { @@ -703,6 +711,8 @@ file_prefs_toggle_callback (GtkWidget *widget, val = data; *val = (long) gtk_object_get_user_data (GTK_OBJECT (widget)); } + else if (data == &use_help) + use_help = GTK_TOGGLE_BUTTON (widget)->active; else { /* Are you a gimp-hacker who is getting this message? You @@ -972,360 +982,6 @@ file_prefs_monitor_resolution_callback (GtkWidget *widget, monitor_yres = yres; } -/* ******************************************************************** - * convenience constructors test site ;) - */ - -/* local callbacks of gimp_dialog_new () */ -static int -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; -} - -/* -#include "/home/mitschel/gimpfiles/wilber.xpm" - -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], - wilber_xpm); - - gdk_window_set_icon (widget->window, NULL, - wilber_pixmap, wilber_mask); -} -*/ - -/* this is an experimental one - * I tried to fold the entire dialog creation and the ActionArea stuff - * into one function. Might be not general enough. - */ -GtkWidget* -gimp_dialog_new (const gchar *title, - const gchar *wmclass_name, - GtkWindowPosition position, - gint allow_shrink, - gint allow_grow, - gint auto_shrink, - - /* specify action area buttons as va_list: - * gchar *label, - * GtkSignalFunc callback, - * gpointer data, - * gboolean default_action, - * gboolean connect_delete, - */ - - ...) -{ - GtkWidget *dialog; - GtkWidget *hbbox; - GtkWidget *button; - - /* action area variables */ - gchar *label; - GtkSignalFunc callback; - gpointer data; - gboolean default_action; - gboolean connect_delete; - - va_list args; - gboolean delete_connected = FALSE; - - 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_grow, allow_shrink, auto_shrink); - - /* prepare the action_area */ - gtk_container_set_border_width - (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (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 (GTK_DIALOG (dialog)->action_area), hbbox, - FALSE, FALSE, 0); - gtk_widget_show (hbbox); - - /* the action_area buttons */ - va_start (args, auto_shrink); - label = va_arg (args, gchar*); - while (label) - { - callback = va_arg (args, GtkSignalFunc); - data = 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 (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*); - } - va_end (args); - - /* catch the WM delete event if not already done */ - if (! delete_connected) - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - (GdkEventFunc) gimp_dialog_delete_callback, - NULL); - - /* the realize callback sets the WM icon */ - /* - gtk_signal_connect (GTK_OBJECT (dialog), "realize", - (GtkSignalFunc) gimp_dialog_realize_callback, - NULL); - - */ - return dialog; -} - -GtkWidget* -gimp_option_menu_new (GtkSignalFunc menu_item_callback, - gpointer initial, /* user_data */ - - /* specify menu items as va_list: - * gchar *label, - * gpointer data, - * gpointer user_data, - */ - - ...) -{ - GtkWidget *menu; - GtkWidget *menuitem; - GtkWidget *optionmenu; - - /* menu item variables */ - gchar *label; - gpointer data; - gpointer user_data; - - va_list args; - gint i; - gint initial_index; - - menu = gtk_menu_new (); - - /* create the menu items */ - initial_index = 0; - va_start (args, initial); - label = va_arg (args, gchar*); - for (i = 0; label; i++) - { - data = va_arg (args, gpointer); - user_data = va_arg (args, gpointer); - - menuitem = gtk_menu_item_new_with_label (label); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - menu_item_callback, data); - gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data); - gtk_widget_show (menuitem); - - /* remember the initial menu item */ - if (user_data == initial) - initial_index = i; - - label = va_arg (args, gchar*); - } - va_end (args); - - optionmenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); - - /* select the initial menu item */ - gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index); - - return optionmenu; -} - -GtkWidget* -gimp_radio_group_new (GtkSignalFunc radio_button_callback, - gpointer initial, /* user_data */ - - /* specify radio buttons as va_list: - * gchar *label, - * gpointer data, - * gpointer user_data, - */ - - ...) -{ - GtkWidget *vbox; - GtkWidget *button; - GSList *group; - - /* radio button variables */ - gchar *label; - gpointer data; - gpointer user_data; - - va_list args; - - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - group = NULL; - - /* create the radio buttons */ - va_start (args, initial); - label = va_arg (args, gchar*); - while (label) - { - data = va_arg (args, gpointer); - user_data = va_arg (args, gpointer); - - button = gtk_radio_button_new_with_label (group, label); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) radio_button_callback, - data); - gtk_object_set_user_data (GTK_OBJECT (button), user_data); - - /* press the initially active radio button */ - if (user_data == initial) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - - gtk_widget_show (button); - - label = va_arg (args, gchar*); - } - va_end (args); - - return vbox; -} - -/* this might be the standard gimp spinbutton */ -GtkWidget* -gimp_spin_button_new (GtkObject **adjustment, /* return value */ - gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - gfloat page_size, - gfloat climb_rate, - guint digits) -{ - GtkWidget *spinbutton; - - *adjustment = gtk_adjustment_new (value, lower, upper, - step_increment, page_increment, page_size); - - spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment), - climb_rate, digits); - gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), - GTK_SHADOW_NONE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); - gtk_widget_set_usize (spinbutton, 75, 0); - - return spinbutton; -} - -/* add aligned label & widget to a two-column table */ -void -gimp_table_attach_aligned (GtkTable *table, - gint row, - gchar *text, - gfloat xalign, - gfloat yalign, - GtkWidget *widget, - gboolean left_adjust) -{ - GtkWidget *label; - - label = gtk_label_new (text); - gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); - gtk_table_attach (table, GTK_WIDGET (label), 0, 1, row, row + 1, - GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - gtk_widget_show (label); - - if (left_adjust) - { - GtkWidget *alignment; - - alignment = gtk_alignment_new (0.0, 1.0, 0.0, 0.0); - gtk_table_attach_defaults (table, alignment, 1, 2, row, row + 1); - gtk_widget_show (alignment); - gtk_container_add (GTK_CONTAINER (alignment), widget); - } - else - { - gtk_table_attach_defaults (table, widget, 1, 2, row, row + 1); - } - - gtk_widget_show (widget); -} - - -/********************************************************************** - * preferences-specific GUI helpers - */ - /* create a new notebook page */ static GtkWidget* file_prefs_notebook_append_page (GtkNotebook *notebook, @@ -1492,6 +1148,7 @@ file_pref_cmd_callback (GtkWidget *widget, old_thumbnail_mode = thumbnail_mode; old_show_indicators = show_indicators; old_trust_dirty_flag = trust_dirty_flag; + old_use_help = use_help; file_prefs_strset (&old_temp_path, edit_temp_path); file_prefs_strset (&old_swap_path, edit_swap_path); @@ -1506,20 +1163,24 @@ file_pref_cmd_callback (GtkWidget *widget, /* Create the dialog */ prefs_dlg = gimp_dialog_new (_("Preferences"), "gimp_preferences", - GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, - _("OK"), file_prefs_ok_callback, NULL, - FALSE, FALSE, - _("Save"), file_prefs_save_callback, NULL, - FALSE, FALSE, - _("Cancel"), file_prefs_cancel_callback, NULL, - TRUE, TRUE, + gimp_standard_help_func, + "dialogs/preferences_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, + + _("OK"), file_prefs_ok_callback, + NULL, NULL, FALSE, FALSE, + _("Save"), file_prefs_save_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), file_prefs_cancel_callback, + NULL, NULL, TRUE, TRUE, + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (prefs_dlg)->vbox), - hbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (prefs_dlg)->vbox), hbox); gtk_widget_show (hbox); /* The categories tree */ @@ -1849,7 +1510,7 @@ file_pref_cmd_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); - button = gtk_check_button_new_with_label(_("Show Tool Tips")); + button = gtk_check_button_new_with_label (_("Show Tool Tips")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), show_tool_tips); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); @@ -1858,6 +1519,16 @@ file_pref_cmd_callback (GtkWidget *widget, &show_tool_tips); gtk_widget_show (button); + button = + gtk_check_button_new_with_label (_("Context Sensitive Help with \"F1\"")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + use_help); + gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "toggled", + (GtkSignalFunc) file_prefs_toggle_callback, + &use_help); + gtk_widget_show (button); + /* Interface / Image Windows */ vbox = file_prefs_notebook_append_page (GTK_NOTEBOOK (notebook), _("Image Windows Settings"), diff --git a/app/preferences_dialog.h b/app/preferences_dialog.h index de5b153e12..ed92c84cea 100644 --- a/app/preferences_dialog.h +++ b/app/preferences_dialog.h @@ -20,14 +20,5 @@ #define __PREFERENCES_DIALOG_H__ void file_pref_cmd_callback (GtkWidget *, gpointer); -GtkWidget* gimp_spin_button_new (GtkObject **, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - gfloat, - guint); #endif /* __PREFERENCES_DIALOG_H__ */ diff --git a/app/qmask.c b/app/qmask.c index 29c2706729..5dea7de4c1 100644 --- a/app/qmask.c +++ b/app/qmask.c @@ -24,7 +24,6 @@ #include #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); -g_assert(gdisp->gimage); + 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); + 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; + GimpImage *gimg; + GimpChannel *gmask; -if (gdisp) - { - gimg = gdisp->gimage; - if (!gimg) return; - - if (!gdisp->gimage->qmask_state) { + 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; - - 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 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(); + + /* 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 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); } - 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); - } } 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); + 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, - /* Handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (options->query_box), "delete_event", - GTK_SIGNAL_FUNC (qmask_query_delete_callback), - options); + _("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 +edit_qmask_query_cancel_callback (GtkWidget *widget, + gpointer client_data) { EditQmaskOptions *options; diff --git a/app/resize.c b/app/resize.c index 7a0ef0f835..7e2925d1db 100644 --- a/app/resize.c +++ b/app/resize.c @@ -19,8 +19,8 @@ #include "config.h" #include "appenv.h" #include "resize.h" -#include "actionarea.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpchainbutton.h" #include "libgimp/gimplimits.h" @@ -91,9 +91,6 @@ resize_widget_new (ResizeType type, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, - gint (*delete_cb) (GtkWidget *, - GdkEvent *, - gpointer), gpointer user_data) { Resize *resize; @@ -110,12 +107,6 @@ resize_widget_new (ResizeType type, GtkWidget *alignment; GtkObject *adjustment; - static ActionAreaItem action_items[] = - { - { N_("OK"), NULL, NULL, NULL }, - { N_("Cancel"), NULL, NULL, NULL } - }; - alignment = NULL; frame = NULL; @@ -149,52 +140,62 @@ resize_widget_new (ResizeType type, /* dialog box */ { - const char *wmclass = NULL; - const char *window_title = NULL; + const gchar *wmclass = NULL; + const gchar *window_title = NULL; + gchar *help_page = NULL; - switch (type) { - case ScaleWidget: - switch (target) { - case ResizeLayer: + switch (type) + { + case ScaleWidget: + switch (target) + { + case ResizeLayer: wmclass = "scale_layer"; window_title = _("Scale Layer"); + help_page = "dialogs/scale_layer_dialog.html"; frame = gtk_frame_new (_("Size")); break; - case ResizeImage: + case ResizeImage: wmclass = "image_scale"; window_title = _("Image Scale"); + help_page = "dialogs/scale_image_dialog.html"; frame = gtk_frame_new (_("Pixel Dimensions")); break; - } + } break; - case ResizeWidget: - switch (target) { - case ResizeLayer: + case ResizeWidget: + switch (target) + { + case ResizeLayer: wmclass = "resize_layer"; window_title = _("Resize Layer"); + help_page = "dialogs/resize_layer_dialog.html"; break; - case ResizeImage: + case ResizeImage: wmclass = "image_resize"; window_title = _("Image Resize"); + help_page = "dialogs/resize_image_dialog.html"; break; - } + } frame = gtk_frame_new (_("Size")); break; - } + } - resize->resize_shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (resize->resize_shell), wmclass,"Gimp"); - gtk_window_set_title (GTK_WINDOW (resize->resize_shell), window_title); - gtk_window_set_policy(GTK_WINDOW (resize->resize_shell), FALSE,FALSE,TRUE); - gtk_window_position (GTK_WINDOW (resize->resize_shell), GTK_WIN_POS_MOUSE); + resize->resize_shell = + gimp_dialog_new (window_title, wmclass, + gimp_standard_help_func, help_page, + GTK_WIN_POS_MOUSE, + FALSE, FALSE, TRUE, + + _("OK"), ok_cb, + user_data, NULL, TRUE, FALSE, + _("Cancel"), cancel_cb, + user_data, NULL, FALSE, TRUE, + + NULL); } - /* handle the wm close singal */ - if (delete_cb) - gtk_signal_connect (GTK_OBJECT (resize->resize_shell), "delete_event", - GTK_SIGNAL_FUNC (delete_cb), user_data); - /* handle the image disappearing under our feet */ if (object) { @@ -203,16 +204,9 @@ resize_widget_new (ResizeType type, signame = (target == ResizeLayer) ? "removed" : "destroy"; private->object = object; private->object_destroy_handler = - gtk_signal_connect(GTK_OBJECT (object), signame, cancel_cb, user_data); + gtk_signal_connect (GTK_OBJECT (object), signame, cancel_cb, user_data); } - /* the action area */ - action_items[0].user_data = user_data; - action_items[0].callback = ok_cb; - action_items[1].user_data = user_data; - action_items[1].callback = cancel_cb; - build_action_area (GTK_DIALOG (resize->resize_shell), action_items, 2, 0); - /* the main vbox */ vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); diff --git a/app/resize.h b/app/resize.h index 8163f142ba..7a9dced007 100644 --- a/app/resize.h +++ b/app/resize.h @@ -73,9 +73,6 @@ Resize * resize_widget_new (ResizeType type, gboolean dot_for_dot, GtkSignalFunc ok_cb, GtkSignalFunc cancel_cb, - gint (*delete_cb) (GtkWidget *, - GdkEvent *, - gpointer), gpointer user_data); void resize_widget_free (Resize * resize); diff --git a/app/rotate_tool.c b/app/rotate_tool.c index 37feb3257b..1525f861ad 100644 --- a/app/rotate_tool.c +++ b/app/rotate_tool.c @@ -83,7 +83,8 @@ rotate_tool_transform (Tool *tool, if (!transform_info) { - transform_info = info_dialog_new (_("Rotation Information")); + transform_info = info_dialog_new (_("Rotation Information"), + tools_help_func, NULL); widget = info_dialog_add_spinbutton (transform_info, _("Angle:"), diff --git a/app/scale_tool.c b/app/scale_tool.c index d5630c5bd9..ff64114a04 100644 --- a/app/scale_tool.c +++ b/app/scale_tool.c @@ -71,7 +71,8 @@ scale_tool_transform (Tool *tool, if (!transform_info) { - transform_info = info_dialog_new (_("Scaling Information")); + transform_info = info_dialog_new (_("Scaling Information"), + tools_help_func, NULL); info_dialog_add_label (transform_info, _("Original Width:"), orig_width_buf); diff --git a/app/shear_tool.c b/app/shear_tool.c index 9678e4fea0..9a8c4778f6 100644 --- a/app/shear_tool.c +++ b/app/shear_tool.c @@ -71,7 +71,8 @@ shear_tool_transform (Tool *tool, case INIT : if (!transform_info) { - transform_info = info_dialog_new (_("Shear Information")); + transform_info = info_dialog_new (_("Shear Information"), + tools_help_func, NULL); info_dialog_add_spinbutton (transform_info, _("Shear Magnitude X:"), diff --git a/app/threshold.c b/app/threshold.c index f0fbb393a7..20685a58ba 100644 --- a/app/threshold.c +++ b/app/threshold.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "general.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "threshold.h" @@ -56,8 +56,6 @@ static ThresholdDialog * threshold_new_dialog (void); static void threshold_preview (ThresholdDialog *); static void threshold_ok_callback (GtkWidget *, gpointer); static void threshold_cancel_callback (GtkWidget *, gpointer); -static gint threshold_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void threshold_preview_update (GtkWidget *, gpointer); static void threshold_low_threshold_text_update (GtkWidget *, gpointer); static void threshold_high_threshold_text_update (GtkWidget *, gpointer); @@ -273,31 +271,29 @@ threshold_new_dialog () GtkWidget *frame; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), threshold_ok_callback, NULL, NULL }, - { N_("Cancel"), threshold_cancel_callback, NULL, NULL } - }; - - td = g_malloc (sizeof (ThresholdDialog)); - td->preview = TRUE; - td->low_threshold = 127; + td = g_new (ThresholdDialog, 1); + td->preview = TRUE; + td->low_threshold = 127; td->high_threshold = 255; - td->hist = gimp_histogram_new(); + td->hist = gimp_histogram_new (); /* The shell and main vbox */ - td->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (td->shell), "threshold", "Gimp"); - gtk_window_set_title (GTK_WINDOW (td->shell), _("Threshold")); + td->shell = + gimp_dialog_new (_("Threshold"), "threshold", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (td->shell), "delete_event", - GTK_SIGNAL_FUNC (threshold_delete_callback), - td); + _("OK"), threshold_ok_callback, + td, NULL, TRUE, FALSE, + _("Cancel"), threshold_cancel_callback, + td, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (td->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (td->shell)->vbox), vbox); /* Horizontal box for threshold text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -362,11 +358,6 @@ threshold_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = td; - action_items[1].user_data = td; - build_action_area (GTK_DIALOG (td->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (td->shell); @@ -411,16 +402,6 @@ threshold_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -threshold_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - threshold_cancel_callback (w, client_data); - - return TRUE; -} - static void threshold_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools.c b/app/tools.c index d150017b4a..074d1f0b87 100644 --- a/app/tools.c +++ b/app/tools.c @@ -17,7 +17,6 @@ */ #include #include "appenv.h" -#include "actionarea.h" #include "airbrush.h" #include "bezier_select.h" #include "blend.h" @@ -35,6 +34,7 @@ #include "dodgeburn.h" #include "eraser.h" #include "gdisplay.h" +#include "gimpui.h" #include "hue_saturation.h" #include "ellipse_select.h" #include "flip_tool.h" @@ -87,7 +87,7 @@ ToolInfo tool_info[] = "R", (char **) rect_bits, N_("Select rectangular regions"), - "ContextHelp/rect-select", + "rect_select", RECT_SELECT, tools_new_rect_select, tools_free_rect_select, @@ -102,7 +102,7 @@ ToolInfo tool_info[] = "E", (char **) circ_bits, N_("Select elliptical regions"), - "ContextHelp/ellipse-select", + "ellipse_select", ELLIPSE_SELECT, tools_new_ellipse_select, tools_free_ellipse_select, @@ -117,7 +117,7 @@ ToolInfo tool_info[] = "F", (char **) free_bits, N_("Select hand-drawn regions"), - "ContextHelp/free-select", + "free_select", FREE_SELECT, tools_new_free_select, tools_free_free_select, @@ -132,7 +132,7 @@ ToolInfo tool_info[] = "Z", (char **) fuzzy_bits, N_("Select contiguous regions"), - "ContextHelp/fuzzy-select", + "fuzzy_select", FUZZY_SELECT, tools_new_fuzzy_select, tools_free_fuzzy_select, @@ -147,7 +147,7 @@ ToolInfo tool_info[] = "B", (char **) bezier_bits, N_("Select regions using Bezier curves"), - "ContextHelp/bezier-select", + "bezier_select", BEZIER_SELECT, tools_new_bezier_select, tools_free_bezier_select, @@ -162,7 +162,7 @@ ToolInfo tool_info[] = "I", (char **) iscissors_bits, N_("Select shapes from image"), - "ContextHelp/iscissors", + "intelligent_scissors", ISCISSORS, tools_new_iscissors, tools_free_iscissors, @@ -177,7 +177,7 @@ ToolInfo tool_info[] = "M", (char **) move_bits, N_("Move layers & selections"), - "ContextHelp/move", + "move", MOVE, tools_new_move_tool, tools_free_move_tool, @@ -192,7 +192,7 @@ ToolInfo tool_info[] = "M", (char **) magnify_bits, N_("Zoom in & out"), - "ContextHelp/magnify", + "magnify", MAGNIFY, tools_new_magnify, tools_free_magnify, @@ -207,7 +207,7 @@ ToolInfo tool_info[] = "C", (char **) crop_bits, N_("Crop or resize the image"), - "ContextHelp/crop", + "crop", CROP, tools_new_crop, tools_free_crop, @@ -222,7 +222,7 @@ ToolInfo tool_info[] = "T", (char **) scale_bits, N_("Transform the layer or selection"), - "ContextHelp/rotate", + "transform", ROTATE, tools_new_transform_tool, tools_free_transform_tool, @@ -237,7 +237,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "transform", SCALE, tools_new_transform_tool, tools_free_transform_tool, @@ -252,7 +252,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "transform", SHEAR, tools_new_transform_tool, tools_free_transform_tool, @@ -267,7 +267,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "transform", PERSPECTIVE, tools_new_transform_tool, tools_free_transform_tool, @@ -282,7 +282,7 @@ ToolInfo tool_info[] = "F", (char **) flip_bits, N_("Flip the layer or selection"), - "ContextHelp/flip", + "flip", FLIP, tools_new_flip, tools_free_flip_tool, @@ -297,7 +297,7 @@ ToolInfo tool_info[] = "T", (char **) text_bits, N_("Add text to the image"), - "ContextHelp/text", + "text", TEXT, tools_new_text, tools_free_text, @@ -312,7 +312,7 @@ ToolInfo tool_info[] = "O", (char **) colorpicker_bits, N_("Pick colors from the image"), - "ContextHelp/color-picker", + "color_picker", COLOR_PICKER, tools_new_color_picker, tools_free_color_picker, @@ -327,7 +327,7 @@ ToolInfo tool_info[] = "B", (char **) fill_bits, N_("Fill with a color or pattern"), - "ContextHelp/bucket-fill", + "bucket_fill", BUCKET_FILL, tools_new_bucket_fill, tools_free_bucket_fill, @@ -342,7 +342,7 @@ ToolInfo tool_info[] = "L", (char **) gradient_bits, N_("Fill with a color gradient"), - "ContextHelp/gradient", + "blend", BLEND, tools_new_blend, tools_free_blend, @@ -357,7 +357,7 @@ ToolInfo tool_info[] = "P", (char **) pencil_bits, N_("Draw sharp pencil strokes"), - "ContextHelp/pencil", + "pencil", PENCIL, tools_new_pencil, tools_free_pencil, @@ -372,7 +372,7 @@ ToolInfo tool_info[] = "P", (char **) paint_bits, N_("Paint fuzzy brush strokes"), - "ContextHelp/paintbrush", + "paintbrush", PAINTBRUSH, tools_new_paintbrush, tools_free_paintbrush, @@ -387,7 +387,7 @@ ToolInfo tool_info[] = "E", (char **) erase_bits, N_("Erase to background or transparency"), - "ContextHelp/eraser", + "eraser", ERASER, tools_new_eraser, tools_free_eraser, @@ -402,7 +402,7 @@ ToolInfo tool_info[] = "A", (char **) airbrush_bits, N_("Airbrush with variable pressure"), - "ContextHelp/airbrush", + "airbrush", AIRBRUSH, tools_new_airbrush, tools_free_airbrush, @@ -417,7 +417,7 @@ ToolInfo tool_info[] = "C", (char **) clone_bits, N_("Paint using patterns or image regions"), - "ContextHelp/clone", + "clone", CLONE, tools_new_clone, tools_free_clone, @@ -432,7 +432,7 @@ ToolInfo tool_info[] = "V", (char **) blur_bits, N_("Blur or sharpen"), - "ContextHelp/convolve", + "convolve", CONVOLVE, tools_new_convolve, tools_free_convolve, @@ -447,7 +447,7 @@ ToolInfo tool_info[] = "K", (char **) ink_bits, N_("Draw in ink"), - "ContextHelp/ink", + "ink", INK, tools_new_ink, tools_free_ink, @@ -462,7 +462,7 @@ ToolInfo tool_info[] = "D", (char **) dodge_bits, N_("Dodge or Burn"), - "ContextHelp/dodgeburn", + "dodgeburn", DODGEBURN, tools_new_dodgeburn, tools_free_dodgeburn, @@ -477,7 +477,7 @@ ToolInfo tool_info[] = "S", (char **) smudge_bits, N_("Smudge"), - "ContextHelp/smudge", + "smudge", SMUDGE, tools_new_smudge, tools_free_smudge, @@ -492,7 +492,7 @@ ToolInfo tool_info[] = "", (char **) measure_bits, N_("Measure distances and angles"), - "ContextHelp/measure", + "measure", MEASURE, tools_new_measure_tool, tools_free_measure_tool, @@ -507,7 +507,7 @@ ToolInfo tool_info[] = "A", (char **) xinput_airbrush_bits, N_("Natural Airbrush"), - "ContextHelp/xinput_airbrush", + "xinput_airbrush", XINPUT_AIRBRUSH, tools_new_xinput_airbrush, tools_free_xinput_airbrush, @@ -522,7 +522,7 @@ ToolInfo tool_info[] = "", (char **) path_tool_bits, N_("Manipulate paths"), - "ContextHelp/path", + "path", PATH_TOOL, tools_new_path_tool, tools_free_path_tool, @@ -539,7 +539,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "by_color_select", BY_COLOR_SELECT, tools_new_by_color_select, tools_free_by_color_select, @@ -554,7 +554,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "color_balance", COLOR_BALANCE, tools_new_color_balance, tools_free_color_balance, @@ -569,7 +569,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "brightness_contrast", BRIGHTNESS_CONTRAST, tools_new_brightness_contrast, tools_free_brightness_contrast, @@ -584,7 +584,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "hue_saturation", HUE_SATURATION, tools_new_hue_saturation, tools_free_hue_saturation, @@ -599,7 +599,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "posterize", POSTERIZE, tools_new_posterize, tools_free_posterize, @@ -614,7 +614,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "threshold", THRESHOLD, tools_new_threshold, tools_free_threshold, @@ -629,7 +629,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "curves", CURVES, tools_new_curves, tools_free_curves, @@ -644,7 +644,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "levels", LEVELS, tools_new_levels, tools_free_levels, @@ -659,7 +659,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "histogram", HISTOGRAM, tools_new_histogram_tool, tools_free_histogram_tool, @@ -671,11 +671,10 @@ gint num_tools = sizeof (tool_info) / sizeof (tool_info[0]); /* Local function declarations */ -static void tools_options_show (ToolType); -static void tools_options_hide (ToolType); -static void tools_options_reset_callback (GtkWidget *, gpointer); -static void tools_options_close_callback (GtkWidget *, gpointer); -static gint tools_options_delete_callback (GtkWidget *, GdkEvent *, gpointer); +static void tools_options_show (ToolType); +static void tools_options_hide (ToolType); +static void tools_options_reset_callback (GtkWidget *, gpointer); +static void tools_options_close_callback (GtkWidget *, gpointer); /* Function definitions */ @@ -695,15 +694,15 @@ active_tool_free (void) } void -tools_select (ToolType type) +tools_select (ToolType tool_type) { /* Care for switching to the tool's private context */ - context_manager_set_tool (type); + context_manager_set_tool (tool_type); if (active_tool) active_tool_free (); - active_tool = (* tool_info[(int) type].new_func) (); + active_tool = (* tool_info[(int) tool_type].new_func) (); tools_options_show (active_tool->type); @@ -712,30 +711,30 @@ tools_select (ToolType type) } void -tools_initialize (ToolType type, +tools_initialize (ToolType tool_type, GDisplay *gdisp) { /* Tools which have an init function have dialogs and * cannot be initialized without a display */ - if (tool_info[(int) type].init_func && !gdisp) - type = RECT_SELECT; + if (tool_info[(int) tool_type].init_func && !gdisp) + tool_type = RECT_SELECT; /* Activate the appropriate widget. * Implicitly calls tools_select() */ - if (active_tool->type == type) + if (active_tool->type == tool_type) { - tools_select (type); + tools_select (tool_type); } else { - gtk_widget_activate (tool_info[type].tool_widget); + gtk_widget_activate (tool_info[tool_type].tool_widget); } - if (tool_info[(int) type].init_func) + if (tool_info[(int) tool_type].init_func) { - (* tool_info[(int) type].init_func) (gdisp); + (* tool_info[(int) tool_type].init_func) (gdisp); active_tool->drawable = gimage_active_drawable (gdisp->gimage); } @@ -878,13 +877,13 @@ standard_control_func (Tool *tool, */ Tool * -tools_new_tool (ToolType type) +tools_new_tool (ToolType tool_type) { Tool *tool; tool = g_new (Tool, 1); - tool->type = type; + tool->type = tool_type; tool->ID = global_tool_ID++; tool->state = INACTIVE; @@ -917,21 +916,22 @@ tools_options_dialog_new () GtkWidget *frame; GtkWidget *vbox; - ActionAreaItem action_items[] = - { - { N_("Reset"), tools_options_reset_callback, NULL, NULL }, - { N_("Close"), tools_options_close_callback, NULL, NULL } - }; - /* The shell and main vbox */ - options_shell = gtk_dialog_new (); + options_shell = + gimp_dialog_new (_("Tool Options"), "tool_options", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, TRUE, + + _("Reset"), tools_options_reset_callback, + NULL, &options_reset_button, FALSE, FALSE, + _("Close"), tools_options_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* Register dialog */ dialog_register (options_shell); - - gtk_window_set_wmclass (GTK_WINDOW (options_shell), "tool_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options_shell), _("Tool Options")); - gtk_window_set_policy (GTK_WINDOW (options_shell), FALSE, TRUE, TRUE); session_set_window_geometry (options_shell, &tool_options_session_info, FALSE ); @@ -961,17 +961,6 @@ tools_options_dialog_new () gtk_container_set_border_width (GTK_CONTAINER (options_vbox), 2); gtk_box_pack_start (GTK_BOX (vbox), options_vbox, FALSE, FALSE, 0); - /* handle the window manager trying to close the window */ - gtk_signal_connect (GTK_OBJECT (options_shell), "delete_event", - GTK_SIGNAL_FUNC (tools_options_delete_callback), - options_shell); - - action_items[0].user_data = options_shell; - action_items[1].user_data = options_shell; - build_action_area (GTK_DIALOG (options_shell), action_items, 2, 1); - - options_reset_button = action_items[0].widget; - gtk_widget_show (options_vbox); /* hide the separator between the dialog's vbox and the action area */ @@ -985,6 +974,18 @@ tools_options_dialog_free () gtk_widget_destroy (options_shell); } +void +tools_help_func (gpointer help_data) +{ + gchar *help_page; + + help_page = g_strdup_printf ("tools/%s.html", + tool_info[(int) active_tool->type].private_tip); + gimp_help (help_page); + + g_free (help_page); +} + void tools_register (ToolType tool_type, ToolOptions *tool_options) @@ -1007,57 +1008,47 @@ tools_register (ToolType tool_type, } static void -tools_options_show (ToolType tooltype) +tools_options_show (ToolType tool_type) { - if (tool_info[tooltype].tool_options->main_vbox) - gtk_widget_show (tool_info[tooltype].tool_options->main_vbox); + if (tool_info[tool_type].tool_options->main_vbox) + gtk_widget_show (tool_info[tool_type].tool_options->main_vbox); - if (tool_info[tooltype].tool_options->title) + if (tool_info[tool_type].tool_options->title) gtk_label_set_text (GTK_LABEL (options_label), - _(tool_info[tooltype].tool_options->title)); + _(tool_info[tool_type].tool_options->title)); - if (tool_info[tooltype].tool_options->reset_func) + if (tool_info[tool_type].tool_options->reset_func) gtk_widget_set_sensitive (options_reset_button, TRUE); else gtk_widget_set_sensitive (options_reset_button, FALSE); } static void -tools_options_hide (ToolType tooltype) +tools_options_hide (ToolType tool_type) { - if (tool_info[tooltype].tool_options) - gtk_widget_hide (tool_info[tooltype].tool_options->main_vbox); + if (tool_info[tool_type].tool_options) + gtk_widget_hide (tool_info[tool_type].tool_options->main_vbox); } /* Tool options callbacks */ -static gint -tools_options_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - tools_options_close_callback (w, client_data); - - return TRUE; -} - static void -tools_options_close_callback (GtkWidget *w, - gpointer client_data) +tools_options_close_callback (GtkWidget *widget, + gpointer data) { GtkWidget *shell; - shell = (GtkWidget *) client_data; + shell = (GtkWidget *) data; gtk_widget_hide (shell); } static void -tools_options_reset_callback (GtkWidget *w, - gpointer client_data) +tools_options_reset_callback (GtkWidget *widget, + gpointer data) { GtkWidget *shell; - shell = (GtkWidget *) client_data; + shell = (GtkWidget *) data; if (! active_tool) return; diff --git a/app/tools.h b/app/tools.h index 3f5ec19831..b0fb46959e 100644 --- a/app/tools.h +++ b/app/tools.h @@ -111,6 +111,8 @@ void tools_options_dialog_new (void); void tools_options_dialog_show (void); void tools_options_dialog_free (void); +void tools_help_func (gpointer); + void tools_register (ToolType tool_type, ToolOptions *tool_options); diff --git a/app/tools/brightness_contrast.c b/app/tools/brightness_contrast.c index 0c7557477c..8bfde39e55 100644 --- a/app/tools/brightness_contrast.c +++ b/app/tools/brightness_contrast.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "brightness_contrast.h" #include "drawable.h" #include "gimage_mask.h" +#include "gimpui.h" #include "gdisplay.h" #include "image_map.h" #include "interface.h" @@ -89,7 +89,6 @@ static void brightness_contrast_update (BrightnessContrastDia static void brightness_contrast_preview (BrightnessContrastDialog *); static void brightness_contrast_ok_callback (GtkWidget *, gpointer); static void brightness_contrast_cancel_callback (GtkWidget *, gpointer); -static gint brightness_contrast_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void brightness_contrast_preview_update (GtkWidget *, gpointer); static void brightness_contrast_brightness_scale_update (GtkAdjustment *, gpointer); static void brightness_contrast_contrast_scale_update (GtkAdjustment *, gpointer); @@ -208,26 +207,24 @@ brightness_contrast_new_dialog () GtkWidget *toggle; GtkObject *data; - static ActionAreaItem action_items[] = - { - { N_("OK"), brightness_contrast_ok_callback, NULL, NULL }, - { N_("Cancel"), brightness_contrast_cancel_callback, NULL, NULL } - }; - bcd = g_new (BrightnessContrastDialog, 1); bcd->preview = TRUE; bcd->lut = gimp_lut_new (); /* The shell and main vbox */ - bcd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bcd->shell), "brightness_contrast", "Gimp"); - gtk_window_set_title (GTK_WINDOW (bcd->shell), _("Brightness-Contrast")); + bcd->shell = + gimp_dialog_new (_("Brightness-Contrast"), "brightness_contrast", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle wm close signal */ - gtk_signal_connect (GTK_OBJECT (bcd->shell), "delete_event", - GTK_SIGNAL_FUNC (brightness_contrast_delete_callback), - bcd); + _("OK"), brightness_contrast_ok_callback, + bcd, NULL, TRUE, FALSE, + _("Cancel"), brightness_contrast_cancel_callback, + bcd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -320,12 +317,6 @@ brightness_contrast_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = bcd; - action_items[1].user_data = bcd; - build_action_area (GTK_DIALOG (bcd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (bcd->shell); @@ -412,16 +403,6 @@ brightness_contrast_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -brightness_contrast_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - brightness_contrast_cancel_callback (widget, data); - - return TRUE; -} - static void brightness_contrast_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/tools/by_color_select.c b/app/tools/by_color_select.c index cbec398598..deb874f008 100644 --- a/app/tools/by_color_select.c +++ b/app/tools/by_color_select.c @@ -28,6 +28,7 @@ #include "gimage_mask.h" #include "gimprc.h" #include "gimpset.h" +#include "gimpui.h" #include "gdisplay.h" #include "selection_options.h" @@ -87,8 +88,6 @@ static gint by_color_select_preview_events (GtkWidget *, GdkEventButton *, static void by_color_select_type_callback (GtkWidget *, gpointer); static void by_color_select_reset_callback (GtkWidget *, gpointer); static void by_color_select_close_callback (GtkWidget *, gpointer); -static gint by_color_select_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void by_color_select_fuzzy_update (GtkAdjustment *, gpointer); static void by_color_select_preview_button_press (ByColorDialog *, GdkEventButton *); @@ -529,15 +528,14 @@ by_color_select_new_dialog () GtkWidget *options_box; GtkWidget *label; GtkWidget *util_box; - GtkWidget *push_button; GtkWidget *slider; GtkWidget *radio_box; GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - char *button_names[] = + gchar *button_names[] = { N_("Replace"), N_("Add"), @@ -545,7 +543,7 @@ by_color_select_new_dialog () N_("Intersect") }; - int button_values[] = + gint button_values[] = { REPLACE, ADD, @@ -553,28 +551,30 @@ by_color_select_new_dialog () INTERSECT }; - bcd = g_malloc (sizeof (ByColorDialog)); - bcd->gimage = NULL; + bcd = g_new (ByColorDialog, 1); + bcd->gimage = NULL; bcd->operation = REPLACE; bcd->threshold = DEFAULT_FUZZINESS; /* The shell and main vbox */ - bcd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bcd->shell), "by_color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (bcd->shell), _("By Color Selection")); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->action_area), 2); + bcd->shell = gimp_dialog_new (_("By Color Selection"), "by_color_selection", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (bcd->shell), "delete_event", - (GtkSignalFunc) by_color_select_delete_callback, - bcd); + _("Reset"), by_color_select_reset_callback, + bcd, NULL, FALSE, FALSE, + _("Close"), by_color_select_close_callback, + bcd, NULL, TRUE, TRUE, - /* The vbox */ + NULL); + + /* The vbox */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->vbox), vbox); - /* The horizontal box containing preview & options box */ + /* The horizontal box containing preview & options box */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -650,25 +650,6 @@ by_color_select_new_dialog () gtk_widget_show (slider); gtk_widget_show (util_box); - /* The reset push button */ - push_button = gtk_button_new_with_label (_("Reset")); - GTK_WIDGET_SET_FLAGS (push_button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->action_area), push_button, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (push_button), "clicked", - (GtkSignalFunc) by_color_select_reset_callback, - bcd); - gtk_widget_grab_default (push_button); - gtk_widget_show (push_button); - - /* The close push button */ - push_button = gtk_button_new_with_label (_("Close")); - GTK_WIDGET_SET_FLAGS (push_button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->action_area), push_button, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (push_button), "clicked", - (GtkSignalFunc) by_color_select_close_callback, - bcd); - gtk_widget_show (push_button); - gtk_widget_show (options_box); gtk_widget_show (hbox); gtk_widget_show (vbox); @@ -852,16 +833,6 @@ by_color_select_reset_callback (GtkWidget *widget, by_color_select_draw (bcd, bcd->gimage); } -static gint -by_color_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - by_color_select_close_callback (w, client_data); - - return TRUE; -} - static void by_color_select_close_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/color_balance.c b/app/tools/color_balance.c index 6e66f75f05..02db705ef2 100644 --- a/app/tools/color_balance.c +++ b/app/tools/color_balance.c @@ -28,6 +28,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" @@ -69,8 +70,6 @@ static void color_balance_update (ColorBalanceDialog *, int); static void color_balance_preview (ColorBalanceDialog *); static void color_balance_ok_callback (GtkWidget *, gpointer); static void color_balance_cancel_callback (GtkWidget *, gpointer); -static gint color_balance_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void color_balance_shadows_callback (GtkWidget *, gpointer); static void color_balance_midtones_callback (GtkWidget *, gpointer); static void color_balance_highlights_callback (GtkWidget *, gpointer); @@ -253,7 +252,6 @@ color_balance_initialize (GDisplay *gdisp) /* Color Balance dialog */ /**************************/ -/* the action area structure */ static ColorBalanceDialog * color_balance_new_dialog () { @@ -269,15 +267,9 @@ color_balance_new_dialog () GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_balance_ok_callback, NULL, NULL }, - { N_("Cancel"), color_balance_cancel_callback, NULL, NULL } - }; - - char *appl_mode_names[] = + gchar *appl_mode_names[] = { N_("Shadows"), N_("Midtones"), @@ -297,18 +289,21 @@ color_balance_new_dialog () cbd->application_mode = SHADOWS; /* The shell and main vbox */ - cbd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cbd->shell), "color_balance", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cbd->shell), _("Color Balance")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cbd->shell), "delete_event", - GTK_SIGNAL_FUNC (color_balance_delete_callback), - cbd); + cbd->shell = gimp_dialog_new (_("Color Balance"), "color_balance", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), color_balance_ok_callback, + cbd, NULL, TRUE, FALSE, + _("Cancel"), color_balance_cancel_callback, + cbd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cbd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cbd->shell)->vbox), vbox); /* Horizontal box for application mode */ hbox = gtk_hbox_new (TRUE, 2); @@ -473,11 +468,6 @@ color_balance_new_dialog () } gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cbd; - action_items[1].user_data = cbd; - build_action_area (GTK_DIALOG (cbd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (cbd->shell); @@ -614,16 +604,6 @@ color_balance_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -color_balance_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_balance_cancel_callback (w, client_data); - - return TRUE; -} - static void color_balance_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/color_picker.c b/app/tools/color_picker.c index c38ac4be79..612edf0e06 100644 --- a/app/tools/color_picker.c +++ b/app/tools/color_picker.c @@ -22,6 +22,7 @@ #include "draw_core.h" #include "drawable.h" #include "gdisplay.h" +#include "gimphelp.h" #include "cursorutil.h" #include "info_dialog.h" #include "palette.h" @@ -248,7 +249,8 @@ color_picker_button_press (Tool *tool, { GtkWidget *hbox; - color_picker_info = info_dialog_new (_("Color Picker")); + color_picker_info = info_dialog_new (_("Color Picker"), + tools_help_func, NULL); /* if the gdisplay is for a color image, the dialog must have RGB */ switch (drawable_type (tool->drawable)) diff --git a/app/tools/crop.c b/app/tools/crop.c index f461d376e4..ef02ec6c87 100644 --- a/app/tools/crop.c +++ b/app/tools/crop.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include #include "gdk/gdkkeysyms.h" @@ -28,6 +27,7 @@ #include "floating_sel.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimphelp.h" #include "info_dialog.h" #include "tool_options_ui.h" #include "undo.h" @@ -1030,7 +1030,8 @@ crop_info_create (Tool *tool) gdisp = (GDisplay *) tool->gdisp_ptr; /* create the info dialog */ - crop_info = info_dialog_new (_("Crop & Resize Information")); + crop_info = info_dialog_new (_("Crop & Resize Information"), + tools_help_func, NULL); /* add the information fields */ spinbutton = info_dialog_add_spinbutton (crop_info, _("Origin X:"), NULL, diff --git a/app/tools/curves.c b/app/tools/curves.c index b80a204d07..60b11f4044 100644 --- a/app/tools/curves.c +++ b/app/tools/curves.c @@ -21,7 +21,6 @@ #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "cursorutil.h" @@ -29,6 +28,7 @@ #include "general.h" #include "gdisplay.h" #include "gimphistogram.h" +#include "gimpui.h" #include "interface.h" #include "curves.h" #include "gimplut.h" @@ -114,7 +114,6 @@ static void curves_free_callback (GtkWidget *, gpointer); static void curves_reset_callback (GtkWidget *, gpointer); static void curves_ok_callback (GtkWidget *, gpointer); static void curves_cancel_callback (GtkWidget *, gpointer); -static gint curves_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void curves_preview_update (GtkWidget *, gpointer); static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); @@ -519,14 +518,7 @@ curves_new_dialog () GtkWidget *channel_hbox; GtkWidget *menu; GtkWidget *table; - int i, j; - - static ActionAreaItem action_items[] = - { - { N_("Reset"), curves_reset_callback, NULL, NULL }, - { N_("OK"), curves_ok_callback, NULL, NULL }, - { N_("Cancel"), curves_cancel_callback, NULL, NULL } - }; + gint i, j; static MenuItem curve_type_items[] = { @@ -535,7 +527,7 @@ curves_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - cd = g_malloc (sizeof (CurvesDialog)); + cd = g_new (CurvesDialog, 1); cd->cursor_ind_height = cd->cursor_ind_width = -1; cd->preview = TRUE; cd->curve_type = SMOOTH; @@ -556,17 +548,23 @@ curves_new_dialog () curve_type_items [i].user_data = (gpointer) cd; /* The shell and main vbox */ - cd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cd->shell), "curves", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cd->shell), _("Curves")); + cd->shell = gimp_dialog_new (_("Curves"), "curves", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Reset"), curves_reset_callback, + cd, NULL, FALSE, FALSE, + _("OK"), curves_ok_callback, + cd, NULL, TRUE, FALSE, + _("Cancel"), curves_cancel_callback, + cd, NULL, FALSE, TRUE, + + NULL); - gtk_signal_connect (GTK_OBJECT (cd->shell), "delete_event", - GTK_SIGNAL_FUNC (curves_delete_callback), - cd); - vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cd->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -670,12 +668,6 @@ curves_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cd; - action_items[1].user_data = cd; - action_items[2].user_data = cd; - build_action_area (GTK_DIALOG (cd->shell), action_items, 3, 0); - gtk_widget_show (vbox); return cd; @@ -1278,24 +1270,15 @@ curves_cancel_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -curves_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - curves_cancel_callback (w, data); - - return TRUE; -} static void -curves_preview_update (GtkWidget *w, +curves_preview_update (GtkWidget *widget, gpointer data) { CurvesDialog *cd; cd = (CurvesDialog *) data; - if (GTK_TOGGLE_BUTTON (w)->active) + if (GTK_TOGGLE_BUTTON (widget)->active) { cd->preview = TRUE; curves_preview (cd); diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index 0c7557477c..8bfde39e55 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "brightness_contrast.h" #include "drawable.h" #include "gimage_mask.h" +#include "gimpui.h" #include "gdisplay.h" #include "image_map.h" #include "interface.h" @@ -89,7 +89,6 @@ static void brightness_contrast_update (BrightnessContrastDia static void brightness_contrast_preview (BrightnessContrastDialog *); static void brightness_contrast_ok_callback (GtkWidget *, gpointer); static void brightness_contrast_cancel_callback (GtkWidget *, gpointer); -static gint brightness_contrast_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void brightness_contrast_preview_update (GtkWidget *, gpointer); static void brightness_contrast_brightness_scale_update (GtkAdjustment *, gpointer); static void brightness_contrast_contrast_scale_update (GtkAdjustment *, gpointer); @@ -208,26 +207,24 @@ brightness_contrast_new_dialog () GtkWidget *toggle; GtkObject *data; - static ActionAreaItem action_items[] = - { - { N_("OK"), brightness_contrast_ok_callback, NULL, NULL }, - { N_("Cancel"), brightness_contrast_cancel_callback, NULL, NULL } - }; - bcd = g_new (BrightnessContrastDialog, 1); bcd->preview = TRUE; bcd->lut = gimp_lut_new (); /* The shell and main vbox */ - bcd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bcd->shell), "brightness_contrast", "Gimp"); - gtk_window_set_title (GTK_WINDOW (bcd->shell), _("Brightness-Contrast")); + bcd->shell = + gimp_dialog_new (_("Brightness-Contrast"), "brightness_contrast", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle wm close signal */ - gtk_signal_connect (GTK_OBJECT (bcd->shell), "delete_event", - GTK_SIGNAL_FUNC (brightness_contrast_delete_callback), - bcd); + _("OK"), brightness_contrast_ok_callback, + bcd, NULL, TRUE, FALSE, + _("Cancel"), brightness_contrast_cancel_callback, + bcd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -320,12 +317,6 @@ brightness_contrast_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = bcd; - action_items[1].user_data = bcd; - build_action_area (GTK_DIALOG (bcd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (bcd->shell); @@ -412,16 +403,6 @@ brightness_contrast_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -brightness_contrast_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - brightness_contrast_cancel_callback (widget, data); - - return TRUE; -} - static void brightness_contrast_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index cbec398598..deb874f008 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -28,6 +28,7 @@ #include "gimage_mask.h" #include "gimprc.h" #include "gimpset.h" +#include "gimpui.h" #include "gdisplay.h" #include "selection_options.h" @@ -87,8 +88,6 @@ static gint by_color_select_preview_events (GtkWidget *, GdkEventButton *, static void by_color_select_type_callback (GtkWidget *, gpointer); static void by_color_select_reset_callback (GtkWidget *, gpointer); static void by_color_select_close_callback (GtkWidget *, gpointer); -static gint by_color_select_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void by_color_select_fuzzy_update (GtkAdjustment *, gpointer); static void by_color_select_preview_button_press (ByColorDialog *, GdkEventButton *); @@ -529,15 +528,14 @@ by_color_select_new_dialog () GtkWidget *options_box; GtkWidget *label; GtkWidget *util_box; - GtkWidget *push_button; GtkWidget *slider; GtkWidget *radio_box; GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - char *button_names[] = + gchar *button_names[] = { N_("Replace"), N_("Add"), @@ -545,7 +543,7 @@ by_color_select_new_dialog () N_("Intersect") }; - int button_values[] = + gint button_values[] = { REPLACE, ADD, @@ -553,28 +551,30 @@ by_color_select_new_dialog () INTERSECT }; - bcd = g_malloc (sizeof (ByColorDialog)); - bcd->gimage = NULL; + bcd = g_new (ByColorDialog, 1); + bcd->gimage = NULL; bcd->operation = REPLACE; bcd->threshold = DEFAULT_FUZZINESS; /* The shell and main vbox */ - bcd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (bcd->shell), "by_color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (bcd->shell), _("By Color Selection")); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->action_area), 2); + bcd->shell = gimp_dialog_new (_("By Color Selection"), "by_color_selection", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (bcd->shell), "delete_event", - (GtkSignalFunc) by_color_select_delete_callback, - bcd); + _("Reset"), by_color_select_reset_callback, + bcd, NULL, FALSE, FALSE, + _("Close"), by_color_select_close_callback, + bcd, NULL, TRUE, TRUE, - /* The vbox */ + NULL); + + /* The vbox */ vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bcd->shell)->vbox), vbox); - /* The horizontal box containing preview & options box */ + /* The horizontal box containing preview & options box */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -650,25 +650,6 @@ by_color_select_new_dialog () gtk_widget_show (slider); gtk_widget_show (util_box); - /* The reset push button */ - push_button = gtk_button_new_with_label (_("Reset")); - GTK_WIDGET_SET_FLAGS (push_button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->action_area), push_button, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (push_button), "clicked", - (GtkSignalFunc) by_color_select_reset_callback, - bcd); - gtk_widget_grab_default (push_button); - gtk_widget_show (push_button); - - /* The close push button */ - push_button = gtk_button_new_with_label (_("Close")); - GTK_WIDGET_SET_FLAGS (push_button, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bcd->shell)->action_area), push_button, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT (push_button), "clicked", - (GtkSignalFunc) by_color_select_close_callback, - bcd); - gtk_widget_show (push_button); - gtk_widget_show (options_box); gtk_widget_show (hbox); gtk_widget_show (vbox); @@ -852,16 +833,6 @@ by_color_select_reset_callback (GtkWidget *widget, by_color_select_draw (bcd, bcd->gimage); } -static gint -by_color_select_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - by_color_select_close_callback (w, client_data); - - return TRUE; -} - static void by_color_select_close_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index 6e66f75f05..02db705ef2 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -28,6 +28,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" @@ -69,8 +70,6 @@ static void color_balance_update (ColorBalanceDialog *, int); static void color_balance_preview (ColorBalanceDialog *); static void color_balance_ok_callback (GtkWidget *, gpointer); static void color_balance_cancel_callback (GtkWidget *, gpointer); -static gint color_balance_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void color_balance_shadows_callback (GtkWidget *, gpointer); static void color_balance_midtones_callback (GtkWidget *, gpointer); static void color_balance_highlights_callback (GtkWidget *, gpointer); @@ -253,7 +252,6 @@ color_balance_initialize (GDisplay *gdisp) /* Color Balance dialog */ /**************************/ -/* the action area structure */ static ColorBalanceDialog * color_balance_new_dialog () { @@ -269,15 +267,9 @@ color_balance_new_dialog () GtkWidget *radio_button; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_balance_ok_callback, NULL, NULL }, - { N_("Cancel"), color_balance_cancel_callback, NULL, NULL } - }; - - char *appl_mode_names[] = + gchar *appl_mode_names[] = { N_("Shadows"), N_("Midtones"), @@ -297,18 +289,21 @@ color_balance_new_dialog () cbd->application_mode = SHADOWS; /* The shell and main vbox */ - cbd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cbd->shell), "color_balance", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cbd->shell), _("Color Balance")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cbd->shell), "delete_event", - GTK_SIGNAL_FUNC (color_balance_delete_callback), - cbd); + cbd->shell = gimp_dialog_new (_("Color Balance"), "color_balance", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), color_balance_ok_callback, + cbd, NULL, TRUE, FALSE, + _("Cancel"), color_balance_cancel_callback, + cbd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cbd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cbd->shell)->vbox), vbox); /* Horizontal box for application mode */ hbox = gtk_hbox_new (TRUE, 2); @@ -473,11 +468,6 @@ color_balance_new_dialog () } gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cbd; - action_items[1].user_data = cbd; - build_action_area (GTK_DIALOG (cbd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (cbd->shell); @@ -614,16 +604,6 @@ color_balance_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -color_balance_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_balance_cancel_callback (w, client_data); - - return TRUE; -} - static void color_balance_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index f461d376e4..ef02ec6c87 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include #include "gdk/gdkkeysyms.h" @@ -28,6 +27,7 @@ #include "floating_sel.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimphelp.h" #include "info_dialog.h" #include "tool_options_ui.h" #include "undo.h" @@ -1030,7 +1030,8 @@ crop_info_create (Tool *tool) gdisp = (GDisplay *) tool->gdisp_ptr; /* create the info dialog */ - crop_info = info_dialog_new (_("Crop & Resize Information")); + crop_info = info_dialog_new (_("Crop & Resize Information"), + tools_help_func, NULL); /* add the information fields */ spinbutton = info_dialog_add_spinbutton (crop_info, _("Origin X:"), NULL, diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index b80a204d07..60b11f4044 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -21,7 +21,6 @@ #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "cursorutil.h" @@ -29,6 +28,7 @@ #include "general.h" #include "gdisplay.h" #include "gimphistogram.h" +#include "gimpui.h" #include "interface.h" #include "curves.h" #include "gimplut.h" @@ -114,7 +114,6 @@ static void curves_free_callback (GtkWidget *, gpointer); static void curves_reset_callback (GtkWidget *, gpointer); static void curves_ok_callback (GtkWidget *, gpointer); static void curves_cancel_callback (GtkWidget *, gpointer); -static gint curves_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void curves_preview_update (GtkWidget *, gpointer); static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); @@ -519,14 +518,7 @@ curves_new_dialog () GtkWidget *channel_hbox; GtkWidget *menu; GtkWidget *table; - int i, j; - - static ActionAreaItem action_items[] = - { - { N_("Reset"), curves_reset_callback, NULL, NULL }, - { N_("OK"), curves_ok_callback, NULL, NULL }, - { N_("Cancel"), curves_cancel_callback, NULL, NULL } - }; + gint i, j; static MenuItem curve_type_items[] = { @@ -535,7 +527,7 @@ curves_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - cd = g_malloc (sizeof (CurvesDialog)); + cd = g_new (CurvesDialog, 1); cd->cursor_ind_height = cd->cursor_ind_width = -1; cd->preview = TRUE; cd->curve_type = SMOOTH; @@ -556,17 +548,23 @@ curves_new_dialog () curve_type_items [i].user_data = (gpointer) cd; /* The shell and main vbox */ - cd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cd->shell), "curves", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cd->shell), _("Curves")); + cd->shell = gimp_dialog_new (_("Curves"), "curves", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Reset"), curves_reset_callback, + cd, NULL, FALSE, FALSE, + _("OK"), curves_ok_callback, + cd, NULL, TRUE, FALSE, + _("Cancel"), curves_cancel_callback, + cd, NULL, FALSE, TRUE, + + NULL); - gtk_signal_connect (GTK_OBJECT (cd->shell), "delete_event", - GTK_SIGNAL_FUNC (curves_delete_callback), - cd); - vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cd->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -670,12 +668,6 @@ curves_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = cd; - action_items[1].user_data = cd; - action_items[2].user_data = cd; - build_action_area (GTK_DIALOG (cd->shell), action_items, 3, 0); - gtk_widget_show (vbox); return cd; @@ -1278,24 +1270,15 @@ curves_cancel_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -curves_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - curves_cancel_callback (w, data); - - return TRUE; -} static void -curves_preview_update (GtkWidget *w, +curves_preview_update (GtkWidget *widget, gpointer data) { CurvesDialog *cd; cd = (CurvesDialog *) data; - if (GTK_TOGGLE_BUTTON (w)->active) + if (GTK_TOGGLE_BUTTON (widget)->active) { cd->preview = TRUE; curves_preview (cd); diff --git a/app/tools/gimphistogramtool.c b/app/tools/gimphistogramtool.c index 80542b4e5a..2169ca4225 100644 --- a/app/tools/gimphistogramtool.c +++ b/app/tools/gimphistogramtool.c @@ -15,15 +15,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "drawable.h" #include "gdisplay.h" +#include "gimpui.h" #include "histogram_tool.h" #include "image_map.h" #include "interface.h" @@ -54,7 +53,6 @@ static void histogram_tool_control (Tool *, ToolAction, gpointer); static HistogramToolDialog * histogram_tool_new_dialog (void); static void histogram_tool_close_callback (GtkWidget *, gpointer); -static gint histogram_tool_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void histogram_tool_value_callback (GtkWidget *, gpointer); static void histogram_tool_red_callback (GtkWidget *, gpointer); static void histogram_tool_green_callback (GtkWidget *, gpointer); @@ -257,12 +255,7 @@ histogram_tool_new_dialog () gint i; gint x, y; - static ActionAreaItem action_items[] = - { - { N_("Close"), histogram_tool_close_callback, NULL, NULL } - }; - - static char * histogram_info_names[] = + static gchar * histogram_info_names[] = { N_("Mean:"), N_("Std Dev:"), @@ -282,23 +275,24 @@ histogram_tool_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - htd = (HistogramToolDialog *) g_malloc (sizeof (HistogramToolDialog)); + htd = g_new (HistogramToolDialog, 1); htd->channel = HISTOGRAM_VALUE; for (i = 0; i < 4; i++) color_option_items [i].user_data = (gpointer) htd; - + htd->hist = gimp_histogram_new (); /* The shell and main vbox */ - htd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (htd->shell), "histogram", "Gimp"); - gtk_window_set_title (GTK_WINDOW (htd->shell), _("Histogram")); + htd->shell = gimp_dialog_new (_("Histogram"), "histogram", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (htd->shell), "delete_event", - (GtkSignalFunc) histogram_tool_delete_callback, - htd); + _("Close"), histogram_tool_close_callback, + htd, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -365,10 +359,6 @@ histogram_tool_new_dialog () gtk_widget_show (htd->info_labels[i]); } - /* The action area */ - action_items[0].user_data = htd; - build_action_area (GTK_DIALOG (htd->shell), action_items, 1, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (htd->shell); @@ -388,16 +378,6 @@ histogram_tool_close_callback (GtkWidget *widget, gtk_widget_hide (htd->shell); } -static gint -histogram_tool_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - histogram_tool_close_callback (widget, client_data); - - return TRUE; -} - static void histogram_tool_value_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index 941aa8221a..33fab136a9 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -18,6 +18,7 @@ #include #include #include + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -25,6 +26,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "hue_saturation.h" #include "interface.h" @@ -88,8 +90,6 @@ static void hue_saturation_update (HueSaturationDialog *, static void hue_saturation_preview (HueSaturationDialog *); static void hue_saturation_ok_callback (GtkWidget *, gpointer); static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static gint hue_saturation_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void hue_saturation_master_callback (GtkWidget *, gpointer); static void hue_saturation_R_callback (GtkWidget *, gpointer); static void hue_saturation_Y_callback (GtkWidget *, gpointer); @@ -223,7 +223,7 @@ hue_saturation (PixelRegion *srcPR, } -/* by_color select action functions */ +/* hue saturation action functions */ static void hue_saturation_control (Tool *tool, @@ -281,7 +281,7 @@ tools_free_hue_saturation (Tool *tool) color_bal = (HueSaturation *) tool->private; - /* Close the color select dialog */ + /* Close the hue saturation dialog */ if (hue_saturation_dialog) hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog); @@ -299,7 +299,7 @@ hue_saturation_initialize (GDisplay *gdisp) return; } - /* The "hue-saturation color" dialog */ + /* The "hue-saturation" dialog */ if (!hue_saturation_dialog) hue_saturation_dialog = hue_saturation_new_dialog (); else @@ -354,15 +354,9 @@ hue_saturation_new_dialog () GtkWidget *frame; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), hue_saturation_ok_callback, NULL, NULL }, - { N_("Cancel"), hue_saturation_cancel_callback, NULL, NULL } - }; - - char *hue_partition_names[] = + gchar *hue_partition_names[] = { N_("Master"), N_("R"), @@ -384,23 +378,26 @@ hue_saturation_new_dialog () hue_saturation_M_callback }; - hsd = g_malloc (sizeof (HueSaturationDialog)); + hsd = g_new (HueSaturationDialog, 1); hsd->hue_partition = 0; - hsd->preview = TRUE; + hsd->preview = TRUE; /* The shell and main vbox */ - hsd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (hsd->shell), "hue_saturation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (hsd->shell), _("Hue-Saturation")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (hsd->shell), "delete_event", - GTK_SIGNAL_FUNC (hue_saturation_delete_callback), - hsd); + hsd->shell = gimp_dialog_new (_("Hue-Saturation"), "hue_satiration", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), hue_saturation_ok_callback, + hsd, NULL, TRUE, FALSE, + _("Cancel"), hue_saturation_cancel_callback, + hsd, NULL, FALSE, TRUE, + + NULL); main_vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (hsd->shell)->vbox), main_vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (hsd->shell)->vbox), main_vbox); /* The main hbox containing hue partitions and sliders */ main_hbox = gtk_hbox_new (FALSE, 2); @@ -579,12 +576,6 @@ hue_saturation_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = hsd; - action_items[1].user_data = hsd; - build_action_area (GTK_DIALOG (hsd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (main_hbox); @@ -699,16 +690,6 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -hue_saturation_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - hue_saturation_cancel_callback (w, client_data); - - return TRUE; -} - static void hue_saturation_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index caa19c3814..e29e1e4658 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -21,7 +21,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "drawable.h" @@ -29,6 +28,7 @@ #include "gdisplay.h" #include "histogramwidget.h" #include "gimphistogram.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" #include "levels.h" @@ -138,7 +138,6 @@ static void levels_alpha_callback (GtkWidget *, gpointer); static void levels_auto_levels_callback (GtkWidget *, gpointer); static void levels_ok_callback (GtkWidget *, gpointer); static void levels_cancel_callback (GtkWidget *, gpointer); -static gint levels_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void levels_load_callback (GtkWidget *, gpointer); static void levels_save_callback (GtkWidget *, gpointer); static void levels_preview_update (GtkWidget *, gpointer); @@ -342,37 +341,34 @@ levels_new_dialog () GtkWidget *menu; GtkWidget *hbbox; GtkWidget *button; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("Auto Levels"), levels_auto_levels_callback, NULL, NULL }, - { N_("OK"), levels_ok_callback, NULL, NULL }, - { N_("Cancel"), levels_cancel_callback, NULL, NULL } - }; - - ld = g_malloc (sizeof (LevelsDialog)); + ld = g_new (LevelsDialog, 1); ld->preview = TRUE; - - ld->lut = gimp_lut_new(); - ld->hist = gimp_histogram_new(); + ld->lut = gimp_lut_new(); + ld->hist = gimp_histogram_new(); for (i = 0; i < 5; i++) color_option_items [i].user_data = (gpointer) ld; /* The shell and main vbox */ - ld->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (ld->shell), "levels", "Gimp"); - gtk_window_set_title (GTK_WINDOW (ld->shell), _("Levels")); + ld->shell = gimp_dialog_new (_("Levels"), "levels", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (ld->shell), "delete_event", - GTK_SIGNAL_FUNC (levels_delete_callback), - ld); + _("Auto Levels"), levels_auto_levels_callback, + ld, NULL, FALSE, FALSE, + _("OK"), levels_ok_callback, + ld, NULL, TRUE, FALSE, + _("Cancel"), levels_cancel_callback, + ld, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (ld->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ld->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -571,12 +567,6 @@ levels_new_dialog () gtk_widget_show (hbbox); - /* The action area */ - action_items[0].user_data = ld; - action_items[1].user_data = ld; - action_items[2].user_data = ld; - build_action_area (GTK_DIALOG (ld->shell), action_items, 3, 0); - gtk_widget_show (vbox); gtk_widget_show (ld->shell); @@ -1015,16 +1005,6 @@ levels_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -levels_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - levels_cancel_callback (w, client_data); - - return TRUE; -} - static void levels_cancel_callback (GtkWidget *widget, gpointer client_data) @@ -1409,9 +1389,8 @@ static void file_ok_callback (GtkWidget *widget, gpointer data) { - FILE *f; - char *filename; - int i; + FILE *f; + gchar *filename; filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_dlg)); diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index d3683b7c12..caa4a71711 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -18,12 +18,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include "actionarea.h" #include "appenv.h" #include "draw_core.h" +#include "gimphelp.h" #include "info_dialog.h" #include "measure.h" #include "tool_options_ui.h" @@ -266,11 +266,13 @@ measure_tool_button_press (Tool *tool, if (!measure_tool_info && (measure_tool_options->use_info_window || !GTK_WIDGET_VISIBLE (gdisp->statusarea))) { - measure_tool_info = info_dialog_new (_("Measure Tool")); + measure_tool_info = info_dialog_new (_("Measure Tool"), + tools_help_func, NULL); info_dialog_add_label (measure_tool_info, _("Distance:"), distance_buf); info_dialog_add_label (measure_tool_info, _("Angle:"), angle_buf); action_items[0].user_data = measure_tool_info; - build_action_area (GTK_DIALOG (measure_tool_info->shell), action_items, 1, 0); + build_action_area (GTK_DIALOG (measure_tool_info->shell), + action_items, 1, 0); } gdk_pointer_grab (gdisp->canvas->window, FALSE, diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c index eff27a770a..8cf983f639 100644 --- a/app/tools/gimpperspectivetool.c +++ b/app/tools/gimpperspectivetool.c @@ -57,7 +57,8 @@ perspective_tool_transform (Tool *tool, if (!transform_info) { transform_info = - info_dialog_new (_("Perspective Transform Information")); + info_dialog_new (_("Perspective Transform Information"), + tools_help_func, NULL); info_dialog_add_label (transform_info, "Matrix:", matrix_row_buf[0]); info_dialog_add_label (transform_info, "", matrix_row_buf[1]); diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index bd1a963823..465dff30ed 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -23,13 +22,13 @@ #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "gdisplay.h" #include "image_map.h" #include "interface.h" #include "posterize.h" #include "gimplut.h" +#include "gimpui.h" #include "lut_funcs.h" #include "libgimp/gimpintl.h" @@ -77,7 +76,6 @@ static void posterize_ok_callback (GtkWidget *, gpointer); static void posterize_cancel_callback (GtkWidget *, gpointer); static void posterize_preview_update (GtkWidget *, gpointer); static void posterize_levels_text_update (GtkWidget *, gpointer); -static gint posterize_delete_callback (GtkWidget *, GdkEvent *, gpointer); /* posterize select action functions */ @@ -190,29 +188,28 @@ posterize_new_dialog () GtkWidget *label; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), posterize_ok_callback, NULL, NULL }, - { N_("Cancel"), posterize_cancel_callback, NULL, NULL } - }; - - pd = g_malloc (sizeof (PosterizeDialog)); + pd = g_new (PosterizeDialog, 1); pd->preview = TRUE; - pd->levels = 3; - pd->lut = gimp_lut_new(); + pd->levels = 3; + pd->lut = gimp_lut_new (); /* The shell and main vbox */ - pd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (pd->shell), "posterize", "Gimp"); - gtk_window_set_title (GTK_WINDOW (pd->shell), _("Posterize")); + pd->shell = + gimp_dialog_new (_("Posterize"), "posterize", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (pd->shell), "delete_event", - GTK_SIGNAL_FUNC (posterize_delete_callback), - pd); + _("OK"), posterize_ok_callback, + pd, NULL, TRUE, FALSE, + _("Cancel"), posterize_cancel_callback, + pd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pd->shell)->vbox), vbox); /* Horizontal box for levels text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -250,11 +247,6 @@ posterize_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = pd; - action_items[1].user_data = pd; - build_action_area (GTK_DIALOG (pd->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (pd->shell); @@ -304,14 +296,6 @@ posterize_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -posterize_delete_callback (GtkWidget *w, GdkEvent *e, gpointer data) -{ - posterize_cancel_callback (w, data); - - return TRUE; -} - static void posterize_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 37feb3257b..1525f861ad 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -83,7 +83,8 @@ rotate_tool_transform (Tool *tool, if (!transform_info) { - transform_info = info_dialog_new (_("Rotation Information")); + transform_info = info_dialog_new (_("Rotation Information"), + tools_help_func, NULL); widget = info_dialog_add_spinbutton (transform_info, _("Angle:"), diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index d5630c5bd9..ff64114a04 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -71,7 +71,8 @@ scale_tool_transform (Tool *tool, if (!transform_info) { - transform_info = info_dialog_new (_("Scaling Information")); + transform_info = info_dialog_new (_("Scaling Information"), + tools_help_func, NULL); info_dialog_add_label (transform_info, _("Original Width:"), orig_width_buf); diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c index 9678e4fea0..9a8c4778f6 100644 --- a/app/tools/gimpsheartool.c +++ b/app/tools/gimpsheartool.c @@ -71,7 +71,8 @@ shear_tool_transform (Tool *tool, case INIT : if (!transform_info) { - transform_info = info_dialog_new (_("Shear Information")); + transform_info = info_dialog_new (_("Shear Information"), + tools_help_func, NULL); info_dialog_add_spinbutton (transform_info, _("Shear Magnitude X:"), diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c index f0fbb393a7..20685a58ba 100644 --- a/app/tools/gimpthresholdtool.c +++ b/app/tools/gimpthresholdtool.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "general.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "threshold.h" @@ -56,8 +56,6 @@ static ThresholdDialog * threshold_new_dialog (void); static void threshold_preview (ThresholdDialog *); static void threshold_ok_callback (GtkWidget *, gpointer); static void threshold_cancel_callback (GtkWidget *, gpointer); -static gint threshold_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void threshold_preview_update (GtkWidget *, gpointer); static void threshold_low_threshold_text_update (GtkWidget *, gpointer); static void threshold_high_threshold_text_update (GtkWidget *, gpointer); @@ -273,31 +271,29 @@ threshold_new_dialog () GtkWidget *frame; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), threshold_ok_callback, NULL, NULL }, - { N_("Cancel"), threshold_cancel_callback, NULL, NULL } - }; - - td = g_malloc (sizeof (ThresholdDialog)); - td->preview = TRUE; - td->low_threshold = 127; + td = g_new (ThresholdDialog, 1); + td->preview = TRUE; + td->low_threshold = 127; td->high_threshold = 255; - td->hist = gimp_histogram_new(); + td->hist = gimp_histogram_new (); /* The shell and main vbox */ - td->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (td->shell), "threshold", "Gimp"); - gtk_window_set_title (GTK_WINDOW (td->shell), _("Threshold")); + td->shell = + gimp_dialog_new (_("Threshold"), "threshold", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (td->shell), "delete_event", - GTK_SIGNAL_FUNC (threshold_delete_callback), - td); + _("OK"), threshold_ok_callback, + td, NULL, TRUE, FALSE, + _("Cancel"), threshold_cancel_callback, + td, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (td->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (td->shell)->vbox), vbox); /* Horizontal box for threshold text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -362,11 +358,6 @@ threshold_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = td; - action_items[1].user_data = td; - build_action_area (GTK_DIALOG (td->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (td->shell); @@ -411,16 +402,6 @@ threshold_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -threshold_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - threshold_cancel_callback (w, client_data); - - return TRUE; -} - static void threshold_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/histogram_tool.c b/app/tools/histogram_tool.c index 80542b4e5a..2169ca4225 100644 --- a/app/tools/histogram_tool.c +++ b/app/tools/histogram_tool.c @@ -15,15 +15,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "drawable.h" #include "gdisplay.h" +#include "gimpui.h" #include "histogram_tool.h" #include "image_map.h" #include "interface.h" @@ -54,7 +53,6 @@ static void histogram_tool_control (Tool *, ToolAction, gpointer); static HistogramToolDialog * histogram_tool_new_dialog (void); static void histogram_tool_close_callback (GtkWidget *, gpointer); -static gint histogram_tool_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void histogram_tool_value_callback (GtkWidget *, gpointer); static void histogram_tool_red_callback (GtkWidget *, gpointer); static void histogram_tool_green_callback (GtkWidget *, gpointer); @@ -257,12 +255,7 @@ histogram_tool_new_dialog () gint i; gint x, y; - static ActionAreaItem action_items[] = - { - { N_("Close"), histogram_tool_close_callback, NULL, NULL } - }; - - static char * histogram_info_names[] = + static gchar * histogram_info_names[] = { N_("Mean:"), N_("Std Dev:"), @@ -282,23 +275,24 @@ histogram_tool_new_dialog () { NULL, 0, 0, NULL, NULL, NULL, NULL } }; - htd = (HistogramToolDialog *) g_malloc (sizeof (HistogramToolDialog)); + htd = g_new (HistogramToolDialog, 1); htd->channel = HISTOGRAM_VALUE; for (i = 0; i < 4; i++) color_option_items [i].user_data = (gpointer) htd; - + htd->hist = gimp_histogram_new (); /* The shell and main vbox */ - htd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (htd->shell), "histogram", "Gimp"); - gtk_window_set_title (GTK_WINDOW (htd->shell), _("Histogram")); + htd->shell = gimp_dialog_new (_("Histogram"), "histogram", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (htd->shell), "delete_event", - (GtkSignalFunc) histogram_tool_delete_callback, - htd); + _("Close"), histogram_tool_close_callback, + htd, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); @@ -365,10 +359,6 @@ histogram_tool_new_dialog () gtk_widget_show (htd->info_labels[i]); } - /* The action area */ - action_items[0].user_data = htd; - build_action_area (GTK_DIALOG (htd->shell), action_items, 1, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (htd->shell); @@ -388,16 +378,6 @@ histogram_tool_close_callback (GtkWidget *widget, gtk_widget_hide (htd->shell); } -static gint -histogram_tool_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer client_data) -{ - histogram_tool_close_callback (widget, client_data); - - return TRUE; -} - static void histogram_tool_value_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/hue_saturation.c b/app/tools/hue_saturation.c index 941aa8221a..33fab136a9 100644 --- a/app/tools/hue_saturation.c +++ b/app/tools/hue_saturation.c @@ -18,6 +18,7 @@ #include #include #include + #include "appenv.h" #include "actionarea.h" #include "colormaps.h" @@ -25,6 +26,7 @@ #include "general.h" #include "gimage_mask.h" #include "gdisplay.h" +#include "gimpui.h" #include "hue_saturation.h" #include "interface.h" @@ -88,8 +90,6 @@ static void hue_saturation_update (HueSaturationDialog *, static void hue_saturation_preview (HueSaturationDialog *); static void hue_saturation_ok_callback (GtkWidget *, gpointer); static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static gint hue_saturation_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void hue_saturation_master_callback (GtkWidget *, gpointer); static void hue_saturation_R_callback (GtkWidget *, gpointer); static void hue_saturation_Y_callback (GtkWidget *, gpointer); @@ -223,7 +223,7 @@ hue_saturation (PixelRegion *srcPR, } -/* by_color select action functions */ +/* hue saturation action functions */ static void hue_saturation_control (Tool *tool, @@ -281,7 +281,7 @@ tools_free_hue_saturation (Tool *tool) color_bal = (HueSaturation *) tool->private; - /* Close the color select dialog */ + /* Close the hue saturation dialog */ if (hue_saturation_dialog) hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog); @@ -299,7 +299,7 @@ hue_saturation_initialize (GDisplay *gdisp) return; } - /* The "hue-saturation color" dialog */ + /* The "hue-saturation" dialog */ if (!hue_saturation_dialog) hue_saturation_dialog = hue_saturation_new_dialog (); else @@ -354,15 +354,9 @@ hue_saturation_new_dialog () GtkWidget *frame; GtkObject *data; GSList *group = NULL; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("OK"), hue_saturation_ok_callback, NULL, NULL }, - { N_("Cancel"), hue_saturation_cancel_callback, NULL, NULL } - }; - - char *hue_partition_names[] = + gchar *hue_partition_names[] = { N_("Master"), N_("R"), @@ -384,23 +378,26 @@ hue_saturation_new_dialog () hue_saturation_M_callback }; - hsd = g_malloc (sizeof (HueSaturationDialog)); + hsd = g_new (HueSaturationDialog, 1); hsd->hue_partition = 0; - hsd->preview = TRUE; + hsd->preview = TRUE; /* The shell and main vbox */ - hsd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (hsd->shell), "hue_saturation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (hsd->shell), _("Hue-Saturation")); - - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (hsd->shell), "delete_event", - GTK_SIGNAL_FUNC (hue_saturation_delete_callback), - hsd); + hsd->shell = gimp_dialog_new (_("Hue-Saturation"), "hue_satiration", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("OK"), hue_saturation_ok_callback, + hsd, NULL, TRUE, FALSE, + _("Cancel"), hue_saturation_cancel_callback, + hsd, NULL, FALSE, TRUE, + + NULL); main_vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (hsd->shell)->vbox), main_vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (hsd->shell)->vbox), main_vbox); /* The main hbox containing hue partitions and sliders */ main_hbox = gtk_hbox_new (FALSE, 2); @@ -579,12 +576,6 @@ hue_saturation_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - - /* The action area */ - action_items[0].user_data = hsd; - action_items[1].user_data = hsd; - build_action_area (GTK_DIALOG (hsd->shell), action_items, 2, 0); - gtk_widget_show (table); gtk_widget_show (vbox); gtk_widget_show (main_hbox); @@ -699,16 +690,6 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -hue_saturation_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - hue_saturation_cancel_callback (w, client_data); - - return TRUE; -} - static void hue_saturation_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/levels.c b/app/tools/levels.c index caa19c3814..e29e1e4658 100644 --- a/app/tools/levels.c +++ b/app/tools/levels.c @@ -21,7 +21,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "drawable.h" @@ -29,6 +28,7 @@ #include "gdisplay.h" #include "histogramwidget.h" #include "gimphistogram.h" +#include "gimpui.h" #include "image_map.h" #include "interface.h" #include "levels.h" @@ -138,7 +138,6 @@ static void levels_alpha_callback (GtkWidget *, gpointer); static void levels_auto_levels_callback (GtkWidget *, gpointer); static void levels_ok_callback (GtkWidget *, gpointer); static void levels_cancel_callback (GtkWidget *, gpointer); -static gint levels_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void levels_load_callback (GtkWidget *, gpointer); static void levels_save_callback (GtkWidget *, gpointer); static void levels_preview_update (GtkWidget *, gpointer); @@ -342,37 +341,34 @@ levels_new_dialog () GtkWidget *menu; GtkWidget *hbbox; GtkWidget *button; - int i; + gint i; - static ActionAreaItem action_items[] = - { - { N_("Auto Levels"), levels_auto_levels_callback, NULL, NULL }, - { N_("OK"), levels_ok_callback, NULL, NULL }, - { N_("Cancel"), levels_cancel_callback, NULL, NULL } - }; - - ld = g_malloc (sizeof (LevelsDialog)); + ld = g_new (LevelsDialog, 1); ld->preview = TRUE; - - ld->lut = gimp_lut_new(); - ld->hist = gimp_histogram_new(); + ld->lut = gimp_lut_new(); + ld->hist = gimp_histogram_new(); for (i = 0; i < 5; i++) color_option_items [i].user_data = (gpointer) ld; /* The shell and main vbox */ - ld->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (ld->shell), "levels", "Gimp"); - gtk_window_set_title (GTK_WINDOW (ld->shell), _("Levels")); + ld->shell = gimp_dialog_new (_("Levels"), "levels", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (ld->shell), "delete_event", - GTK_SIGNAL_FUNC (levels_delete_callback), - ld); + _("Auto Levels"), levels_auto_levels_callback, + ld, NULL, FALSE, FALSE, + _("OK"), levels_ok_callback, + ld, NULL, TRUE, FALSE, + _("Cancel"), levels_cancel_callback, + ld, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (ld->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ld->shell)->vbox), vbox); /* The option menu for selecting channels */ channel_hbox = gtk_hbox_new (FALSE, 2); @@ -571,12 +567,6 @@ levels_new_dialog () gtk_widget_show (hbbox); - /* The action area */ - action_items[0].user_data = ld; - action_items[1].user_data = ld; - action_items[2].user_data = ld; - build_action_area (GTK_DIALOG (ld->shell), action_items, 3, 0); - gtk_widget_show (vbox); gtk_widget_show (ld->shell); @@ -1015,16 +1005,6 @@ levels_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -levels_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - levels_cancel_callback (w, client_data); - - return TRUE; -} - static void levels_cancel_callback (GtkWidget *widget, gpointer client_data) @@ -1409,9 +1389,8 @@ static void file_ok_callback (GtkWidget *widget, gpointer data) { - FILE *f; - char *filename; - int i; + FILE *f; + gchar *filename; filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_dlg)); diff --git a/app/tools/measure.c b/app/tools/measure.c index d3683b7c12..caa4a71711 100644 --- a/app/tools/measure.c +++ b/app/tools/measure.c @@ -18,12 +18,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include "actionarea.h" #include "appenv.h" #include "draw_core.h" +#include "gimphelp.h" #include "info_dialog.h" #include "measure.h" #include "tool_options_ui.h" @@ -266,11 +266,13 @@ measure_tool_button_press (Tool *tool, if (!measure_tool_info && (measure_tool_options->use_info_window || !GTK_WIDGET_VISIBLE (gdisp->statusarea))) { - measure_tool_info = info_dialog_new (_("Measure Tool")); + measure_tool_info = info_dialog_new (_("Measure Tool"), + tools_help_func, NULL); info_dialog_add_label (measure_tool_info, _("Distance:"), distance_buf); info_dialog_add_label (measure_tool_info, _("Angle:"), angle_buf); action_items[0].user_data = measure_tool_info; - build_action_area (GTK_DIALOG (measure_tool_info->shell), action_items, 1, 0); + build_action_area (GTK_DIALOG (measure_tool_info->shell), + action_items, 1, 0); } gdk_pointer_grab (gdisp->canvas->window, FALSE, diff --git a/app/tools/perspective_tool.c b/app/tools/perspective_tool.c index eff27a770a..8cf983f639 100644 --- a/app/tools/perspective_tool.c +++ b/app/tools/perspective_tool.c @@ -57,7 +57,8 @@ perspective_tool_transform (Tool *tool, if (!transform_info) { transform_info = - info_dialog_new (_("Perspective Transform Information")); + info_dialog_new (_("Perspective Transform Information"), + tools_help_func, NULL); info_dialog_add_label (transform_info, "Matrix:", matrix_row_buf[0]); info_dialog_add_label (transform_info, "", matrix_row_buf[1]); diff --git a/app/tools/posterize.c b/app/tools/posterize.c index bd1a963823..465dff30ed 100644 --- a/app/tools/posterize.c +++ b/app/tools/posterize.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -23,13 +22,13 @@ #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "gdisplay.h" #include "image_map.h" #include "interface.h" #include "posterize.h" #include "gimplut.h" +#include "gimpui.h" #include "lut_funcs.h" #include "libgimp/gimpintl.h" @@ -77,7 +76,6 @@ static void posterize_ok_callback (GtkWidget *, gpointer); static void posterize_cancel_callback (GtkWidget *, gpointer); static void posterize_preview_update (GtkWidget *, gpointer); static void posterize_levels_text_update (GtkWidget *, gpointer); -static gint posterize_delete_callback (GtkWidget *, GdkEvent *, gpointer); /* posterize select action functions */ @@ -190,29 +188,28 @@ posterize_new_dialog () GtkWidget *label; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), posterize_ok_callback, NULL, NULL }, - { N_("Cancel"), posterize_cancel_callback, NULL, NULL } - }; - - pd = g_malloc (sizeof (PosterizeDialog)); + pd = g_new (PosterizeDialog, 1); pd->preview = TRUE; - pd->levels = 3; - pd->lut = gimp_lut_new(); + pd->levels = 3; + pd->lut = gimp_lut_new (); /* The shell and main vbox */ - pd->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (pd->shell), "posterize", "Gimp"); - gtk_window_set_title (GTK_WINDOW (pd->shell), _("Posterize")); + pd->shell = + gimp_dialog_new (_("Posterize"), "posterize", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (pd->shell), "delete_event", - GTK_SIGNAL_FUNC (posterize_delete_callback), - pd); + _("OK"), posterize_ok_callback, + pd, NULL, TRUE, FALSE, + _("Cancel"), posterize_cancel_callback, + pd, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pd->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pd->shell)->vbox), vbox); /* Horizontal box for levels text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -250,11 +247,6 @@ posterize_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = pd; - action_items[1].user_data = pd; - build_action_area (GTK_DIALOG (pd->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (pd->shell); @@ -304,14 +296,6 @@ posterize_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -posterize_delete_callback (GtkWidget *w, GdkEvent *e, gpointer data) -{ - posterize_cancel_callback (w, data); - - return TRUE; -} - static void posterize_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/rotate_tool.c b/app/tools/rotate_tool.c index 37feb3257b..1525f861ad 100644 --- a/app/tools/rotate_tool.c +++ b/app/tools/rotate_tool.c @@ -83,7 +83,8 @@ rotate_tool_transform (Tool *tool, if (!transform_info) { - transform_info = info_dialog_new (_("Rotation Information")); + transform_info = info_dialog_new (_("Rotation Information"), + tools_help_func, NULL); widget = info_dialog_add_spinbutton (transform_info, _("Angle:"), diff --git a/app/tools/scale_tool.c b/app/tools/scale_tool.c index d5630c5bd9..ff64114a04 100644 --- a/app/tools/scale_tool.c +++ b/app/tools/scale_tool.c @@ -71,7 +71,8 @@ scale_tool_transform (Tool *tool, if (!transform_info) { - transform_info = info_dialog_new (_("Scaling Information")); + transform_info = info_dialog_new (_("Scaling Information"), + tools_help_func, NULL); info_dialog_add_label (transform_info, _("Original Width:"), orig_width_buf); diff --git a/app/tools/shear_tool.c b/app/tools/shear_tool.c index 9678e4fea0..9a8c4778f6 100644 --- a/app/tools/shear_tool.c +++ b/app/tools/shear_tool.c @@ -71,7 +71,8 @@ shear_tool_transform (Tool *tool, case INIT : if (!transform_info) { - transform_info = info_dialog_new (_("Shear Information")); + transform_info = info_dialog_new (_("Shear Information"), + tools_help_func, NULL); info_dialog_add_spinbutton (transform_info, _("Shear Magnitude X:"), diff --git a/app/tools/threshold.c b/app/tools/threshold.c index f0fbb393a7..20685a58ba 100644 --- a/app/tools/threshold.c +++ b/app/tools/threshold.c @@ -19,10 +19,10 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "drawable.h" #include "general.h" #include "gdisplay.h" +#include "gimpui.h" #include "interface.h" #include "threshold.h" @@ -56,8 +56,6 @@ static ThresholdDialog * threshold_new_dialog (void); static void threshold_preview (ThresholdDialog *); static void threshold_ok_callback (GtkWidget *, gpointer); static void threshold_cancel_callback (GtkWidget *, gpointer); -static gint threshold_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void threshold_preview_update (GtkWidget *, gpointer); static void threshold_low_threshold_text_update (GtkWidget *, gpointer); static void threshold_high_threshold_text_update (GtkWidget *, gpointer); @@ -273,31 +271,29 @@ threshold_new_dialog () GtkWidget *frame; GtkWidget *toggle; - static ActionAreaItem action_items[] = - { - { N_("OK"), threshold_ok_callback, NULL, NULL }, - { N_("Cancel"), threshold_cancel_callback, NULL, NULL } - }; - - td = g_malloc (sizeof (ThresholdDialog)); - td->preview = TRUE; - td->low_threshold = 127; + td = g_new (ThresholdDialog, 1); + td->preview = TRUE; + td->low_threshold = 127; td->high_threshold = 255; - td->hist = gimp_histogram_new(); + td->hist = gimp_histogram_new (); /* The shell and main vbox */ - td->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (td->shell), "threshold", "Gimp"); - gtk_window_set_title (GTK_WINDOW (td->shell), _("Threshold")); + td->shell = + gimp_dialog_new (_("Threshold"), "threshold", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (td->shell), "delete_event", - GTK_SIGNAL_FUNC (threshold_delete_callback), - td); + _("OK"), threshold_ok_callback, + td, NULL, TRUE, FALSE, + _("Cancel"), threshold_cancel_callback, + td, NULL, FALSE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (td->shell)->vbox), vbox, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (td->shell)->vbox), vbox); /* Horizontal box for threshold text widget */ hbox = gtk_hbox_new (TRUE, 2); @@ -362,11 +358,6 @@ threshold_new_dialog () gtk_widget_show (toggle); gtk_widget_show (hbox); - /* The action area */ - action_items[0].user_data = td; - action_items[1].user_data = td; - build_action_area (GTK_DIALOG (td->shell), action_items, 2, 0); - gtk_widget_show (vbox); gtk_widget_show (td->shell); @@ -411,16 +402,6 @@ threshold_ok_callback (GtkWidget *widget, active_tool->drawable = NULL; } -static gint -threshold_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - threshold_cancel_callback (w, client_data); - - return TRUE; -} - static void threshold_cancel_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/tools/tools.c b/app/tools/tools.c index d150017b4a..074d1f0b87 100644 --- a/app/tools/tools.c +++ b/app/tools/tools.c @@ -17,7 +17,6 @@ */ #include #include "appenv.h" -#include "actionarea.h" #include "airbrush.h" #include "bezier_select.h" #include "blend.h" @@ -35,6 +34,7 @@ #include "dodgeburn.h" #include "eraser.h" #include "gdisplay.h" +#include "gimpui.h" #include "hue_saturation.h" #include "ellipse_select.h" #include "flip_tool.h" @@ -87,7 +87,7 @@ ToolInfo tool_info[] = "R", (char **) rect_bits, N_("Select rectangular regions"), - "ContextHelp/rect-select", + "rect_select", RECT_SELECT, tools_new_rect_select, tools_free_rect_select, @@ -102,7 +102,7 @@ ToolInfo tool_info[] = "E", (char **) circ_bits, N_("Select elliptical regions"), - "ContextHelp/ellipse-select", + "ellipse_select", ELLIPSE_SELECT, tools_new_ellipse_select, tools_free_ellipse_select, @@ -117,7 +117,7 @@ ToolInfo tool_info[] = "F", (char **) free_bits, N_("Select hand-drawn regions"), - "ContextHelp/free-select", + "free_select", FREE_SELECT, tools_new_free_select, tools_free_free_select, @@ -132,7 +132,7 @@ ToolInfo tool_info[] = "Z", (char **) fuzzy_bits, N_("Select contiguous regions"), - "ContextHelp/fuzzy-select", + "fuzzy_select", FUZZY_SELECT, tools_new_fuzzy_select, tools_free_fuzzy_select, @@ -147,7 +147,7 @@ ToolInfo tool_info[] = "B", (char **) bezier_bits, N_("Select regions using Bezier curves"), - "ContextHelp/bezier-select", + "bezier_select", BEZIER_SELECT, tools_new_bezier_select, tools_free_bezier_select, @@ -162,7 +162,7 @@ ToolInfo tool_info[] = "I", (char **) iscissors_bits, N_("Select shapes from image"), - "ContextHelp/iscissors", + "intelligent_scissors", ISCISSORS, tools_new_iscissors, tools_free_iscissors, @@ -177,7 +177,7 @@ ToolInfo tool_info[] = "M", (char **) move_bits, N_("Move layers & selections"), - "ContextHelp/move", + "move", MOVE, tools_new_move_tool, tools_free_move_tool, @@ -192,7 +192,7 @@ ToolInfo tool_info[] = "M", (char **) magnify_bits, N_("Zoom in & out"), - "ContextHelp/magnify", + "magnify", MAGNIFY, tools_new_magnify, tools_free_magnify, @@ -207,7 +207,7 @@ ToolInfo tool_info[] = "C", (char **) crop_bits, N_("Crop or resize the image"), - "ContextHelp/crop", + "crop", CROP, tools_new_crop, tools_free_crop, @@ -222,7 +222,7 @@ ToolInfo tool_info[] = "T", (char **) scale_bits, N_("Transform the layer or selection"), - "ContextHelp/rotate", + "transform", ROTATE, tools_new_transform_tool, tools_free_transform_tool, @@ -237,7 +237,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "transform", SCALE, tools_new_transform_tool, tools_free_transform_tool, @@ -252,7 +252,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "transform", SHEAR, tools_new_transform_tool, tools_free_transform_tool, @@ -267,7 +267,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "transform", PERSPECTIVE, tools_new_transform_tool, tools_free_transform_tool, @@ -282,7 +282,7 @@ ToolInfo tool_info[] = "F", (char **) flip_bits, N_("Flip the layer or selection"), - "ContextHelp/flip", + "flip", FLIP, tools_new_flip, tools_free_flip_tool, @@ -297,7 +297,7 @@ ToolInfo tool_info[] = "T", (char **) text_bits, N_("Add text to the image"), - "ContextHelp/text", + "text", TEXT, tools_new_text, tools_free_text, @@ -312,7 +312,7 @@ ToolInfo tool_info[] = "O", (char **) colorpicker_bits, N_("Pick colors from the image"), - "ContextHelp/color-picker", + "color_picker", COLOR_PICKER, tools_new_color_picker, tools_free_color_picker, @@ -327,7 +327,7 @@ ToolInfo tool_info[] = "B", (char **) fill_bits, N_("Fill with a color or pattern"), - "ContextHelp/bucket-fill", + "bucket_fill", BUCKET_FILL, tools_new_bucket_fill, tools_free_bucket_fill, @@ -342,7 +342,7 @@ ToolInfo tool_info[] = "L", (char **) gradient_bits, N_("Fill with a color gradient"), - "ContextHelp/gradient", + "blend", BLEND, tools_new_blend, tools_free_blend, @@ -357,7 +357,7 @@ ToolInfo tool_info[] = "P", (char **) pencil_bits, N_("Draw sharp pencil strokes"), - "ContextHelp/pencil", + "pencil", PENCIL, tools_new_pencil, tools_free_pencil, @@ -372,7 +372,7 @@ ToolInfo tool_info[] = "P", (char **) paint_bits, N_("Paint fuzzy brush strokes"), - "ContextHelp/paintbrush", + "paintbrush", PAINTBRUSH, tools_new_paintbrush, tools_free_paintbrush, @@ -387,7 +387,7 @@ ToolInfo tool_info[] = "E", (char **) erase_bits, N_("Erase to background or transparency"), - "ContextHelp/eraser", + "eraser", ERASER, tools_new_eraser, tools_free_eraser, @@ -402,7 +402,7 @@ ToolInfo tool_info[] = "A", (char **) airbrush_bits, N_("Airbrush with variable pressure"), - "ContextHelp/airbrush", + "airbrush", AIRBRUSH, tools_new_airbrush, tools_free_airbrush, @@ -417,7 +417,7 @@ ToolInfo tool_info[] = "C", (char **) clone_bits, N_("Paint using patterns or image regions"), - "ContextHelp/clone", + "clone", CLONE, tools_new_clone, tools_free_clone, @@ -432,7 +432,7 @@ ToolInfo tool_info[] = "V", (char **) blur_bits, N_("Blur or sharpen"), - "ContextHelp/convolve", + "convolve", CONVOLVE, tools_new_convolve, tools_free_convolve, @@ -447,7 +447,7 @@ ToolInfo tool_info[] = "K", (char **) ink_bits, N_("Draw in ink"), - "ContextHelp/ink", + "ink", INK, tools_new_ink, tools_free_ink, @@ -462,7 +462,7 @@ ToolInfo tool_info[] = "D", (char **) dodge_bits, N_("Dodge or Burn"), - "ContextHelp/dodgeburn", + "dodgeburn", DODGEBURN, tools_new_dodgeburn, tools_free_dodgeburn, @@ -477,7 +477,7 @@ ToolInfo tool_info[] = "S", (char **) smudge_bits, N_("Smudge"), - "ContextHelp/smudge", + "smudge", SMUDGE, tools_new_smudge, tools_free_smudge, @@ -492,7 +492,7 @@ ToolInfo tool_info[] = "", (char **) measure_bits, N_("Measure distances and angles"), - "ContextHelp/measure", + "measure", MEASURE, tools_new_measure_tool, tools_free_measure_tool, @@ -507,7 +507,7 @@ ToolInfo tool_info[] = "A", (char **) xinput_airbrush_bits, N_("Natural Airbrush"), - "ContextHelp/xinput_airbrush", + "xinput_airbrush", XINPUT_AIRBRUSH, tools_new_xinput_airbrush, tools_free_xinput_airbrush, @@ -522,7 +522,7 @@ ToolInfo tool_info[] = "", (char **) path_tool_bits, N_("Manipulate paths"), - "ContextHelp/path", + "path", PATH_TOOL, tools_new_path_tool, tools_free_path_tool, @@ -539,7 +539,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "by_color_select", BY_COLOR_SELECT, tools_new_by_color_select, tools_free_by_color_select, @@ -554,7 +554,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "color_balance", COLOR_BALANCE, tools_new_color_balance, tools_free_color_balance, @@ -569,7 +569,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "brightness_contrast", BRIGHTNESS_CONTRAST, tools_new_brightness_contrast, tools_free_brightness_contrast, @@ -584,7 +584,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "hue_saturation", HUE_SATURATION, tools_new_hue_saturation, tools_free_hue_saturation, @@ -599,7 +599,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "posterize", POSTERIZE, tools_new_posterize, tools_free_posterize, @@ -614,7 +614,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "threshold", THRESHOLD, tools_new_threshold, tools_free_threshold, @@ -629,7 +629,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "curves", CURVES, tools_new_curves, tools_free_curves, @@ -644,7 +644,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "levels", LEVELS, tools_new_levels, tools_free_levels, @@ -659,7 +659,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, - NULL, + "histogram", HISTOGRAM, tools_new_histogram_tool, tools_free_histogram_tool, @@ -671,11 +671,10 @@ gint num_tools = sizeof (tool_info) / sizeof (tool_info[0]); /* Local function declarations */ -static void tools_options_show (ToolType); -static void tools_options_hide (ToolType); -static void tools_options_reset_callback (GtkWidget *, gpointer); -static void tools_options_close_callback (GtkWidget *, gpointer); -static gint tools_options_delete_callback (GtkWidget *, GdkEvent *, gpointer); +static void tools_options_show (ToolType); +static void tools_options_hide (ToolType); +static void tools_options_reset_callback (GtkWidget *, gpointer); +static void tools_options_close_callback (GtkWidget *, gpointer); /* Function definitions */ @@ -695,15 +694,15 @@ active_tool_free (void) } void -tools_select (ToolType type) +tools_select (ToolType tool_type) { /* Care for switching to the tool's private context */ - context_manager_set_tool (type); + context_manager_set_tool (tool_type); if (active_tool) active_tool_free (); - active_tool = (* tool_info[(int) type].new_func) (); + active_tool = (* tool_info[(int) tool_type].new_func) (); tools_options_show (active_tool->type); @@ -712,30 +711,30 @@ tools_select (ToolType type) } void -tools_initialize (ToolType type, +tools_initialize (ToolType tool_type, GDisplay *gdisp) { /* Tools which have an init function have dialogs and * cannot be initialized without a display */ - if (tool_info[(int) type].init_func && !gdisp) - type = RECT_SELECT; + if (tool_info[(int) tool_type].init_func && !gdisp) + tool_type = RECT_SELECT; /* Activate the appropriate widget. * Implicitly calls tools_select() */ - if (active_tool->type == type) + if (active_tool->type == tool_type) { - tools_select (type); + tools_select (tool_type); } else { - gtk_widget_activate (tool_info[type].tool_widget); + gtk_widget_activate (tool_info[tool_type].tool_widget); } - if (tool_info[(int) type].init_func) + if (tool_info[(int) tool_type].init_func) { - (* tool_info[(int) type].init_func) (gdisp); + (* tool_info[(int) tool_type].init_func) (gdisp); active_tool->drawable = gimage_active_drawable (gdisp->gimage); } @@ -878,13 +877,13 @@ standard_control_func (Tool *tool, */ Tool * -tools_new_tool (ToolType type) +tools_new_tool (ToolType tool_type) { Tool *tool; tool = g_new (Tool, 1); - tool->type = type; + tool->type = tool_type; tool->ID = global_tool_ID++; tool->state = INACTIVE; @@ -917,21 +916,22 @@ tools_options_dialog_new () GtkWidget *frame; GtkWidget *vbox; - ActionAreaItem action_items[] = - { - { N_("Reset"), tools_options_reset_callback, NULL, NULL }, - { N_("Close"), tools_options_close_callback, NULL, NULL } - }; - /* The shell and main vbox */ - options_shell = gtk_dialog_new (); + options_shell = + gimp_dialog_new (_("Tool Options"), "tool_options", + tools_help_func, NULL, + GTK_WIN_POS_NONE, + FALSE, TRUE, TRUE, + + _("Reset"), tools_options_reset_callback, + NULL, &options_reset_button, FALSE, FALSE, + _("Close"), tools_options_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* Register dialog */ dialog_register (options_shell); - - gtk_window_set_wmclass (GTK_WINDOW (options_shell), "tool_options", "Gimp"); - gtk_window_set_title (GTK_WINDOW (options_shell), _("Tool Options")); - gtk_window_set_policy (GTK_WINDOW (options_shell), FALSE, TRUE, TRUE); session_set_window_geometry (options_shell, &tool_options_session_info, FALSE ); @@ -961,17 +961,6 @@ tools_options_dialog_new () gtk_container_set_border_width (GTK_CONTAINER (options_vbox), 2); gtk_box_pack_start (GTK_BOX (vbox), options_vbox, FALSE, FALSE, 0); - /* handle the window manager trying to close the window */ - gtk_signal_connect (GTK_OBJECT (options_shell), "delete_event", - GTK_SIGNAL_FUNC (tools_options_delete_callback), - options_shell); - - action_items[0].user_data = options_shell; - action_items[1].user_data = options_shell; - build_action_area (GTK_DIALOG (options_shell), action_items, 2, 1); - - options_reset_button = action_items[0].widget; - gtk_widget_show (options_vbox); /* hide the separator between the dialog's vbox and the action area */ @@ -985,6 +974,18 @@ tools_options_dialog_free () gtk_widget_destroy (options_shell); } +void +tools_help_func (gpointer help_data) +{ + gchar *help_page; + + help_page = g_strdup_printf ("tools/%s.html", + tool_info[(int) active_tool->type].private_tip); + gimp_help (help_page); + + g_free (help_page); +} + void tools_register (ToolType tool_type, ToolOptions *tool_options) @@ -1007,57 +1008,47 @@ tools_register (ToolType tool_type, } static void -tools_options_show (ToolType tooltype) +tools_options_show (ToolType tool_type) { - if (tool_info[tooltype].tool_options->main_vbox) - gtk_widget_show (tool_info[tooltype].tool_options->main_vbox); + if (tool_info[tool_type].tool_options->main_vbox) + gtk_widget_show (tool_info[tool_type].tool_options->main_vbox); - if (tool_info[tooltype].tool_options->title) + if (tool_info[tool_type].tool_options->title) gtk_label_set_text (GTK_LABEL (options_label), - _(tool_info[tooltype].tool_options->title)); + _(tool_info[tool_type].tool_options->title)); - if (tool_info[tooltype].tool_options->reset_func) + if (tool_info[tool_type].tool_options->reset_func) gtk_widget_set_sensitive (options_reset_button, TRUE); else gtk_widget_set_sensitive (options_reset_button, FALSE); } static void -tools_options_hide (ToolType tooltype) +tools_options_hide (ToolType tool_type) { - if (tool_info[tooltype].tool_options) - gtk_widget_hide (tool_info[tooltype].tool_options->main_vbox); + if (tool_info[tool_type].tool_options) + gtk_widget_hide (tool_info[tool_type].tool_options->main_vbox); } /* Tool options callbacks */ -static gint -tools_options_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - tools_options_close_callback (w, client_data); - - return TRUE; -} - static void -tools_options_close_callback (GtkWidget *w, - gpointer client_data) +tools_options_close_callback (GtkWidget *widget, + gpointer data) { GtkWidget *shell; - shell = (GtkWidget *) client_data; + shell = (GtkWidget *) data; gtk_widget_hide (shell); } static void -tools_options_reset_callback (GtkWidget *w, - gpointer client_data) +tools_options_reset_callback (GtkWidget *widget, + gpointer data) { GtkWidget *shell; - shell = (GtkWidget *) client_data; + shell = (GtkWidget *) data; if (! active_tool) return; diff --git a/app/tools/tools.h b/app/tools/tools.h index 3f5ec19831..b0fb46959e 100644 --- a/app/tools/tools.h +++ b/app/tools/tools.h @@ -111,6 +111,8 @@ void tools_options_dialog_new (void); void tools_options_dialog_show (void); void tools_options_dialog_free (void); +void tools_help_func (gpointer); + void tools_register (ToolType tool_type, ToolOptions *tool_options); diff --git a/app/tools/transform_core.c b/app/tools/transform_core.c index c8f8749d51..1ff22aac79 100644 --- a/app/tools/transform_core.c +++ b/app/tools/transform_core.c @@ -101,8 +101,13 @@ typedef struct _PixelSurround { int row_stride; } PixelSurround; -static void pixel_surround_init(PixelSurround * ps, TileManager* t, - int w, int h, unsigned char bg[MAX_CHANNELS]) { +static void +pixel_surround_init (PixelSurround *ps, + TileManager *t, + int w, + int h, + guchar bg[MAX_CHANNELS]) +{ int i; for (i = 0; i < MAX_CHANNELS; ++i) { ps->bg[i] = bg[i]; @@ -122,8 +127,11 @@ static void pixel_surround_init(PixelSurround * ps, TileManager* t, /* strategy: if we are in the middle of a tile, use the tile storage */ /* otherwise just copy into out own malloced buffer and return that */ -static unsigned char* pixel_surround_lock(PixelSurround* ps, int x, int y) { - +static guchar * +pixel_surround_lock (PixelSurround *ps, + int x, + int y) +{ int i, j; unsigned char* k; unsigned char* ptr; @@ -170,28 +178,34 @@ static unsigned char* pixel_surround_lock(PixelSurround* ps, int x, int y) { return ps->buff; } -static int pixel_surround_rowstride(PixelSurround* ps) { +static int +pixel_surround_rowstride (PixelSurround *ps) +{ return ps->row_stride; } -static void pixel_surround_release(PixelSurround* ps) { +static void +pixel_surround_release (PixelSurround *ps) +{ /* always get new tile (for now), so release the old one */ - if (ps->tile) { - tile_release(ps->tile, FALSE); - ps->tile = 0; - } + if (ps->tile) + { + tile_release(ps->tile, FALSE); + ps->tile = 0; + } } -static void pixel_surround_clear(PixelSurround* ps) { - if (ps->buff) { - g_free(ps->buff); - ps->buff = 0; - ps->buff_size = 0; - } +static void +pixel_surround_clear (PixelSurround *ps) +{ + if (ps->buff) + { + g_free (ps->buff); + ps->buff = 0; + ps->buff_size = 0; + } } - - static void transform_ok_callback (GtkWidget *w, gpointer client_data) @@ -386,6 +400,7 @@ transform_core_button_press (Tool *tool, action_items[1].user_data = tool; build_action_area (GTK_DIALOG (transform_info->shell), action_items, n_action_items, 0); + transform_info_inited = TRUE; } @@ -1611,5 +1626,3 @@ cubic (double dx, return result; } - - diff --git a/app/transform_core.c b/app/transform_core.c index c8f8749d51..1ff22aac79 100644 --- a/app/transform_core.c +++ b/app/transform_core.c @@ -101,8 +101,13 @@ typedef struct _PixelSurround { int row_stride; } PixelSurround; -static void pixel_surround_init(PixelSurround * ps, TileManager* t, - int w, int h, unsigned char bg[MAX_CHANNELS]) { +static void +pixel_surround_init (PixelSurround *ps, + TileManager *t, + int w, + int h, + guchar bg[MAX_CHANNELS]) +{ int i; for (i = 0; i < MAX_CHANNELS; ++i) { ps->bg[i] = bg[i]; @@ -122,8 +127,11 @@ static void pixel_surround_init(PixelSurround * ps, TileManager* t, /* strategy: if we are in the middle of a tile, use the tile storage */ /* otherwise just copy into out own malloced buffer and return that */ -static unsigned char* pixel_surround_lock(PixelSurround* ps, int x, int y) { - +static guchar * +pixel_surround_lock (PixelSurround *ps, + int x, + int y) +{ int i, j; unsigned char* k; unsigned char* ptr; @@ -170,28 +178,34 @@ static unsigned char* pixel_surround_lock(PixelSurround* ps, int x, int y) { return ps->buff; } -static int pixel_surround_rowstride(PixelSurround* ps) { +static int +pixel_surround_rowstride (PixelSurround *ps) +{ return ps->row_stride; } -static void pixel_surround_release(PixelSurround* ps) { +static void +pixel_surround_release (PixelSurround *ps) +{ /* always get new tile (for now), so release the old one */ - if (ps->tile) { - tile_release(ps->tile, FALSE); - ps->tile = 0; - } + if (ps->tile) + { + tile_release(ps->tile, FALSE); + ps->tile = 0; + } } -static void pixel_surround_clear(PixelSurround* ps) { - if (ps->buff) { - g_free(ps->buff); - ps->buff = 0; - ps->buff_size = 0; - } +static void +pixel_surround_clear (PixelSurround *ps) +{ + if (ps->buff) + { + g_free (ps->buff); + ps->buff = 0; + ps->buff_size = 0; + } } - - static void transform_ok_callback (GtkWidget *w, gpointer client_data) @@ -386,6 +400,7 @@ transform_core_button_press (Tool *tool, action_items[1].user_data = tool; build_action_area (GTK_DIALOG (transform_info->shell), action_items, n_action_items, 0); + transform_info_inited = TRUE; } @@ -1611,5 +1626,3 @@ cubic (double dx, return result; } - - diff --git a/app/undo_history.c b/app/undo_history.c index 7609e152e9..05ea81e8d7 100644 --- a/app/undo_history.c +++ b/app/undo_history.c @@ -49,8 +49,8 @@ #include +#include "gimpui.h" #include "undo.h" -#include "actionarea.h" #include "libgimp/gimpintl.h" @@ -132,25 +132,6 @@ undo_history_close_callback (GtkWidget *w, gtk_widget_hide (GTK_WIDGET (st->shell)); } -/* WM_DELETE */ -static gint -undo_history_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer data) -{ - undo_history_close_callback (w, data); - return TRUE; -} - - -static ActionAreaItem action_items[] = -{ - { N_("Close"), undo_history_close_callback, NULL, NULL } -}; - - - - /* The gimage and shell destroy callbacks are split so we can: * a) blow the shell when the image dissappears * b) disconnect from the image if the shell dissappears (we don't @@ -441,16 +422,20 @@ undo_history_new (GImage *gimage) undo_history_clean_callback, st); /* The shell and main vbox */ - st->shell = gtk_dialog_new (); - - gtk_window_set_wmclass (GTK_WINDOW (st->shell), "undohistory", "Gimp"); - gtk_window_set_policy (GTK_WINDOW (st->shell), FALSE, TRUE, FALSE); - { - char *title = g_strdup_printf (_("%s: undo history"), - g_basename (gimage_filename (gimage))); - gtk_window_set_title (GTK_WINDOW (st->shell), title); - g_free (title); + char *title = g_strdup_printf (_("%s: undo history"), + g_basename (gimage_filename (gimage))); + st->shell = gimp_dialog_new (title, "undo_history", + gimp_standard_help_func, + "dialogs/undo_histroy_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Close"), undo_history_close_callback, + st, NULL, TRUE, TRUE, + + NULL); + g_free (title); } vbox = gtk_vbox_new (FALSE, 1); @@ -459,9 +444,6 @@ undo_history_new (GImage *gimage) vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); - /* handle the wm close event */ - gtk_signal_connect (GTK_OBJECT (st->shell), "delete_event", - GTK_SIGNAL_FUNC (undo_history_delete_callback), st); gtk_signal_connect (GTK_OBJECT (st->shell), "destroy", GTK_SIGNAL_FUNC (undo_history_shell_destroy_callback), st); @@ -513,13 +495,9 @@ undo_history_new (GImage *gimage) undo_history_redo_callback, st); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); - action_items[0].user_data = st; - build_action_area (GTK_DIALOG (st->shell), action_items, 1, 0); - undo_history_set_sensitive (st, GTK_CLIST (st->clist)->rows); gtk_widget_show (GTK_WIDGET (st->shell)); return st->shell; } - diff --git a/app/user_install.c b/app/user_install.c index 1ae0bc2571..2c6233c258 100644 --- a/app/user_install.c +++ b/app/user_install.c @@ -15,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include @@ -29,9 +28,9 @@ #endif #include "appenv.h" -#include "actionarea.h" #include "install.h" #include "gimprc.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" #include "libgimp/gimpenv.h" @@ -49,13 +48,13 @@ # define USER_INSTALL "user_install.bat" #endif -static void install_run (InstallCallback); -static void install_help (InstallCallback); -static void help_install_callback (GtkWidget *, gpointer); -static void help_ignore_callback (GtkWidget *, gpointer); -static void help_quit_callback (GtkWidget *, gpointer); +static void install_run (InstallCallback); +static void install_help (InstallCallback); +static void help_install_callback (GtkWidget *, gpointer); +static void help_ignore_callback (GtkWidget *, gpointer); +static void help_quit_callback (GtkWidget *, gpointer); static void install_continue_callback (GtkWidget *, gpointer); -static void install_quit_callback (GtkWidget *, gpointer); +static void install_quit_callback (GtkWidget *, gpointer); static GtkWidget *help_widget; static GtkWidget *install_widget; @@ -100,12 +99,6 @@ install_verify (InstallCallback install_callback) static void install_help (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Install"), help_install_callback, NULL, NULL }, - { N_("Ignore"), help_ignore_callback, NULL, NULL }, - { N_("Quit"), help_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -175,7 +168,7 @@ install_help (InstallCallback callback) { 1, N_("generated_brushes\n") }, { 0, N_("\t\tThis is a subdirectory which is used to store brushes\n" "\t\tthat are created with the brush editor. The default\n" - "\t\gimprc file checks this subdirectory when searching for\n" + "\t\tgimprc file checks this subdirectory when searching for\n" "\t\tgenerated brushes.\n") }, { 1, N_("gradients\n") }, @@ -254,13 +247,24 @@ install_help (InstallCallback callback) gint nhelp_lines = sizeof (help_lines) / sizeof (help_lines[0]); gint i; - help_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (help_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (help_widget), "gimp_installation", "Gimp"); - gtk_window_set_title (GTK_WINDOW (help_widget), _("GIMP Installation")); - gtk_window_position (GTK_WINDOW (help_widget), GTK_WIN_POS_CENTER); + help_widget = gimp_dialog_new (_("GIMP Installation"), "gimp_installation", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Install"), help_install_callback, + callback, NULL, TRUE, FALSE, + _("Ignore"), help_ignore_callback, + callback, NULL, FALSE, FALSE, + _("Quit"), help_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (help_widget)->vbox), table); vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); @@ -268,25 +272,12 @@ install_help (InstallCallback callback) gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_widget_set_usize (text, 450, 475); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - action_items[2].user_data = (void *) callback; - build_action_area (GTK_DIALOG (help_widget), action_items, 3, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (help_widget)->vbox), table, - TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, 0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font_emphasis = gdk_font_load ("-*-helvetica-medium-o-normal-*-*-100-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*"); @@ -392,11 +383,6 @@ quote_spaces (char *string) static void install_run (InstallCallback callback) { - static ActionAreaItem action_items[] = - { - { N_("Continue"), install_continue_callback, NULL, NULL }, - { N_("Quit"), install_quit_callback, NULL, NULL } - }; GtkWidget *text; GtkWidget *table; GtkWidget *vsb; @@ -409,27 +395,28 @@ install_run (InstallCallback callback) int err; int executable = TRUE; - install_widget = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (install_widget), "delete_event", - GTK_SIGNAL_FUNC (gtk_true), - NULL); - gtk_window_set_wmclass (GTK_WINDOW (install_widget), "installation_log", "Gimp"); - gtk_window_set_title (GTK_WINDOW (install_widget), _("Installation Log")); - gtk_window_position (GTK_WINDOW (install_widget), GTK_WIN_POS_CENTER); + install_widget = gimp_dialog_new (_("Installation Log"), "installation_log", + NULL, NULL, + GTK_WIN_POS_CENTER, + FALSE, TRUE, FALSE, + + _("Continue"), install_continue_callback, + callback, NULL, TRUE, FALSE, + _("Quit"), install_quit_callback, + callback, NULL, FALSE, TRUE, + + NULL); + + table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (install_widget)->vbox), table); + vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); vsb = gtk_vscrollbar_new (vadj); text = gtk_text_new (NULL, vadj); gtk_widget_set_usize (text, 384, 356); - table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); - - action_items[0].user_data = (void *) callback; - action_items[1].user_data = (void *) callback; - build_action_area (GTK_DIALOG (install_widget), action_items, 2, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (install_widget)->vbox), table, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, @@ -437,8 +424,6 @@ install_run (InstallCallback callback) GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - font_strong = gdk_font_load ("-*-helvetica-bold-r-normal-*-*-120-*-*-*-*-*-*"); font = gdk_font_load ("-*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"); diff --git a/app/widgets/gimpbrusheditor.c b/app/widgets/gimpbrusheditor.c index 28f0fa3746..4541982c79 100644 --- a/app/widgets/gimpbrusheditor.c +++ b/app/widgets/gimpbrusheditor.c @@ -23,22 +23,16 @@ #include "appenv.h" #include "gimpbrushgenerated.h" #include "brush_edit.h" -#include "actionarea.h" +#include "gimpui.h" #include "libgimp/gimpintl.h" -static void brush_edit_close_callback (GtkWidget *w, void *data); +static void brush_edit_close_callback (GtkWidget *, gpointer); static gint brush_edit_preview_resize (GtkWidget *widget, GdkEvent *event, BrushEditGeneratedWindow *begw); -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Close"), brush_edit_close_callback, NULL, NULL } -}; - static void -update_brush_callback (GtkAdjustment *adjustment, +update_brush_callback (GtkAdjustment *adjustment, BrushEditGeneratedWindow *begw) { if (begw->brush && @@ -64,15 +58,6 @@ update_brush_callback (GtkAdjustment *adjustment, } } -static gint -brush_edit_delete_callback (GtkWidget *w, - BrushEditGeneratedWindow *begw) -{ - if (GTK_WIDGET_VISIBLE (w)) - gtk_widget_hide (w); - return TRUE; -} - static void brush_edit_clear_preview (BrushEditGeneratedWindow *begw) { @@ -93,7 +78,7 @@ brush_edit_clear_preview (BrushEditGeneratedWindow *begw) } static gint -brush_edit_brush_dirty_callback(GimpBrush *brush, +brush_edit_brush_dirty_callback (GimpBrush *brush, BrushEditGeneratedWindow *begw) { int x, y, width, yend, ystart, xo; @@ -138,15 +123,17 @@ brush_edit_brush_dirty_callback(GimpBrush *brush, return TRUE; } -void brush_renamed_callback(GtkWidget *widget, BrushEditGeneratedWindow *begw) +void +brush_renamed_callback (GtkWidget *widget, + BrushEditGeneratedWindow *begw) { gtk_entry_set_text(GTK_ENTRY(begw->name), gimp_brush_get_name(GIMP_BRUSH(begw->brush))); } void -brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw, - GimpBrush *gbrush) +brush_edit_generated_set_brush (BrushEditGeneratedWindow *begw, + GimpBrush *gbrush) { GimpBrushGenerated *brush = 0; if (begw->brush == (GimpBrushGenerated*)gbrush) @@ -189,16 +176,21 @@ brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw, } } -void name_changed_func(GtkWidget *widget, BrushEditGeneratedWindow *begw) +void +name_changed_func (GtkWidget *widget, + BrushEditGeneratedWindow *begw) { gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(widget)); gimp_brush_set_name(GIMP_BRUSH(begw->brush), entry_text); } -void focus_out_func(GtkWidget *wid1, GtkWidget *wid2, BrushEditGeneratedWindow *begw) +void +focus_out_func (GtkWidget *wid1, + GtkWidget *wid2, + BrushEditGeneratedWindow *begw) { - name_changed_func(wid1, begw); + name_changed_func (wid1, begw); } BrushEditGeneratedWindow * @@ -210,34 +202,31 @@ brush_edit_generated_new () GtkWidget *slider; GtkWidget *table; - - - begw = g_malloc (sizeof (BrushEditGeneratedWindow)); + begw = g_new (BrushEditGeneratedWindow, 1); begw->brush = NULL; - begw->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (begw->shell), "generatedbrusheditor", - "Gimp"); - gtk_window_set_title (GTK_WINDOW (begw->shell), _("Brush Editor")); - gtk_window_set_policy(GTK_WINDOW(begw->shell), FALSE, TRUE, FALSE); + begw->shell = gimp_dialog_new (_("Brush Editor"), "generated_brush_editor", + gimp_standard_help_func, + "dialogs/generated_brush_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Close"), brush_edit_close_callback, + begw, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (begw->shell)->vbox), vbox, - TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (begw->shell)->vbox), vbox); - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (begw->shell), "delete_event", - GTK_SIGNAL_FUNC (brush_edit_delete_callback), - begw); + /* Populate the window with some widgets */ -/* Populate the window with some widgets */ - - /* table for brush controlls */ + /* table for brush controlls */ table = gtk_table_new(5, 4, FALSE); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); - /* Brush's name */ + /* Brush's name */ begw->name = gtk_entry_new(); gtk_box_pack_start (GTK_BOX (vbox), begw->name, TRUE, TRUE, 0); @@ -249,7 +238,7 @@ brush_edit_generated_new () begw); gtk_widget_show(begw->name); - /* brush's preview widget w/frame */ + /* brush's preview widget w/frame */ begw->frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (begw->frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), begw->frame, TRUE, TRUE, 0); @@ -276,7 +265,7 @@ brush_edit_generated_new () /* brush radius scale */ label = gtk_label_new (_("Radius:")); gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5); -/* gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); */ + /* gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 0, 0); */ gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, 3, 0, 0, 0); begw->radius_data = GTK_ADJUSTMENT (gtk_adjustment_new (10.0, 0.0, 100.0, 0.1, 1.0, 0.0)); slider = gtk_hscale_new (begw->radius_data); @@ -341,20 +330,15 @@ brush_edit_generated_new () gtk_table_set_col_spacing(GTK_TABLE (table), 0, 3); gtk_widget_show (table); - /* The action area */ - action_items[0].user_data = begw; - build_action_area (GTK_DIALOG (begw->shell), action_items, 1, 0); - gtk_widget_show (vbox); gtk_widget_show (begw->shell); - return begw; } static gint -brush_edit_preview_resize (GtkWidget *widget, - GdkEvent *event, +brush_edit_preview_resize (GtkWidget *widget, + GdkEvent *event, BrushEditGeneratedWindow *begw) { gtk_preview_size (GTK_PREVIEW (begw->preview), @@ -363,14 +347,16 @@ brush_edit_preview_resize (GtkWidget *widget, /* update the display */ if (begw->brush) - brush_edit_brush_dirty_callback(GIMP_BRUSH(begw->brush), begw); + brush_edit_brush_dirty_callback (GIMP_BRUSH (begw->brush), begw); return FALSE; } static void -brush_edit_close_callback (GtkWidget *w, void *data) +brush_edit_close_callback (GtkWidget *widget, + gpointer data) { - BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *)data; + BrushEditGeneratedWindow *begw = (BrushEditGeneratedWindow *) data; + if (GTK_WIDGET_VISIBLE (begw->shell)) gtk_widget_hide (begw->shell); } diff --git a/app/widgets/gimpcolordialog.c b/app/widgets/gimpcolordialog.c index bdb4b3739c..39976e007a 100644 --- a/app/widgets/gimpcolordialog.c +++ b/app/widgets/gimpcolordialog.c @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #define __COLOR_NOTEBOOK_C__ 1 #include "config.h" @@ -29,28 +28,17 @@ #include #include "appenv.h" -#include "actionarea.h" #include "color_notebook.h" +#include "gimpui.h" #include "libgimp/color_selector.h" #include "libgimp/gimpintl.h" - - -static void color_notebook_ok_callback (GtkWidget *, gpointer); +static void color_notebook_ok_callback (GtkWidget *, gpointer); static void color_notebook_cancel_callback (GtkWidget *, gpointer); -static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void color_notebook_update_callback (void *, int, int, int); static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint); - -static ActionAreaItem action_items[2] = -{ - { N_("OK"), color_notebook_ok_callback, NULL, NULL }, - { N_("Cancel"), color_notebook_cancel_callback, NULL, NULL }, -}; - - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo { char *name; /* label used in notebook tab */ @@ -98,28 +86,33 @@ color_notebook_new (int r, g_return_val_if_fail (selector_info != NULL, NULL); - cnp = g_malloc (sizeof (_ColorNotebook)); + cnp = g_new (_ColorNotebook, 1); - cnp->callback = callback; - cnp->client_data = client_data; + cnp->callback = callback; + cnp->client_data = client_data; cnp->wants_updates = wants_updates; - cnp->selectors = NULL; - cnp->cur_page = NULL; + cnp->selectors = NULL; + cnp->cur_page = NULL; - cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; + cnp->values[RED] = cnp->orig_values[RED] = r & 0xff; cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff; - cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; + cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff; - /* window hints need to stay the same, so people's window manager - * setups still work */ - cnp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE); + cnp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_notebook_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event", - (GtkSignalFunc) color_notebook_delete_callback, cnp); + wants_updates ? _("Close") : _("OK"), + color_notebook_ok_callback, + cnp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_notebook_cancel_callback, + cnp, NULL, FALSE, TRUE, + + NULL); /* do we actually need a notebook? */ if (selector_info->next) @@ -179,21 +172,6 @@ color_notebook_new (int r, info = info->next; } - /* The action area */ - action_items[0].user_data = cnp; - action_items[1].user_data = cnp; - if (cnp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0); - gtk_widget_show (cnp->shell); /* this must come after showing the widget, otherwise we get a @@ -209,7 +187,6 @@ color_notebook_new (int r, return cnp; } - void color_notebook_show (ColorNotebookP cnp) { @@ -217,7 +194,6 @@ color_notebook_show (ColorNotebookP cnp) gtk_widget_show (cnp->shell); } - void color_notebook_hide (ColorNotebookP cnp) { @@ -253,13 +229,12 @@ color_notebook_free (ColorNotebookP cnp) g_free (cnp); } - void color_notebook_set_color (ColorNotebookP cnp, - int r, - int g, - int b, - int set_current) + int r, + int g, + int b, + int set_current) { ColorSelectorInstance *csel; g_return_if_fail (cnp != NULL); @@ -279,11 +254,12 @@ color_notebook_set_color (ColorNotebookP cnp, csel->info->m.setcolor (csel->selector_data, r, g, b, set_current); } - - /* Called by a colour selector on user selection of a colour */ static void -color_notebook_update_callback (void *data, int r, int g, int b) +color_notebook_update_callback (void *data, + int r, + int g, + int b) { ColorSelectorInstance *csel; ColorNotebookP cnp; @@ -307,16 +283,13 @@ color_notebook_update_callback (void *data, int r, int g, int b) } } - - - static void -color_notebook_ok_callback (GtkWidget *w, - gpointer client_data) +color_notebook_ok_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->values[RED], @@ -326,25 +299,13 @@ color_notebook_ok_callback (GtkWidget *w, cnp->client_data); } - -static gint -color_notebook_delete_callback (GtkWidget *w, - GdkEvent *e, - gpointer client_data) -{ - color_notebook_cancel_callback (w, client_data); - - return TRUE; -} - - static void -color_notebook_cancel_callback (GtkWidget *w, - gpointer client_data) +color_notebook_cancel_callback (GtkWidget *widget, + gpointer data) { ColorNotebookP cnp; - cnp = (ColorNotebookP) client_data; + cnp = (ColorNotebookP) data; if (cnp->callback) (* cnp->callback) (cnp->orig_values[RED], @@ -355,14 +316,14 @@ color_notebook_cancel_callback (GtkWidget *w, } static void -color_notebook_page_switch (GtkWidget *w, +color_notebook_page_switch (GtkWidget *widget, GtkNotebookPage *page, guint page_num) { ColorNotebookP cnp; ColorSelectorInstance *csel; - cnp = gtk_object_get_user_data (GTK_OBJECT (w)); + cnp = gtk_object_get_user_data (GTK_OBJECT (widget)); csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook"); g_return_if_fail (cnp != NULL && csel != NULL); @@ -466,5 +427,4 @@ selector_death (ColorSelectorInfo *info) g_warning ("color selector %p not found, can't happen!", info); } - /* End of color_notebook.c */ diff --git a/app/widgets/gimpcolordisplayeditor.c b/app/widgets/gimpcolordisplayeditor.c index 8a95e96136..3e85750e10 100644 --- a/app/widgets/gimpcolordisplayeditor.c +++ b/app/widgets/gimpcolordisplayeditor.c @@ -15,12 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "actionarea.h" #include "gdisplay.h" #include "gdisplay_color.h" #include "gdisplay_color_ui.h" #include "gimpimageP.h" +#include "gimpui.h" #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" #include @@ -48,7 +47,6 @@ struct _ButtonInfo static void color_display_ok_callback (GtkWidget *, gpointer); static void color_display_cancel_callback (GtkWidget *, gpointer); -static gint color_display_delete_callback (GtkWidget *, gpointer); static gint color_display_destroy_callback (GtkWidget *, gpointer); static void color_display_add_callback (GtkWidget *, gpointer); static void color_display_remove_callback (GtkWidget *, gpointer); @@ -68,12 +66,6 @@ make_dialog (void) char *titles[2]; int i; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_display_ok_callback, NULL, NULL }, - { N_("Cancel"), color_display_cancel_callback, NULL, NULL } - }; - static ButtonInfo buttons[] = { { N_("Add"), color_display_add_callback }, @@ -83,13 +75,18 @@ make_dialog (void) { N_("Configure"), color_display_configure_callback } }; - cdd.shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (cdd.shell), "display_color", "Gimp"); - gtk_window_set_title (GTK_WINDOW (cdd.shell), _("Color Display Filters")); + cdd.shell = gimp_dialog_new (_("Color Display Filters"), "display_color", + gimp_standard_help_func, + "dialogs/color_diaplsy_filters_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - gtk_signal_connect (GTK_OBJECT (cdd.shell), "delete_event", - GTK_SIGNAL_FUNC (color_display_delete_callback), - NULL); + _("OK"), color_display_ok_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), color_display_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); hbox = gtk_hbox_new (FALSE, 4); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cdd.shell)->vbox), hbox, @@ -139,10 +136,6 @@ make_dialog (void) } gtk_widget_show_all (hbox); - - action_items[0].user_data = cdd.shell; - action_items[1].user_data = cdd.shell; - build_action_area (GTK_DIALOG (cdd.shell), action_items, 2, 0); } static void @@ -159,14 +152,6 @@ color_display_cancel_callback (GtkWidget *widget, gtk_widget_hide (GTK_WIDGET (data)); } -static gint -color_display_delete_callback (GtkWidget *widget, - gpointer data) -{ - color_display_cancel_callback (widget, data); - return TRUE; -} - static gint color_display_destroy_callback (GtkWidget *widget, gpointer data) diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c index 9faa2b0ea4..4ca834935d 100644 --- a/app/widgets/gimpdeviceinfo.c +++ b/app/widgets/gimpdeviceinfo.c @@ -15,19 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "config.h" #include #include #include "appenv.h" -#include "actionarea.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "devices.h" #include "interface.h" #include "gimprc.h" +#include "gimpui.h" #include "palette.h" #include "session.h" #include "tools.h" @@ -63,7 +62,7 @@ struct _DeviceInfo { GimpBrushP brush; GPatternP pattern; ToolType tool; - unsigned char foreground[3]; + guchar foreground[3]; }; typedef struct _DeviceInfoDialog DeviceInfoDialog; @@ -115,13 +114,6 @@ static void device_status_drop_pattern (GtkWidget *, /* Global data */ int current_device = GDK_CORE_POINTER; -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Save"), (ActionCallback)devices_write_rc, NULL, NULL }, - { N_("Close"), devices_close_callback, NULL, NULL } -}; - /* dnd stuff */ static GtkTargetEntry color_area_target_table[] = { @@ -151,17 +143,17 @@ create_input_dialog (void) if (!inputd) { - inputd = gtk_input_dialog_new(); + inputd = gtk_input_dialog_new (); /* register this one only */ - dialog_register(inputd); + dialog_register (inputd); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area), FALSE); - hbbox = gtk_hbutton_box_new(); - gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbbox), 4); + hbbox = gtk_hbutton_box_new (); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox); GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button, @@ -170,46 +162,52 @@ create_input_dialog (void) GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button, GTK_CAN_DEFAULT); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, - FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, + FALSE, FALSE, 0); gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button); gtk_widget_show(hbbox); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button), + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button), "clicked", - GTK_SIGNAL_FUNC(devices_write_rc), NULL); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), + GTK_SIGNAL_FUNC (devices_write_rc), NULL); + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button), "clicked", - GTK_SIGNAL_FUNC(devices_close_callback), inputd); + GTK_SIGNAL_FUNC (devices_close_callback), inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "destroy", - (GtkSignalFunc)input_dialog_destroy_callback, + gtk_signal_connect (GTK_OBJECT (inputd), "destroy", + (GtkSignalFunc) input_dialog_destroy_callback, &inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "enable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); - gtk_signal_connect (GTK_OBJECT(inputd), "disable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "enable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "disable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (inputd, + gimp_standard_help_func, + "dialogs/input_devices_dialog.html"); + gtk_widget_show (inputd); } else { - if (!GTK_WIDGET_MAPPED(inputd)) - gtk_widget_show(inputd); + if (!GTK_WIDGET_MAPPED (inputd)) + gtk_widget_show (inputd); else - gdk_window_raise(inputd->window); + gdk_window_raise (inputd->window); } } void -input_dialog_able_callback (GtkWidget *w, - guint32 deviceid, +input_dialog_able_callback (GtkWidget *widget, + guint32 deviceid, gpointer data) { device_status_update (deviceid); } static void -input_dialog_destroy_callback (GtkWidget *w, +input_dialog_destroy_callback (GtkWidget *widget, gpointer call_data) { *((GtkWidget **)call_data) = NULL; @@ -223,7 +221,7 @@ devices_init (void) /* Create device info structures for present devices */ tmp_list = gdk_input_list_devices (); - + while (tmp_list) { GdkDeviceInfo *gdk_info = (GdkDeviceInfo *)tmp_list->data; @@ -528,7 +526,7 @@ devices_save_current_info (void) device_info->is_init = TRUE; device_info->device = current_device; device_info->brush = get_active_brush (); - device_info->pattern = get_active_pattern(); + device_info->pattern = get_active_pattern (); if (active_tool) device_info->tool = active_tool->type; else @@ -539,7 +537,7 @@ devices_save_current_info (void) } static void -devices_write_rc_device (DeviceInfo *device_info, +devices_write_rc_device (DeviceInfo *device_info, FILE *fp) { GdkDeviceInfo *gdk_info; @@ -552,7 +550,7 @@ devices_write_rc_device (DeviceInfo *device_info, { /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ - tmp_list = gdk_input_list_devices(); + tmp_list = gdk_input_list_devices (); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; @@ -566,7 +564,7 @@ devices_write_rc_device (DeviceInfo *device_info, } } - fprintf(fp, "(device \"%s\"",device_info->name); + fprintf (fp, "(device \"%s\"",device_info->name); switch (gdk_info ? gdk_info->mode : device_info->mode) { @@ -581,9 +579,10 @@ devices_write_rc_device (DeviceInfo *device_info, break; } - fprintf(fp, "\n (mode %s)",mode); + fprintf (fp, "\n (mode %s)", mode); - fprintf(fp, "\n (axes %d",gdk_info ? gdk_info->num_axes : device_info->num_axes); + fprintf (fp, "\n (axes %d", + gdk_info ? gdk_info->num_axes : device_info->num_axes); for (i=0; i<(gdk_info ? gdk_info->num_axes : device_info->num_axes); i++) { @@ -615,19 +614,20 @@ devices_write_rc_device (DeviceInfo *device_info, break; #endif /* GTK_HAVE_SIX_VALUATORS */ } - fprintf(fp, " %s",axis_type); + fprintf (fp, " %s",axis_type); } - fprintf(fp,")"); + fprintf (fp,")"); - fprintf(fp, "\n (keys %d", gdk_info ? gdk_info->num_keys : device_info->num_keys); + fprintf (fp, "\n (keys %d", + gdk_info ? gdk_info->num_keys : device_info->num_keys); - for (i=0; i<(gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) + for (i=0; i < (gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) { GdkModifierType modifiers = gdk_info ? gdk_info->keys[i].modifiers : device_info->keys[i].modifiers; guint keyval = gdk_info ? gdk_info->keys[i].keyval : device_info->keys[i].keyval; - + if (keyval) { /* FIXME: integrate this back with menus_install_accelerator */ @@ -650,22 +650,22 @@ devices_write_rc_device (DeviceInfo *device_info, else fprintf (fp, " \"\""); } - fprintf(fp,")"); + fprintf (fp,")"); if (device_info->is_init) { if (device_info->brush) - fprintf(fp, "\n (brush \"%s\")",device_info->brush->name); + fprintf (fp, "\n (brush \"%s\")",device_info->brush->name); if (device_info->pattern) - fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name); + fprintf (fp, "\n (pattern \"%s\")",device_info->pattern->name); /* Fixme: hard coded last tool.... see gimprc */ if (device_info->tool && device_info->tool <= LAST_TOOLBOX_TOOL) - fprintf(fp, "\n (tool \"%s\")", - tool_info[device_info->tool].tool_name); - fprintf(fp, "\n (foreground %d %d %d)", - device_info->foreground[0], - device_info->foreground[1], - device_info->foreground[2]); + fprintf (fp, "\n (tool \"%s\")", + tool_info[device_info->tool].tool_name); + fprintf (fp, "\n (foreground %d %d %d)", + device_info->foreground[0], + device_info->foreground[1], + device_info->foreground[2]); } fprintf(fp,")\n"); @@ -702,18 +702,25 @@ create_device_status (void) if (deviceD == NULL) { deviceD = g_new (DeviceInfoDialog, 1); - deviceD->shell = gtk_dialog_new (); + + deviceD->shell = + gimp_dialog_new (_("Device Status"), "device_status", + gimp_standard_help_func, + "dialogs/device_status_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, TRUE, + + _("Save"), (GtkSignalFunc) devices_write_rc, + NULL, NULL, FALSE, FALSE, + _("Close"), devices_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* register this one only */ - dialog_register(deviceD->shell); - - gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status")); - gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE); - /* don't set the dialog's size, as the number of devices may have - * changed since the last session - */ - session_set_window_geometry (deviceD->shell, - &device_status_session_info, FALSE); + dialog_register (deviceD->shell); + session_set_window_geometry (deviceD->shell, &device_status_session_info, + FALSE); deviceD->num_devices = 0; tmp_list = devices_info; @@ -723,10 +730,10 @@ create_device_status (void) deviceD->num_devices++; tmp_list = tmp_list->next; } -/* devices table */ + /* devices table */ deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE); - gtk_container_set_border_width (GTK_CONTAINER(deviceD->table), 3); - gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox), + gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox), deviceD->table); gtk_widget_realize (deviceD->table); gtk_widget_show (deviceD->table); @@ -841,9 +848,6 @@ create_device_status (void) i++; } - action_items[1].user_data = deviceD->shell; - build_action_area (GTK_DIALOG (deviceD->shell), action_items, 2, 1); - deviceD->current = 0xffffffff; /* random, but doesn't matter */ device_status_update_current (); @@ -878,7 +882,7 @@ device_status_destroy_callback (void) } static void -devices_close_callback (GtkWidget *w, +devices_close_callback (GtkWidget *widget, gpointer data) { gtk_widget_hide (GTK_WIDGET(data)); diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c index 9faa2b0ea4..4ca834935d 100644 --- a/app/widgets/gimpdevices.c +++ b/app/widgets/gimpdevices.c @@ -15,19 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "config.h" #include #include #include "appenv.h" -#include "actionarea.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "devices.h" #include "interface.h" #include "gimprc.h" +#include "gimpui.h" #include "palette.h" #include "session.h" #include "tools.h" @@ -63,7 +62,7 @@ struct _DeviceInfo { GimpBrushP brush; GPatternP pattern; ToolType tool; - unsigned char foreground[3]; + guchar foreground[3]; }; typedef struct _DeviceInfoDialog DeviceInfoDialog; @@ -115,13 +114,6 @@ static void device_status_drop_pattern (GtkWidget *, /* Global data */ int current_device = GDK_CORE_POINTER; -/* the action area structure */ -static ActionAreaItem action_items[] = -{ - { N_("Save"), (ActionCallback)devices_write_rc, NULL, NULL }, - { N_("Close"), devices_close_callback, NULL, NULL } -}; - /* dnd stuff */ static GtkTargetEntry color_area_target_table[] = { @@ -151,17 +143,17 @@ create_input_dialog (void) if (!inputd) { - inputd = gtk_input_dialog_new(); + inputd = gtk_input_dialog_new (); /* register this one only */ - dialog_register(inputd); + dialog_register (inputd); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (inputd)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area), FALSE); - hbbox = gtk_hbutton_box_new(); - gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbbox), 4); + hbbox = gtk_hbutton_box_new (); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox); GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button, @@ -170,46 +162,52 @@ create_input_dialog (void) GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button, GTK_CAN_DEFAULT); - gtk_box_pack_end(GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, - FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox, + FALSE, FALSE, 0); gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button); gtk_widget_show(hbbox); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button), + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->save_button), "clicked", - GTK_SIGNAL_FUNC(devices_write_rc), NULL); - gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), + GTK_SIGNAL_FUNC (devices_write_rc), NULL); + gtk_signal_connect (GTK_OBJECT (GTK_INPUT_DIALOG (inputd)->close_button), "clicked", - GTK_SIGNAL_FUNC(devices_close_callback), inputd); + GTK_SIGNAL_FUNC (devices_close_callback), inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "destroy", - (GtkSignalFunc)input_dialog_destroy_callback, + gtk_signal_connect (GTK_OBJECT (inputd), "destroy", + (GtkSignalFunc) input_dialog_destroy_callback, &inputd); - gtk_signal_connect (GTK_OBJECT(inputd), "enable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); - gtk_signal_connect (GTK_OBJECT(inputd), "disable_device", - GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "enable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + gtk_signal_connect (GTK_OBJECT (inputd), "disable_device", + GTK_SIGNAL_FUNC (input_dialog_able_callback), NULL); + + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (inputd, + gimp_standard_help_func, + "dialogs/input_devices_dialog.html"); + gtk_widget_show (inputd); } else { - if (!GTK_WIDGET_MAPPED(inputd)) - gtk_widget_show(inputd); + if (!GTK_WIDGET_MAPPED (inputd)) + gtk_widget_show (inputd); else - gdk_window_raise(inputd->window); + gdk_window_raise (inputd->window); } } void -input_dialog_able_callback (GtkWidget *w, - guint32 deviceid, +input_dialog_able_callback (GtkWidget *widget, + guint32 deviceid, gpointer data) { device_status_update (deviceid); } static void -input_dialog_destroy_callback (GtkWidget *w, +input_dialog_destroy_callback (GtkWidget *widget, gpointer call_data) { *((GtkWidget **)call_data) = NULL; @@ -223,7 +221,7 @@ devices_init (void) /* Create device info structures for present devices */ tmp_list = gdk_input_list_devices (); - + while (tmp_list) { GdkDeviceInfo *gdk_info = (GdkDeviceInfo *)tmp_list->data; @@ -528,7 +526,7 @@ devices_save_current_info (void) device_info->is_init = TRUE; device_info->device = current_device; device_info->brush = get_active_brush (); - device_info->pattern = get_active_pattern(); + device_info->pattern = get_active_pattern (); if (active_tool) device_info->tool = active_tool->type; else @@ -539,7 +537,7 @@ devices_save_current_info (void) } static void -devices_write_rc_device (DeviceInfo *device_info, +devices_write_rc_device (DeviceInfo *device_info, FILE *fp) { GdkDeviceInfo *gdk_info; @@ -552,7 +550,7 @@ devices_write_rc_device (DeviceInfo *device_info, { /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ - tmp_list = gdk_input_list_devices(); + tmp_list = gdk_input_list_devices (); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; @@ -566,7 +564,7 @@ devices_write_rc_device (DeviceInfo *device_info, } } - fprintf(fp, "(device \"%s\"",device_info->name); + fprintf (fp, "(device \"%s\"",device_info->name); switch (gdk_info ? gdk_info->mode : device_info->mode) { @@ -581,9 +579,10 @@ devices_write_rc_device (DeviceInfo *device_info, break; } - fprintf(fp, "\n (mode %s)",mode); + fprintf (fp, "\n (mode %s)", mode); - fprintf(fp, "\n (axes %d",gdk_info ? gdk_info->num_axes : device_info->num_axes); + fprintf (fp, "\n (axes %d", + gdk_info ? gdk_info->num_axes : device_info->num_axes); for (i=0; i<(gdk_info ? gdk_info->num_axes : device_info->num_axes); i++) { @@ -615,19 +614,20 @@ devices_write_rc_device (DeviceInfo *device_info, break; #endif /* GTK_HAVE_SIX_VALUATORS */ } - fprintf(fp, " %s",axis_type); + fprintf (fp, " %s",axis_type); } - fprintf(fp,")"); + fprintf (fp,")"); - fprintf(fp, "\n (keys %d", gdk_info ? gdk_info->num_keys : device_info->num_keys); + fprintf (fp, "\n (keys %d", + gdk_info ? gdk_info->num_keys : device_info->num_keys); - for (i=0; i<(gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) + for (i=0; i < (gdk_info ? gdk_info->num_keys : device_info->num_keys); i++) { GdkModifierType modifiers = gdk_info ? gdk_info->keys[i].modifiers : device_info->keys[i].modifiers; guint keyval = gdk_info ? gdk_info->keys[i].keyval : device_info->keys[i].keyval; - + if (keyval) { /* FIXME: integrate this back with menus_install_accelerator */ @@ -650,22 +650,22 @@ devices_write_rc_device (DeviceInfo *device_info, else fprintf (fp, " \"\""); } - fprintf(fp,")"); + fprintf (fp,")"); if (device_info->is_init) { if (device_info->brush) - fprintf(fp, "\n (brush \"%s\")",device_info->brush->name); + fprintf (fp, "\n (brush \"%s\")",device_info->brush->name); if (device_info->pattern) - fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name); + fprintf (fp, "\n (pattern \"%s\")",device_info->pattern->name); /* Fixme: hard coded last tool.... see gimprc */ if (device_info->tool && device_info->tool <= LAST_TOOLBOX_TOOL) - fprintf(fp, "\n (tool \"%s\")", - tool_info[device_info->tool].tool_name); - fprintf(fp, "\n (foreground %d %d %d)", - device_info->foreground[0], - device_info->foreground[1], - device_info->foreground[2]); + fprintf (fp, "\n (tool \"%s\")", + tool_info[device_info->tool].tool_name); + fprintf (fp, "\n (foreground %d %d %d)", + device_info->foreground[0], + device_info->foreground[1], + device_info->foreground[2]); } fprintf(fp,")\n"); @@ -702,18 +702,25 @@ create_device_status (void) if (deviceD == NULL) { deviceD = g_new (DeviceInfoDialog, 1); - deviceD->shell = gtk_dialog_new (); + + deviceD->shell = + gimp_dialog_new (_("Device Status"), "device_status", + gimp_standard_help_func, + "dialogs/device_status_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, TRUE, + + _("Save"), (GtkSignalFunc) devices_write_rc, + NULL, NULL, FALSE, FALSE, + _("Close"), devices_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* register this one only */ - dialog_register(deviceD->shell); - - gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status")); - gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE); - /* don't set the dialog's size, as the number of devices may have - * changed since the last session - */ - session_set_window_geometry (deviceD->shell, - &device_status_session_info, FALSE); + dialog_register (deviceD->shell); + session_set_window_geometry (deviceD->shell, &device_status_session_info, + FALSE); deviceD->num_devices = 0; tmp_list = devices_info; @@ -723,10 +730,10 @@ create_device_status (void) deviceD->num_devices++; tmp_list = tmp_list->next; } -/* devices table */ + /* devices table */ deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE); - gtk_container_set_border_width (GTK_CONTAINER(deviceD->table), 3); - gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox), + gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox), deviceD->table); gtk_widget_realize (deviceD->table); gtk_widget_show (deviceD->table); @@ -841,9 +848,6 @@ create_device_status (void) i++; } - action_items[1].user_data = deviceD->shell; - build_action_area (GTK_DIALOG (deviceD->shell), action_items, 2, 1); - deviceD->current = 0xffffffff; /* random, but doesn't matter */ device_status_update_current (); @@ -878,7 +882,7 @@ device_status_destroy_callback (void) } static void -devices_close_callback (GtkWidget *w, +devices_close_callback (GtkWidget *widget, gpointer data) { gtk_widget_hide (GTK_WIDGET(data)); diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c index c5c8a84b84..0274f668a0 100644 --- a/app/widgets/gimpgradienteditor.c +++ b/app/widgets/gimpgradienteditor.c @@ -150,7 +150,6 @@ #include #endif -#include "actionarea.h" #include "appenv.h" #include "colormaps.h" #include "cursorutil.h" @@ -158,8 +157,8 @@ #include "errors.h" #include "general.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "session.h" #include "gradient_header.h" @@ -209,8 +208,6 @@ static void ed_do_copy_gradient_callback (GtkWidget *, gpointer , gpointer); static void ed_delete_gradient_callback (GtkWidget *, gpointer); static void ed_do_delete_gradient_callback (GtkWidget *, gpointer); static void ed_cancel_delete_gradient_callback (GtkWidget *, gpointer); -static gint ed_delete_delete_gradient_callback (GtkWidget *, GdkEvent *, - gpointer); static void ed_rename_gradient_callback (GtkWidget *, gpointer); static void ed_do_rename_gradient_callback (GtkWidget *, gpointer, gpointer); @@ -222,8 +219,6 @@ static gint ed_delete_save_pov_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_save_grads_callback (GtkWidget *, gpointer); static void ed_refresh_grads_callback (GtkWidget *, gpointer); - -static gint ed_delete_callback (GtkWidget *, GdkEvent *, gpointer); static void ed_close_callback (GtkWidget *, gpointer); /* Zoom, scrollbar & instant update callbacks */ @@ -248,27 +243,29 @@ static void prev_fill_image (int width, int height, /* Gradient control functions */ -static gint control_events (GtkWidget *, GdkEvent *, gpointer); -static void control_do_hint (gint x, gint y); -static void control_button_press (gint x, gint y, - guint button, guint state); -static int control_point_in_handle (gint x, gint y, grad_segment_t *seg, - control_drag_mode_t handle); -static void control_select_single_segment (grad_segment_t *seg); -static void control_extend_selection (grad_segment_t *seg, double pos); -static void control_motion (gint x); +static gint control_events (GtkWidget *, GdkEvent *, + gpointer); +static void control_do_hint (gint x, gint y); +static void control_button_press (gint x, gint y, + guint button, guint state); +static gboolean control_point_in_handle (gint x, gint y, + grad_segment_t *seg, + control_drag_mode_t handle); +static void control_select_single_segment (grad_segment_t *seg); +static void control_extend_selection (grad_segment_t *seg, double pos); +static void control_motion (gint x); -static void control_compress_left (grad_segment_t *range_l, - grad_segment_t *range_r, - grad_segment_t *drag_seg, +static void control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, double pos); -static void control_compress_range (grad_segment_t *range_l, - grad_segment_t *range_r, - double new_l, double new_r); +static void control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, double new_r); -static double control_move (grad_segment_t *range_l, - grad_segment_t *range_r, - double delta); +static double control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta); /* Control update/redraw functions */ @@ -379,8 +376,6 @@ static void cpopup_split_uniform_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_scale_update (GtkAdjustment *, gpointer); static void cpopup_split_uniform_split_callback (GtkWidget *, gpointer); static void cpopup_split_uniform_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_split_uniform_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_split_uniform (grad_segment_t *lseg, int parts, grad_segment_t **newl, grad_segment_t **newr); @@ -398,8 +393,6 @@ static void cpopup_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_scale_update (GtkAdjustment *, gpointer); static void cpopup_do_replicate_callback (GtkWidget *, gpointer); static void cpopup_replicate_cancel_callback (GtkWidget *, gpointer); -static gint cpopup_replicate_delete_callback (GtkWidget *, GdkEvent *, - gpointer); static void cpopup_blend_colors (GtkWidget *, gpointer); static void cpopup_blend_opacity (GtkWidget *, gpointer); @@ -668,13 +661,6 @@ grad_create_gradient_editor_init (gint need_show) gint i; gint select_pos; - static ActionAreaItem action_items[] = - { - { N_("Save"), ed_save_grads_callback, NULL, NULL }, - { N_("Refresh"), ed_refresh_grads_callback, NULL, NULL }, - { N_("Close"), ed_close_callback, NULL, NULL } - }; - /* If the editor already exists, just show it */ if (g_editor) { @@ -698,15 +684,20 @@ grad_create_gradient_editor_init (gint need_show) g_editor = g_new (gradient_editor_t, 1); /* Shell and main vbox */ - g_editor->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_editor", "Gimp"); - gtk_window_set_title (GTK_WINDOW (g_editor->shell), _("Gradient Editor")); + g_editor->shell = gimp_dialog_new (_("Gradient Editor"), "gradient_editor", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_callback), - NULL); + _("Save"), ed_save_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Refresh"), ed_refresh_grads_callback, + NULL, NULL, FALSE, FALSE, + _("Close"), ed_close_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); @@ -881,7 +872,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (gvbox); /* Gradient preview */ - g_editor->preview_rows[0] = NULL; g_editor->preview_rows[1] = NULL; g_editor->preview_last_x = 0; @@ -905,7 +895,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_widget_show (g_editor->preview); /* Gradient control */ - g_editor->control_pixmap = NULL; g_editor->control_drag_segment = NULL; g_editor->control_sel_l = NULL; @@ -967,9 +956,6 @@ grad_create_gradient_editor_init (gint need_show) gtk_box_pack_start (GTK_BOX (vbox), g_editor->hint_label, FALSE, FALSE, 0); gtk_widget_show (g_editor->hint_label); - /* The action area */ - build_action_area (GTK_DIALOG (g_editor->shell), action_items, 3, 2); - /* Initialize other data */ g_editor->left_color_preview = NULL; g_editor->left_saved_segments = NULL; @@ -995,11 +981,8 @@ grad_create_gradient_editor_init (gint need_show) gtk_clist_moveto (GTK_CLIST (g_editor->clist), select_pos, 0, 0.0, 0.0); } - /***** Gradient editor functions *****/ -/*****/ - static void ed_fetch_foreground (double *fg_r, double *fg_g, double *fg_b, double *fg_a) { @@ -1319,17 +1302,20 @@ ed_initialize_saved_colors(void) /***** the "new gradient" dialog functions *****/ -/*****/ - static void ed_new_gradient_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box(_("New gradient"), - _("Enter a name for the new gradient"), - _("untitled"), - NULL, NULL, - ed_do_new_gradient_callback, NULL)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the new gradient"), + _("untitled"), + NULL, NULL, + ed_do_new_gradient_callback, NULL); + gtk_widget_show (qbox); } static void @@ -1373,12 +1359,11 @@ ed_do_new_gradient_callback (GtkWidget *widget, /***** The "copy gradient" dialog functions *****/ -/*****/ - static void ed_copy_gradient_callback (GtkWidget *widget, gpointer data) { + GtkWidget *qbox; gchar *name; if (curr_gradient == NULL) @@ -1386,13 +1371,16 @@ ed_copy_gradient_callback (GtkWidget *widget, name = g_strdup_printf (_("%s copy"), curr_gradient->name); - gtk_widget_show (query_string_box (_("Copy gradient"), - _("Enter a name for the copied gradient"), - name, - NULL, NULL, - ed_do_copy_gradient_callback, NULL)); + qbox = gimp_query_string_box (_("Copy gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a name for the copied gradient"), + name, + NULL, NULL, + ed_do_copy_gradient_callback, NULL); + gtk_widget_show (qbox); - g_free(name); + g_free (name); } static void @@ -1460,21 +1448,24 @@ ed_do_copy_gradient_callback (GtkWidget *widget, /***** The "rename gradient" dialog functions *****/ -/*****/ - static void ed_rename_gradient_callback (GtkWidget *widget, - gpointer data) + gpointer data) { + GtkWidget *qbox; + if (curr_gradient == NULL) return; - gtk_widget_show (query_string_box (_("Rename gradient"), - _("Enter a new name for the gradient"), - curr_gradient->name, - NULL, NULL, - ed_do_rename_gradient_callback, - curr_gradient)); + qbox = gimp_query_string_box (_("Rename gradient"), + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + _("Enter a new name for the gradient"), + curr_gradient->name, + NULL, NULL, + ed_do_rename_gradient_callback, + curr_gradient); + gtk_widget_show (qbox); } static void @@ -1536,8 +1527,6 @@ ed_do_rename_gradient_callback (GtkWidget *widget, /***** The "delete gradient" dialog functions *****/ -/*****/ - static void ed_delete_gradient_callback (GtkWidget *widget, gpointer data) @@ -1547,24 +1536,21 @@ ed_delete_gradient_callback (GtkWidget *widget, GtkWidget *label; gchar *str; - static ActionAreaItem action_items[] = - { - { N_("Delete"), ed_do_delete_gradient_callback, NULL, NULL }, - { N_("Cancel"), ed_cancel_delete_gradient_callback, NULL, NULL } - }; - if (num_gradients <= 1) return; - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "delete_gradient", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Delete gradient")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = gimp_dialog_new (_("Delete gradient"), "delete_gradient", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (ed_delete_delete_gradient_callback), - dialog); + _("Delete"), ed_do_delete_gradient_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), ed_cancel_delete_gradient_callback, + NULL, NULL, TRUE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 2); @@ -1572,9 +1558,9 @@ ed_delete_gradient_callback (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); gtk_widget_show (vbox); - str = g_strdup_printf(_("Are you sure you want to delete\n" - "\"%s\" from the list and from disk?"), - curr_gradient->name); + str = g_strdup_printf (_("Are you sure you want to delete\n" + "\"%s\" from the list and from disk?"), + curr_gradient->name); label = gtk_label_new (str); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); @@ -1582,11 +1568,6 @@ ed_delete_gradient_callback (GtkWidget *widget, g_free (str); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1658,20 +1639,8 @@ ed_cancel_delete_gradient_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -ed_delete_delete_gradient_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_cancel_delete_gradient_callback (widget, data); - - return TRUE; -} - /***** The "save as pov" dialog functions *****/ -/*****/ - static void ed_save_pov_callback (GtkWidget *widget, gpointer data) @@ -1682,7 +1651,7 @@ ed_save_pov_callback (GtkWidget *widget, return; window = gtk_file_selection_new (_("Save as POV-Ray")); - gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); + gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button), "clicked", (GtkSignalFunc) ed_do_save_pov_callback, @@ -1696,6 +1665,10 @@ ed_save_pov_callback (GtkWidget *widget, (GdkEventFunc) ed_delete_save_pov_callback, window); + /* Connect the "F1" help key */ + gimp_help_connect_help_accel (window, gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html"); + gtk_widget_show (window); gtk_widget_set_sensitive (g_editor->shell, FALSE); } @@ -1771,8 +1744,6 @@ ed_delete_save_pov_callback (GtkWidget *widget, /***** The main dialog action area button callbacks *****/ -/*****/ - static void ed_save_grads_callback (GtkWidget *widget, gpointer data) @@ -1815,20 +1786,8 @@ ed_close_callback (GtkWidget *widget, gtk_widget_hide (g_editor->shell); } -static gint -ed_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - ed_close_callback (widget, data); - - return TRUE; -} - /***** Zoom, scrollbar & instant update callbacks *****/ -/*****/ - static void ed_scrollbar_update (GtkAdjustment *adjustment, gpointer data) @@ -1942,8 +1901,6 @@ ed_instant_update_update (GtkWidget *widget, /***** Gradient preview functions *****/ -/*****/ - static gint prev_events (GtkWidget *widget, GdkEvent *event, @@ -2103,7 +2060,7 @@ prev_set_foreground (gint x) palette_set_foreground (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Foreground color set to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2126,7 +2083,7 @@ prev_set_background (gint x) palette_set_background (r * 255.0, g * 255.0, b * 255.0); - g_snprintf (str, sizeof(str), + g_snprintf (str, sizeof (str), _("Background color to RGB (%d, %d, %d) <-> " "(%0.3f, %0.3f, %0.3f)"), (int) (r * 255.0), @@ -2229,54 +2186,58 @@ prev_update (gboolean recalculate) /*****/ static void -prev_fill_image(int width, int height, double left, double right) +prev_fill_image (int width, + int height, + double left, + double right) { - guchar *p0, *p1; - int x, y; - double dx, cur_x; - double r, g, b, a; - double c0, c1; + guchar *p0, *p1; + int x, y; + double dx, cur_x; + double r, g, b, a; + double c0, c1; - dx = (right - left) / (width - 1); - cur_x = left; - p0 = g_editor->preview_rows[0]; - p1 = g_editor->preview_rows[1]; + dx = (right - left) / (width - 1); + cur_x = left; + p0 = g_editor->preview_rows[0]; + p1 = g_editor->preview_rows[1]; - /* Create lines to fill the image */ + /* Create lines to fill the image */ + for (x = 0; x < width; x++) + { + grad_get_color_at (cur_x, &r, &g, &b, &a); - for (x = 0; x < width; x++) { - grad_get_color_at(cur_x, &r, &g, &b, &a); + if ((x / GRAD_CHECK_SIZE) & 1) + { + c0 = GRAD_CHECK_LIGHT; + c1 = GRAD_CHECK_DARK; + } + else + { + c0 = GRAD_CHECK_DARK; + c1 = GRAD_CHECK_LIGHT; + } - if ((x / GRAD_CHECK_SIZE) & 1) { - c0 = GRAD_CHECK_LIGHT; - c1 = GRAD_CHECK_DARK; - } else { - c0 = GRAD_CHECK_DARK; - c1 = GRAD_CHECK_LIGHT; - } /* else */ + *p0++ = (c0 + (r - c0) * a) * 255.0; + *p0++ = (c0 + (g - c0) * a) * 255.0; + *p0++ = (c0 + (b - c0) * a) * 255.0; - *p0++ = (c0 + (r - c0) * a) * 255.0; - *p0++ = (c0 + (g - c0) * a) * 255.0; - *p0++ = (c0 + (b - c0) * a) * 255.0; + *p1++ = (c1 + (r - c1) * a) * 255.0; + *p1++ = (c1 + (g - c1) * a) * 255.0; + *p1++ = (c1 + (b - c1) * a) * 255.0; - *p1++ = (c1 + (r - c1) * a) * 255.0; - *p1++ = (c1 + (g - c1) * a) * 255.0; - *p1++ = (c1 + (b - c1) * a) * 255.0; - - cur_x += dx; - } /* for */ - - /* Fill image */ - - for (y = 0; y < height; y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[1], 0, y, width); - else - gtk_preview_draw_row(GTK_PREVIEW(g_editor->preview), - g_editor->preview_rows[0], 0, y, width); -} /* prev_fill_image */ + cur_x += dx; + } + /* Fill image */ + for (y = 0; y < height; y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[1], 0, y, width); + else + gtk_preview_draw_row (GTK_PREVIEW (g_editor->preview), + g_editor->preview_rows[0], 0, y, width); +} /***** Gradient control functions *****/ @@ -2288,8 +2249,6 @@ prev_fill_image(int width, int height, double left, double right) * them yourself ;-) */ -/*****/ - static gint control_events (GtkWidget *widget, GdkEvent *event, @@ -2395,51 +2354,56 @@ control_events (GtkWidget *widget, /*****/ static void -control_do_hint(gint x, gint y) +control_do_hint (gint x, + gint y) { - grad_segment_t *seg; - control_drag_mode_t handle; - int in_handle; - double pos; + grad_segment_t *seg; + control_drag_mode_t handle; + gboolean in_handle; + double pos; - pos = control_calc_g_pos(x); + pos = control_calc_g_pos (x); - if ((pos < 0.0) || (pos > 1.0)) - return; + if ((pos < 0.0) || (pos > 1.0)) + return; - seg_get_closest_handle(curr_gradient, pos, &seg, &handle); + seg_get_closest_handle (curr_gradient, pos, &seg, &handle); - in_handle = control_point_in_handle(x, y, seg, handle); + in_handle = control_point_in_handle (x, y, seg, handle); - if (in_handle) { - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg != NULL) { - if (seg->prev != NULL) - ed_set_hint(_("Drag: move Shift+drag: move & compress")); - else - ed_set_hint(_("Click: select Shift+click: extend selection")); - } else - ed_set_hint(_("Click: select Shift+click: extend selection")); + if (in_handle) + { + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg != NULL) + { + if (seg->prev != NULL) + ed_set_hint (_("Drag: move Shift+drag: move & compress")); + else + ed_set_hint (_("Click: select Shift+click: extend selection")); + } + else + ed_set_hint (_("Click: select Shift+click: extend selection")); - break; + break; - case GRAD_DRAG_MIDDLE: - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move")); + case GRAD_DRAG_MIDDLE: + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move")); - break; - - default: - g_message ("control_do_hint: oops, in_handle is true " - "yet we got handle type %d", (int) handle); - break; - } /* switch */ - } else - ed_set_hint(_("Click: select Shift+click: extend selection " - "Drag: move Shift+drag: move & compress")); -} /* control_do_hint */ + break; + default: + g_message ("control_do_hint: oops, in_handle is true " + "yet we got handle type %d", (int) handle); + break; + } + } + else + ed_set_hint (_("Click: select Shift+click: extend selection " + "Drag: move Shift+drag: move & compress")); +} /*****/ @@ -2452,7 +2416,7 @@ control_button_press (gint x, grad_segment_t *seg; control_drag_mode_t handle; double xpos; - gint in_handle; + gboolean in_handle; /* See which button was pressed */ @@ -2592,343 +2556,370 @@ control_button_press (gint x, /*****/ -static int -control_point_in_handle(gint x, gint y, grad_segment_t *seg, control_drag_mode_t handle) +static gboolean +control_point_in_handle (gint x, + gint y, + grad_segment_t *seg, + control_drag_mode_t handle) { - gint handle_pos; + gint handle_pos; - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - handle_pos = control_calc_p_pos(seg->left); - else { - seg = seg_get_last_segment(curr_gradient->segments); + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + handle_pos = control_calc_p_pos (seg->left); + else + { + seg = seg_get_last_segment (curr_gradient->segments); - handle_pos = control_calc_p_pos(seg->right); - } /* else */ + handle_pos = control_calc_p_pos (seg->right); + } - break; + break; - case GRAD_DRAG_MIDDLE: - handle_pos = control_calc_p_pos(seg->middle); - break; + case GRAD_DRAG_MIDDLE: + handle_pos = control_calc_p_pos (seg->middle); + break; - default: - g_message ("control_point_in_handle(): oops, can not handle drag mode %d", - (int) handle); - return 0; - } /* switch */ + default: + g_message ("control_point_in_handle(): oops, can not handle drag mode %d", + (int) handle); + return FALSE; + } - y /= 2; - - if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) - return 1; - else - return 0; -} /* control_point_in_handle */ + y /= 2; + if ((x >= (handle_pos - y)) && (x <= (handle_pos + y))) + return TRUE; + else + return FALSE; +} /*****/ static void -control_select_single_segment(grad_segment_t *seg) +control_select_single_segment (grad_segment_t *seg) { - g_editor->control_sel_l = seg; - g_editor->control_sel_r = seg; -} /* control_select_single_segment */ - + g_editor->control_sel_l = seg; + g_editor->control_sel_r = seg; +} /*****/ static void -control_extend_selection(grad_segment_t *seg, double pos) +control_extend_selection (grad_segment_t *seg, + double pos) { - if (fabs(pos - g_editor->control_sel_l->left) < fabs(pos - g_editor->control_sel_r->right)) - g_editor->control_sel_l = seg; - else - g_editor->control_sel_r = seg; -} /* control_extend_selection */ - + if (fabs (pos - g_editor->control_sel_l->left) < + fabs(pos - g_editor->control_sel_r->right)) + g_editor->control_sel_l = seg; + else + g_editor->control_sel_r = seg; +} /*****/ static void -control_motion(gint x) +control_motion (gint x) { - grad_segment_t *seg; - double pos; - double delta; - char str[256]; + grad_segment_t *seg; + double pos; + double delta; + char str[256]; - seg = g_editor->control_drag_segment; + seg = g_editor->control_drag_segment; - switch (g_editor->control_drag_mode) { - case GRAD_DRAG_LEFT: - pos = control_calc_g_pos(x); + switch (g_editor->control_drag_mode) + { + case GRAD_DRAG_LEFT: + pos = control_calc_g_pos (x); - if (!g_editor->control_compress) - seg->prev->right = seg->left = BOUNDS(pos, - seg->prev->middle + EPSILON, - seg->middle - EPSILON); - else - control_compress_left(g_editor->control_sel_l, - g_editor->control_sel_r, - seg, pos); + if (!g_editor->control_compress) + seg->prev->right = seg->left = BOUNDS (pos, + seg->prev->middle + EPSILON, + seg->middle - EPSILON); + else + control_compress_left (g_editor->control_sel_l, + g_editor->control_sel_r, + seg, pos); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->left); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->left); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_MIDDLE: - pos = control_calc_g_pos(x); - seg->middle = BOUNDS(pos, seg->left + EPSILON, seg->right - EPSILON); + case GRAD_DRAG_MIDDLE: + pos = control_calc_g_pos (x); + seg->middle = BOUNDS (pos, seg->left + EPSILON, seg->right - EPSILON); - g_snprintf(str, sizeof(str), _("Handle position: %0.6f"), seg->middle); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Handle position: %0.6f"), seg->middle); + ed_set_hint (str); - break; + break; - case GRAD_DRAG_ALL: - pos = control_calc_g_pos(x); - delta = pos - g_editor->control_last_gx; + case GRAD_DRAG_ALL: + pos = control_calc_g_pos (x); + delta = pos - g_editor->control_last_gx; - if ((seg->left >= g_editor->control_sel_l->left) && - (seg->right <= g_editor->control_sel_r->right)) - delta = control_move(g_editor->control_sel_l, g_editor->control_sel_r, delta); - else - delta = control_move(seg, seg, delta); + if ((seg->left >= g_editor->control_sel_l->left) && + (seg->right <= g_editor->control_sel_r->right)) + delta = control_move (g_editor->control_sel_l, + g_editor->control_sel_r, delta); + else + delta = control_move (seg, seg, delta); - g_editor->control_last_gx += delta; + g_editor->control_last_gx += delta; - g_snprintf(str, sizeof(str), _("Distance: %0.6f"), - g_editor->control_last_gx - g_editor->control_orig_pos); - ed_set_hint(str); + g_snprintf (str, sizeof (str), _("Distance: %0.6f"), + g_editor->control_last_gx - g_editor->control_orig_pos); + ed_set_hint (str); - break; + break; - default: - gimp_fatal_error(_("control_motion(): Attempt to move bogus handle %d"), - (int) g_editor->control_drag_mode); - break; - } /* switch */ + default: + gimp_fatal_error (_("control_motion(): Attempt to move bogus handle %d"), + (int) g_editor->control_drag_mode); + break; + } - curr_gradient->dirty = 1; - - if (g_editor->instant_update) - ed_update_editor(GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); - else - ed_update_editor(GRAD_UPDATE_CONTROL); -} /* control_motion */ + curr_gradient->dirty = 1; + if (g_editor->instant_update) + ed_update_editor (GRAD_UPDATE_PREVIEW | GRAD_UPDATE_CONTROL); + else + ed_update_editor (GRAD_UPDATE_CONTROL); +} /*****/ static void -control_compress_left(grad_segment_t *range_l, grad_segment_t *range_r, - grad_segment_t *drag_seg, double pos) +control_compress_left (grad_segment_t *range_l, + grad_segment_t *range_r, + grad_segment_t *drag_seg, + double pos) { - grad_segment_t *seg; - double lbound, rbound; - int k; + grad_segment_t *seg; + double lbound, rbound; + int k; - /* Check what we have to compress */ + /* Check what we have to compress */ - if (!((drag_seg->left >= range_l->left) && - ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) { - /* We are compressing a segment outside the selection */ + if (!((drag_seg->left >= range_l->left) && + ((drag_seg->right <= range_r->right) || (drag_seg == range_r->next)))) + { + /* We are compressing a segment outside the selection */ - range_l = range_r = drag_seg; - } /* else */ + range_l = range_r = drag_seg; + } - /* Calculate left bound for dragged hadle */ + /* Calculate left bound for dragged hadle */ - if (drag_seg == range_l) - lbound = range_l->prev->left + 2.0 * EPSILON; - else { - /* Count number of segments to the left of the dragged handle */ + if (drag_seg == range_l) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + { + /* Count number of segments to the left of the dragged handle */ - seg = drag_seg; - k = 0; + seg = drag_seg; + k = 0; - while (seg != range_l) { - k++; - seg = seg->prev; - } /* while */ + while (seg != range_l) + { + k++; + seg = seg->prev; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - lbound = range_l->left + 2.0 * k * EPSILON; - } /* else */ + lbound = range_l->left + 2.0 * k * EPSILON; + } - /* Calculate right bound for dragged handle */ + /* Calculate right bound for dragged handle */ - if (drag_seg == range_r->next) - rbound = range_r->next->right - 2.0 * EPSILON; - else { - /* Count number of segments to the right of the dragged handle */ + if (drag_seg == range_r->next) + rbound = range_r->next->right - 2.0 * EPSILON; + else + { + /* Count number of segments to the right of the dragged handle */ - seg = drag_seg; - k = 1; + seg = drag_seg; + k = 1; - while (seg != range_r) { - k++; - seg = seg->next; - } /* while */ + while (seg != range_r) + { + k++; + seg = seg->next; + } - /* 2*k handles have to fit */ + /* 2*k handles have to fit */ - rbound = range_r->right - 2.0 * k * EPSILON; - } /* else */ + rbound = range_r->right - 2.0 * k * EPSILON; + } - /* Calculate position */ + /* Calculate position */ - pos = BOUNDS(pos, lbound, rbound); + pos = BOUNDS (pos, lbound, rbound); - /* Compress segments to the left of the handle */ + /* Compress segments to the left of the handle */ - if (drag_seg == range_l) - control_compress_range(range_l->prev, range_l->prev, range_l->prev->left, pos); - else - control_compress_range(range_l, drag_seg->prev, range_l->left, pos); + if (drag_seg == range_l) + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, pos); + else + control_compress_range (range_l, drag_seg->prev, range_l->left, pos); - /* Compress segments to the right of the handle */ - - if (drag_seg != range_r->next) - control_compress_range(drag_seg, range_r, pos, range_r->right); - else - control_compress_range(drag_seg, drag_seg, pos, drag_seg->right); -} /* control_compress_left */ + /* Compress segments to the right of the handle */ + if (drag_seg != range_r->next) + control_compress_range (drag_seg, range_r, pos, range_r->right); + else + control_compress_range (drag_seg, drag_seg, pos, drag_seg->right); +} /*****/ static void -control_compress_range(grad_segment_t *range_l, grad_segment_t *range_r, - double new_l, double new_r) +control_compress_range (grad_segment_t *range_l, + grad_segment_t *range_r, + double new_l, + double new_r) { - double orig_l, orig_r; - double scale; - grad_segment_t *seg, *aseg; + double orig_l, orig_r; + double scale; + grad_segment_t *seg, *aseg; - orig_l = range_l->left; - orig_r = range_r->right; + orig_l = range_l->left; + orig_r = range_r->right; - scale = (new_r - new_l) / (orig_r - orig_l); + scale = (new_r - new_l) / (orig_r - orig_l); - seg = range_l; + seg = range_l; - do { - seg->left = new_l + (seg->left - orig_l) * scale; - seg->middle = new_l + (seg->middle - orig_l) * scale; - seg->right = new_l + (seg->right - orig_l) * scale; + do + { + seg->left = new_l + (seg->left - orig_l) * scale; + seg->middle = new_l + (seg->middle - orig_l) * scale; + seg->right = new_l + (seg->right - orig_l) * scale; - /* Next */ - - aseg = seg; - seg = seg->next; - } while (aseg != range_r); -} /* control_compress_range */ + /* Next */ + aseg = seg; + seg = seg->next; + } while (aseg != range_r); +} /*****/ static double -control_move(grad_segment_t *range_l, grad_segment_t *range_r, double delta) +control_move (grad_segment_t *range_l, + grad_segment_t *range_r, + double delta) { - double lbound, rbound; - int is_first, is_last; - grad_segment_t *seg, *aseg; + double lbound, rbound; + int is_first, is_last; + grad_segment_t *seg, *aseg; - /* First or last segments in gradient? */ + /* First or last segments in gradient? */ - is_first = (range_l->prev == NULL); - is_last = (range_r->next == NULL); + is_first = (range_l->prev == NULL); + is_last = (range_r->next == NULL); - /* Calculate drag bounds */ + /* Calculate drag bounds */ - if (!g_editor->control_compress) { - if (!is_first) - lbound = range_l->prev->middle + EPSILON; - else - lbound = range_l->left + EPSILON; + if (!g_editor->control_compress) + { + if (!is_first) + lbound = range_l->prev->middle + EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->middle - EPSILON; - else - rbound = range_r->right - EPSILON; - } else { - if (!is_first) - lbound = range_l->prev->left + 2.0 * EPSILON; - else - lbound = range_l->left + EPSILON; + if (!is_last) + rbound = range_r->next->middle - EPSILON; + else + rbound = range_r->right - EPSILON; + } + else + { + if (!is_first) + lbound = range_l->prev->left + 2.0 * EPSILON; + else + lbound = range_l->left + EPSILON; - if (!is_last) - rbound = range_r->next->right - 2.0 * EPSILON; - else - rbound = range_r->right - EPSILON; - } /* if */ + if (!is_last) + rbound = range_r->next->right - 2.0 * EPSILON; + else + rbound = range_r->right - EPSILON; + } - /* Fix the delta if necessary */ + /* Fix the delta if necessary */ - if (delta < 0.0) { - if (!is_first) { - if (range_l->left + delta < lbound) - delta = lbound - range_l->left; - } else - if (range_l->middle + delta < lbound) - delta = lbound - range_l->middle; - } else { - if (!is_last) { - if (range_r->right + delta > rbound) - delta = rbound - range_r->right; - } else - if (range_r->middle + delta > rbound) - delta = rbound - range_r->middle; - } /* else */ + if (delta < 0.0) + { + if (!is_first) + { + if (range_l->left + delta < lbound) + delta = lbound - range_l->left; + } + else + if (range_l->middle + delta < lbound) + delta = lbound - range_l->middle; + } + else + { + if (!is_last) + { + if (range_r->right + delta > rbound) + delta = rbound - range_r->right; + } + else + if (range_r->middle + delta > rbound) + delta = rbound - range_r->middle; + } - /* Move all the segments inside the range */ + /* Move all the segments inside the range */ - seg = range_l; + seg = range_l; - do { - if (!((seg == range_l) && is_first)) - seg->left += delta; + do + { + if (!((seg == range_l) && is_first)) + seg->left += delta; - seg->middle += delta; + seg->middle += delta; - if (!((seg == range_r) && is_last)) - seg->right += delta; + if (!((seg == range_r) && is_last)) + seg->right += delta; - /* Next */ + /* Next */ - aseg = seg; - seg = seg->next; - } while (aseg != range_r); + aseg = seg; + seg = seg->next; + } + while (aseg != range_r); - /* Fix the segments that surround the range */ + /* Fix the segments that surround the range */ - if (!is_first) - { - if (!g_editor->control_compress) - range_l->prev->right = range_l->left; - else - control_compress_range(range_l->prev, range_l->prev, - range_l->prev->left, range_l->left); - } + if (!is_first) + { + if (!g_editor->control_compress) + range_l->prev->right = range_l->left; + else + control_compress_range (range_l->prev, range_l->prev, + range_l->prev->left, range_l->left); + } - if (!is_last) - { - if (!g_editor->control_compress) - range_r->next->left = range_r->right; - else - control_compress_range(range_r->next, range_r->next, - range_r->right, range_r->next->right); - } - - return delta; -} /* control_move */ + if (!is_last) + { + if (!g_editor->control_compress) + range_r->next->left = range_r->right; + else + control_compress_range (range_r->next, range_r->next, + range_r->right, range_r->next->right); + } + return delta; +} /*****/ @@ -2990,158 +2981,162 @@ control_update (gboolean recalculate) /*****/ static void -control_draw(GdkPixmap *pixmap, int width, int height, double left, double right) +control_draw (GdkPixmap *pixmap, + int width, + int height, + double left, + double right) { - int sel_l, sel_r; - double g_pos; - grad_segment_t *seg; - control_drag_mode_t handle; + int sel_l, sel_r; + double g_pos; + grad_segment_t *seg; + control_drag_mode_t handle; - /* Clear the pixmap */ + /* Clear the pixmap */ - gdk_draw_rectangle(pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], - TRUE, 0, 0, width, height); + gdk_draw_rectangle (pixmap, g_editor->control->style->bg_gc[GTK_STATE_NORMAL], + TRUE, 0, 0, width, height); - /* Draw selection */ + /* Draw selection */ - sel_l = control_calc_p_pos(g_editor->control_sel_l->left); - sel_r = control_calc_p_pos(g_editor->control_sel_r->right); + sel_l = control_calc_p_pos (g_editor->control_sel_l->left); + sel_r = control_calc_p_pos (g_editor->control_sel_r->right); - gdk_draw_rectangle(pixmap, g_editor->control->style->dark_gc[GTK_STATE_NORMAL], - TRUE, sel_l, 0, sel_r - sel_l + 1, height); + gdk_draw_rectangle (pixmap, + g_editor->control->style->dark_gc[GTK_STATE_NORMAL], + TRUE, sel_l, 0, sel_r - sel_l + 1, height); - /* Draw handles */ + /* Draw handles */ - seg = curr_gradient->segments; + seg = curr_gradient->segments; - while (seg) { - control_draw_normal_handle(pixmap, seg->left, height); - control_draw_middle_handle(pixmap, seg->middle, height); + while (seg) + { + control_draw_normal_handle (pixmap, seg->left, height); + control_draw_middle_handle (pixmap, seg->middle, height); - /* Draw right handle only if this is the last segment */ + /* Draw right handle only if this is the last segment */ - if (seg->next == NULL) - control_draw_normal_handle(pixmap, seg->right, height); + if (seg->next == NULL) + control_draw_normal_handle (pixmap, seg->right, height); - /* Next! */ + /* Next! */ - seg = seg->next; - } /* while */ + seg = seg->next; + } - /* Draw the handle which is closest to the mouse position */ + /* Draw the handle which is closest to the mouse position */ - g_pos = control_calc_g_pos(g_editor->control_last_x); + g_pos = control_calc_g_pos (g_editor->control_last_x); - seg_get_closest_handle(curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); + seg_get_closest_handle (curr_gradient, BOUNDS(g_pos, 0.0, 1.0), &seg, &handle); - switch (handle) { - case GRAD_DRAG_LEFT: - if (seg) - control_draw_normal_handle(pixmap, seg->left, height); - else { - seg = seg_get_last_segment(curr_gradient->segments); - control_draw_normal_handle(pixmap, seg->right, height); - } /* else */ + switch (handle) + { + case GRAD_DRAG_LEFT: + if (seg) + control_draw_normal_handle (pixmap, seg->left, height); + else + { + seg = seg_get_last_segment (curr_gradient->segments); + control_draw_normal_handle (pixmap, seg->right, height); + } - break; + break; - case GRAD_DRAG_MIDDLE: - control_draw_middle_handle(pixmap, seg->middle, height); - break; - - default: - break; - } /* switch */ -} /* control_draw */ + case GRAD_DRAG_MIDDLE: + control_draw_middle_handle (pixmap, seg->middle, height); + break; + default: + break; + } +} /*****/ static void -control_draw_normal_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_normal_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->black_gc, - control_calc_p_pos(pos), height); -} /* control_draw_normal_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->black_gc, + control_calc_p_pos (pos), height); +} static void -control_draw_middle_handle(GdkPixmap *pixmap, double pos, int height) +control_draw_middle_handle (GdkPixmap *pixmap, + double pos, + int height) { - control_draw_handle(pixmap, - g_editor->control->style->black_gc, - g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], - control_calc_p_pos(pos), height); -} /* control_draw_middle_handle */ - - -/*****/ + control_draw_handle (pixmap, + g_editor->control->style->black_gc, + g_editor->control->style->bg_gc[GTK_STATE_PRELIGHT], + control_calc_p_pos(pos), height); +} static void -control_draw_handle(GdkPixmap *pixmap, GdkGC *border_gc, GdkGC *fill_gc, int xpos, int height) +control_draw_handle (GdkPixmap *pixmap, + GdkGC *border_gc, + GdkGC *fill_gc, + int xpos, + int height) { - int y; - int left, right, bottom; + int y; + int left, right, bottom; - for (y = 0; y < height; y++) - gdk_draw_line(pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); + for (y = 0; y < height; y++) + gdk_draw_line (pixmap, fill_gc, xpos - y / 2, y, xpos + y / 2, y); - bottom = height - 1; - left = xpos - bottom / 2; - right = xpos + bottom / 2; - - gdk_draw_line(pixmap, border_gc, xpos, 0, left, bottom); - gdk_draw_line(pixmap, border_gc, xpos, 0, right, bottom); - gdk_draw_line(pixmap, border_gc, left, bottom, right, bottom); -} /* control_draw_handle */ + bottom = height - 1; + left = xpos - bottom / 2; + right = xpos + bottom / 2; + gdk_draw_line (pixmap, border_gc, xpos, 0, left, bottom); + gdk_draw_line (pixmap, border_gc, xpos, 0, right, bottom); + gdk_draw_line (pixmap, border_gc, left, bottom, right, bottom); +} /*****/ static int -control_calc_p_pos(double pos) +control_calc_p_pos (double pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the position (in widget's coordinates) of the - * requested point from the gradient. Rounding is done to - * minimize mismatches between the rendered gradient preview - * and the gradient control's handles. - */ + /* Calculate the position (in widget's coordinates) of the + * requested point from the gradient. Rounding is done to + * minimize mismatches between the rendered gradient preview + * and the gradient control's handles. + */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); -} /* control_calc_p_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return (int) ((pwidth - 1) * (pos - adjustment->value) / adjustment->page_size + 0.5); +} /*****/ static double -control_calc_g_pos(int pos) +control_calc_g_pos (int pos) { - gint pwidth, pheight; - GtkAdjustment *adjustment; + gint pwidth, pheight; + GtkAdjustment *adjustment; - /* Calculate the gradient position that corresponds to widget's coordinates */ + /* Calculate the gradient position that corresponds to widget's coordinates */ - adjustment = GTK_ADJUSTMENT(g_editor->scroll_data); - gdk_window_get_size(g_editor->control_pixmap, &pwidth, &pheight); - - return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; -} /* control_calc_g_pos */ + adjustment = GTK_ADJUSTMENT (g_editor->scroll_data); + gdk_window_get_size (g_editor->control_pixmap, &pwidth, &pheight); + return adjustment->page_size * pos / (pwidth - 1) + adjustment->value; +} /***** Control popup functions *****/ -/*****/ - static void cpopup_create_main_menu (void) { @@ -3350,8 +3345,6 @@ cpopup_do_popup (void) /***** Create a single menu item *****/ -/*****/ - static GtkWidget * cpopup_create_color_item (GtkWidget **color_box, GtkWidget **label) @@ -3416,8 +3409,6 @@ cpopup_create_menu_item_with_label (gchar *str, /***** Update all menus *****/ -/*****/ - static void cpopup_adjust_menus (void) { @@ -3677,79 +3668,87 @@ cpopup_check_selection_params (gint *equal_blending, /*****/ static void -cpopup_render_color_box(GtkPreview *preview, double r, double g, double b, double a) +cpopup_render_color_box (GtkPreview *preview, + double r, + double g, + double b, + double a) { - guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; - int x, y; - int r0, g0, b0; - int r1, g1, b1; - guchar *p0, *p1, *p2; + guchar rows[3][GRAD_COLOR_BOX_WIDTH * 3]; + int x, y; + int r0, g0, b0; + int r1, g1, b1; + guchar *p0, *p1, *p2; - /* Fill rows */ + /* Fill rows */ - r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; - r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; + r0 = (GRAD_CHECK_DARK + (r - GRAD_CHECK_DARK) * a) * 255.0; + r1 = (GRAD_CHECK_LIGHT + (r - GRAD_CHECK_LIGHT) * a) * 255.0; - g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; - g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; + g0 = (GRAD_CHECK_DARK + (g - GRAD_CHECK_DARK) * a) * 255.0; + g1 = (GRAD_CHECK_LIGHT + (g - GRAD_CHECK_LIGHT) * a) * 255.0; - b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; - b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; + b0 = (GRAD_CHECK_DARK + (b - GRAD_CHECK_DARK) * a) * 255.0; + b1 = (GRAD_CHECK_LIGHT + (b - GRAD_CHECK_LIGHT) * a) * 255.0; - p0 = rows[0]; - p1 = rows[1]; - p2 = rows[2]; + p0 = rows[0]; + p1 = rows[1]; + p2 = rows[2]; - for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) { - if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) { - *p0++ = 0; - *p0++ = 0; - *p0++ = 0; + for (x = 0; x < GRAD_COLOR_BOX_WIDTH; x++) + { + if ((x == 0) || (x == (GRAD_COLOR_BOX_WIDTH - 1))) + { + *p0++ = 0; + *p0++ = 0; + *p0++ = 0; - *p1++ = 0; - *p1++ = 0; - *p1++ = 0; - } else - if ((x / GRAD_CHECK_SIZE) & 1) { - *p0++ = r1; - *p0++ = g1; - *p0++ = b1; + *p1++ = 0; + *p1++ = 0; + *p1++ = 0; + } + else + if ((x / GRAD_CHECK_SIZE) & 1) + { + *p0++ = r1; + *p0++ = g1; + *p0++ = b1; - *p1++ = r0; - *p1++ = g0; - *p1++ = b0; - } else { - *p0++ = r0; - *p0++ = g0; - *p0++ = b0; + *p1++ = r0; + *p1++ = g0; + *p1++ = b0; + } + else + { + *p0++ = r0; + *p0++ = g0; + *p0++ = b0; - *p1++ = r1; - *p1++ = g1; - *p1++ = b1; - } /* else */ + *p1++ = r1; + *p1++ = g1; + *p1++ = b1; + } - *p2++ = 0; - *p2++ = 0; - *p2++ = 0; - } /* for */ + *p2++ = 0; + *p2++ = 0; + *p2++ = 0; + } - /* Fill preview */ + /* Fill preview */ - gtk_preview_draw_row(preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); + gtk_preview_draw_row (preview, rows[2], 0, 0, GRAD_COLOR_BOX_WIDTH); - for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) - if ((y / GRAD_CHECK_SIZE) & 1) - gtk_preview_draw_row(preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); - else - gtk_preview_draw_row(preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); + for (y = 1; y < (GRAD_COLOR_BOX_HEIGHT - 1); y++) + if ((y / GRAD_CHECK_SIZE) & 1) + gtk_preview_draw_row (preview, rows[1], 0, y, GRAD_COLOR_BOX_WIDTH); + else + gtk_preview_draw_row (preview, rows[0], 0, y, GRAD_COLOR_BOX_WIDTH); - gtk_preview_draw_row(preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); -} /* cpopup_render_color_box */ + gtk_preview_draw_row (preview, rows[2], 0, y, GRAD_COLOR_BOX_WIDTH); +} /***** Creale load & save menus *****/ -/*****/ - static GtkWidget * cpopup_create_load_menu (GtkWidget **color_boxes, GtkWidget **labels, @@ -3824,8 +3823,8 @@ cpopup_create_load_menu (GtkWidget **color_boxes, } static GtkWidget * -cpopup_create_save_menu (GtkWidget **color_boxes, - GtkWidget **labels, +cpopup_create_save_menu (GtkWidget **color_boxes, + GtkWidget **labels, GtkSignalFunc callback) { GtkWidget *menu; @@ -3846,324 +3845,328 @@ cpopup_create_save_menu (GtkWidget **color_boxes, return menu; } +/*****/ + +static void +cpopup_update_saved_color (int n, + double r, + double g, + double b, + double a) +{ + char str[256]; + + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->left_save_color_boxes[n]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_load_color_boxes[n + 3]), + r, g, b, a); + cpopup_render_color_box (GTK_PREVIEW (g_editor->right_save_color_boxes[n]), + r, g, b, a); + + g_snprintf (str, sizeof (str), + _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + + gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); + gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + + g_editor->saved_colors[n].r = r; + g_editor->saved_colors[n].g = g; + g_editor->saved_colors[n].b = b; + g_editor->saved_colors[n].a = a; +} /*****/ static void -cpopup_update_saved_color(int n, double r, double g, double b, double a) +cpopup_load_left_callback (GtkWidget *widget, + gpointer data) { - char str[256]; + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->left_save_color_boxes[n]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_load_color_boxes[n + 3]), - r, g, b, a); - cpopup_render_color_box(GTK_PREVIEW(g_editor->right_save_color_boxes[n]), - r, g, b, a); + switch ((long) data) + { + case 0: /* Fetch from left neighbor's right endpoint */ + if (g_editor->control_sel_l->prev != NULL) + seg = g_editor->control_sel_l->prev; + else + seg = seg_get_last_segment (g_editor->control_sel_l); - g_snprintf(str, sizeof(str), _("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"), r, g, b, a); + cpopup_blend_endpoints (seg->r1, seg->g1, seg->b1, seg->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - gtk_label_set_text (GTK_LABEL (g_editor->left_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->left_save_labels[n]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_load_labels[n + 3]), str); - gtk_label_set_text (GTK_LABEL (g_editor->right_save_labels[n]), str); + case 1: /* Fetch from right endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; - g_editor->saved_colors[n].r = r; - g_editor->saved_colors[n].g = g; - g_editor->saved_colors[n].b = b; - g_editor->saved_colors[n].a = a; -} /* cpopup_update_saved_color */ + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (fg_r, + fg_g, + fg_b, + fg_a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + g_editor->control_sel_r->r1, + g_editor->control_sel_r->g1, + g_editor->control_sel_r->b1, + g_editor->control_sel_r->a1, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_left_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; +} + +static void +cpopup_load_right_callback (GtkWidget *widget, + gpointer data) +{ + grad_segment_t *seg; + double fg_r, fg_g, fg_b; + double fg_a; + + switch ((long) data) + { + case 0: /* Fetch from right neighbor's left endpoint */ + if (g_editor->control_sel_r->next != NULL) + seg = g_editor->control_sel_r->next; + else + seg = curr_gradient->segments; + + cpopup_blend_endpoints (g_editor->control_sel_r->r0, + g_editor->control_sel_r->g0, + g_editor->control_sel_r->b0, + g_editor->control_sel_r->a0, + seg->r0, seg->g0, seg->b0, seg->a0, + TRUE, TRUE); + break; + + case 1: /* Fetch from left endpoint */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + TRUE, TRUE); + break; + + case 2: /* Fetch from FG color */ + ed_fetch_foreground (&fg_r, &fg_g, &fg_b, &fg_a); + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + fg_r, + fg_g, + fg_b, + fg_a, + TRUE, TRUE); + break; + + default: /* Load a color */ + cpopup_blend_endpoints (g_editor->control_sel_l->r0, + g_editor->control_sel_l->g0, + g_editor->control_sel_l->b0, + g_editor->control_sel_l->a0, + g_editor->saved_colors[(long) data - 3].r, + g_editor->saved_colors[(long) data - 3].g, + g_editor->saved_colors[(long) data - 3].b, + g_editor->saved_colors[(long) data - 3].a, + TRUE, TRUE); + break; + } + + curr_gradient->dirty = 1; + ed_update_editor (GRAD_UPDATE_PREVIEW); +} + +static void +cpopup_save_right_callback (GtkWidget *widget, + gpointer data) +{ + g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; + g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; + g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; + g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; +} /*****/ static void -cpopup_load_left_callback(GtkWidget *widget, gpointer data) +cpopup_set_color_selection_color (GtkColorSelection *cs, + double r, + double g, + double b, + double a) { - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; + gdouble color[4]; - switch ((long) data) { - case 0: /* Fetch from left neighbor's right endpoint */ - if (g_editor->control_sel_l->prev != NULL) - seg = g_editor->control_sel_l->prev; - else - seg = seg_get_last_segment(g_editor->control_sel_l); - - cpopup_blend_endpoints(seg->r1, seg->g1, seg->b1, seg->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 1: /* Fetch from right endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(fg_r, - fg_g, - fg_b, - fg_a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - g_editor->control_sel_r->r1, - g_editor->control_sel_r->g1, - g_editor->control_sel_r->b1, - g_editor->control_sel_r->a1, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_left_callback */ + color[0] = r; + color[1] = g; + color[2] = b; + color[3] = a; + gtk_color_selection_set_color (cs, color); +} /*****/ static void -cpopup_save_left_callback(GtkWidget *widget, gpointer data) +cpopup_get_color_selection_color (GtkColorSelection *cs, + double *r, + double *g, + double *b, + double *a) { - g_editor->saved_colors[(long) data].r = g_editor->control_sel_l->r0; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_l->g0; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_l->b0; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_l->a0; -} /* cpopup_save_left_callback */ + gdouble color[4]; + gtk_color_selection_get_color (cs, color); -/*****/ - -static void -cpopup_load_right_callback(GtkWidget *widget, gpointer data) -{ - grad_segment_t *seg; - double fg_r, fg_g, fg_b; - double fg_a; - - switch ((long) data) { - case 0: /* Fetch from right neighbor's left endpoint */ - if (g_editor->control_sel_r->next != NULL) - seg = g_editor->control_sel_r->next; - else - seg = curr_gradient->segments; - - cpopup_blend_endpoints(g_editor->control_sel_r->r0, - g_editor->control_sel_r->g0, - g_editor->control_sel_r->b0, - g_editor->control_sel_r->a0, - seg->r0, seg->g0, seg->b0, seg->a0, - TRUE, TRUE); - break; - - case 1: /* Fetch from left endpoint */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - TRUE, TRUE); - break; - - case 2: /* Fetch from FG color */ - ed_fetch_foreground(&fg_r, &fg_g, &fg_b, &fg_a); - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - fg_r, - fg_g, - fg_b, - fg_a, - TRUE, TRUE); - break; - - default: /* Load a color */ - cpopup_blend_endpoints(g_editor->control_sel_l->r0, - g_editor->control_sel_l->g0, - g_editor->control_sel_l->b0, - g_editor->control_sel_l->a0, - g_editor->saved_colors[(long) data - 3].r, - g_editor->saved_colors[(long) data - 3].g, - g_editor->saved_colors[(long) data - 3].b, - g_editor->saved_colors[(long) data - 3].a, - TRUE, TRUE); - break; - } /* switch */ - - curr_gradient->dirty = 1; - ed_update_editor(GRAD_UPDATE_PREVIEW); -} /* cpopup_load_right_callback */ - - -/*****/ - -static void -cpopup_save_right_callback(GtkWidget *widget, gpointer data) -{ - g_editor->saved_colors[(long) data].r = g_editor->control_sel_r->r1; - g_editor->saved_colors[(long) data].g = g_editor->control_sel_r->g1; - g_editor->saved_colors[(long) data].b = g_editor->control_sel_r->b1; - g_editor->saved_colors[(long) data].a = g_editor->control_sel_r->a1; -} /* cpopup_save_right_callback */ - - -/*****/ - -static void -cpopup_set_color_selection_color(GtkColorSelection *cs, - double r, double g, double b, double a) -{ - gdouble color[4]; - - color[0] = r; - color[1] = g; - color[2] = b; - color[3] = a; - - gtk_color_selection_set_color(cs, color); -} /* cpopup_set_color_selection_color */ - - -/*****/ - -static void -cpopup_get_color_selection_color(GtkColorSelection *cs, - double *r, double *g, double *b, double *a) -{ - gdouble color[4]; - - gtk_color_selection_get_color(cs, color); - - *r = color[0]; - *g = color[1]; - *b = color[2]; - *a = color[3]; -} /* cpopup_get_color_selection_color */ - + *r = color[0]; + *g = color[1]; + *b = color[2]; + *a = color[3]; +} /*****/ static grad_segment_t * -cpopup_save_selection(void) +cpopup_save_selection (void) { - grad_segment_t *seg, *prev, *tmp; - grad_segment_t *oseg, *oaseg; + grad_segment_t *seg, *prev, *tmp; + grad_segment_t *oseg, *oaseg; - prev = NULL; - oseg = g_editor->control_sel_l; - tmp = NULL; + prev = NULL; + oseg = g_editor->control_sel_l; + tmp = NULL; - do { - seg = seg_new_segment(); + do + { + seg = seg_new_segment (); - *seg = *oseg; /* Copy everything */ + *seg = *oseg; /* Copy everything */ - if (prev == NULL) - tmp = seg; /* Remember first segment */ - else - prev->next = seg; + if (prev == NULL) + tmp = seg; /* Remember first segment */ + else + prev->next = seg; - seg->prev = prev; - seg->next = NULL; + seg->prev = prev; + seg->next = NULL; - prev = seg; - oaseg = oseg; - oseg = oseg->next; - } while (oaseg != g_editor->control_sel_r); - - return tmp; -} /* cpopup_save_selection */ + prev = seg; + oaseg = oseg; + oseg = oseg->next; + } + while (oaseg != g_editor->control_sel_r); + return tmp; +} /*****/ static void -cpopup_free_selection(grad_segment_t *seg) +cpopup_free_selection (grad_segment_t *seg) { - seg_free_segments(seg); -} /* cpopup_free_selection */ - + seg_free_segments (seg); +} /*****/ static void -cpopup_replace_selection(grad_segment_t *replace_seg) +cpopup_replace_selection (grad_segment_t *replace_seg) { - grad_segment_t *lseg, *rseg; - grad_segment_t *replace_last; + grad_segment_t *lseg, *rseg; + grad_segment_t *replace_last; - /* Remember left and right segments */ + /* Remember left and right segments */ - lseg = g_editor->control_sel_l->prev; - rseg = g_editor->control_sel_r->next; + lseg = g_editor->control_sel_l->prev; + rseg = g_editor->control_sel_r->next; - replace_last = seg_get_last_segment(replace_seg); + replace_last = seg_get_last_segment (replace_seg); - /* Free old selection */ + /* Free old selection */ - g_editor->control_sel_r->next = NULL; + g_editor->control_sel_r->next = NULL; - seg_free_segments(g_editor->control_sel_l); + seg_free_segments (g_editor->control_sel_l); - /* Link in new segments */ + /* Link in new segments */ - if (lseg) - lseg->next = replace_seg; - else - curr_gradient->segments = replace_seg; + if (lseg) + lseg->next = replace_seg; + else + curr_gradient->segments = replace_seg; - replace_seg->prev = lseg; + replace_seg->prev = lseg; - if (rseg) - rseg->prev = replace_last; + if (rseg) + rseg->prev = replace_last; - replace_last->next = rseg; + replace_last->next = rseg; - g_editor->control_sel_l = replace_seg; - g_editor->control_sel_r = replace_last; + g_editor->control_sel_l = replace_seg; + g_editor->control_sel_r = replace_last; - curr_gradient->last_visited = NULL; /* Force re-search */ -} /* cpopup_replace_selection */ + curr_gradient->last_visited = NULL; /* Force re-search */ +} /***** Color dialogs for left and right endpoint *****/ -/*****/ - static void -cpopup_create_color_dialog (gchar *title, - double r, double g, double b, double a, - GtkSignalFunc color_changed_callback, - GtkSignalFunc ok_callback, - GtkSignalFunc cancel_callback, - GtkSignalFunc delete_callback) +cpopup_create_color_dialog (gchar *title, + double r, + double g, + double b, + double a, + GtkSignalFunc color_changed_callback, + GtkSignalFunc ok_callback, + GtkSignalFunc cancel_callback, + GtkSignalFunc delete_callback) { GtkWidget *window; GtkColorSelection *cs; @@ -4360,8 +4363,6 @@ cpopup_right_color_dialog_delete (GtkWidget *widget, /***** Blending menu *****/ -/*****/ - static GtkWidget * cpopup_create_blending_menu (void) { @@ -4432,8 +4433,6 @@ cpopup_blending_callback (GtkWidget *widget, /***** Coloring menu *****/ -/*****/ - static GtkWidget * cpopup_create_coloring_menu (void) { @@ -4593,26 +4592,23 @@ cpopup_split_uniform_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Split"), cpopup_split_uniform_split_callback, NULL, NULL }, - { N_("Cancel"), cpopup_split_uniform_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (g_editor->shell), - "gradient_segment_split_uniformly", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Split segment uniformly") : - _("Split segments uniformly")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Split segment uniformly") : + _("Split segments uniformly"), + "gradient_segment_split_uniformly", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_split_uniform_delete_callback), - dialog); + _("Split"), cpopup_split_uniform_split_callback, + NULL, NULL, TRUE, FALSE, + _("Cancel"), cpopup_split_uniform_cancel_callback, + NULL, NULL, FALSE, TRUE, + + NULL); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 0); @@ -4646,11 +4642,6 @@ cpopup_split_uniform_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_split_uniform_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 0); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -4704,16 +4695,6 @@ cpopup_split_uniform_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_split_uniform_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_split_uniform_cancel_callback (widget, data); - - return TRUE; -} - static void cpopup_split_uniform (grad_segment_t *lseg, int parts, @@ -4958,8 +4939,6 @@ cpopup_redistribute_callback (GtkWidget *widget, /***** Control popup -> selection options functions *****/ -/*****/ - static GtkWidget * cpopup_create_sel_ops_menu (void) { @@ -5172,26 +5151,23 @@ cpopup_replicate_callback (GtkWidget *widget, GtkWidget *scale; GtkObject *scale_data; - static ActionAreaItem action_items[] = - { - { N_("Replicate"), cpopup_do_replicate_callback, NULL, NULL }, - { N_("Cancel"), cpopup_replicate_cancel_callback, NULL, NULL } - }; - /* Create dialog window */ - dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), - "gradient_segment_replicate", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), - (g_editor->control_sel_l == g_editor->control_sel_r) ? - _("Replicate segment") : - _("Replicate selection")); - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + dialog = + gimp_dialog_new ((g_editor->control_sel_l == g_editor->control_sel_r) ? + _("Replicate segment") : + _("Replicate selection"), + "gradient_segment_replicate", + gimp_standard_help_func, + "dialogs/gradient_editor_dialog.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (cpopup_replicate_delete_callback), - dialog); + _("Replicate"), cpopup_do_replicate_callback, + NULL, NULL, FALSE, FALSE, + _("Cancel"), cpopup_replicate_cancel_callback, + NULL, NULL, TRUE, TRUE, + + NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); @@ -5223,11 +5199,6 @@ cpopup_replicate_callback (GtkWidget *widget, (GtkSignalFunc) cpopup_replicate_scale_update, NULL); - /* The action area */ - action_items[0].user_data = dialog; - action_items[1].user_data = dialog; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Show! */ gtk_widget_show (dialog); gtk_widget_set_sensitive (g_editor->shell, FALSE); @@ -5370,16 +5341,6 @@ cpopup_replicate_cancel_callback (GtkWidget *widget, gtk_widget_set_sensitive (g_editor->shell, TRUE); } -static gint -cpopup_replicate_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - cpopup_replicate_cancel_callback (widget, data); - - return TRUE; -} - /*****/ static void @@ -5420,8 +5381,6 @@ cpopup_blend_opacity (GtkWidget *widget, /***** Main blend function *****/ -/*****/ - static void cpopup_blend_endpoints (double r0, double g0, double b0, double a0, double r1, double g1, double b1, double a1, @@ -5469,645 +5428,671 @@ cpopup_blend_endpoints (double r0, double g0, double b0, double a0, /***** Gradient functions *****/ -/*****/ - static gradient_t * -grad_new_gradient(void) +grad_new_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = g_malloc(sizeof(gradient_t)); + grad = g_new (gradient_t, 1); - grad->name = NULL; - grad->segments = NULL; - grad->last_visited = NULL; - grad->dirty = 0; - grad->filename = NULL; - grad->pixmap = NULL; + grad->name = NULL; + grad->segments = NULL; + grad->last_visited = NULL; + grad->dirty = 0; + grad->filename = NULL; + grad->pixmap = NULL; - return grad; -} /* grad_new_gradient */ - - -/*****/ - -static void -grad_free_gradient(gradient_t *grad) -{ - g_assert(grad != NULL); - - if (grad->name) - g_free(grad->name); - - if (grad->segments) - seg_free_segments(grad->segments); - - if (grad->filename) - g_free(grad->filename); - - g_free(grad); -} /* grad_free_gradient */ - - -/*****/ - -static void -grad_save_all(int need_free) -{ - GSList *node; - gradient_t *grad; - - node = gradients_list; - - while (node) { - grad = node->data; - - /* If gradient has dirty flag set, save it */ - - if (grad->dirty) - grad_save_gradient(grad, grad->filename); - - if(need_free) - grad_free_gradient(grad); - - node = g_slist_next(node); - } /* while */ + return grad; } /*****/ static void -grad_free_gradients(void) +grad_free_gradient (gradient_t *grad) { - grad_save_all(1); + g_assert (grad != NULL); + + if (grad->name) + g_free (grad->name); + + if (grad->segments) + seg_free_segments (grad->segments); + + if (grad->filename) + g_free (grad->filename); + + g_free (grad); +} + +/*****/ + +static void +grad_save_all (int need_free) +{ + GSList *node; + gradient_t *grad; + + node = gradients_list; + + while (node) + { + grad = node->data; + + /* If gradient has dirty flag set, save it */ + if (grad->dirty) + grad_save_gradient (grad, grad->filename); + + if (need_free) + grad_free_gradient (grad); + + node = g_slist_next (node); + } +} + +/*****/ + +static void +grad_free_gradients (void) +{ + grad_save_all (1); - g_slist_free(gradients_list); - - num_gradients = 0; - gradients_list = NULL; - curr_gradient = NULL; -} /* grad_free_gradients */ + g_slist_free (gradients_list); + num_gradients = 0; + gradients_list = NULL; + curr_gradient = NULL; +} /*****/ static void -grad_load_gradient(char *filename) +grad_load_gradient (char *filename) { - FILE *file; - gradient_t *grad; - grad_segment_t *seg, *prev; - int num_segments; - int i; - int type, color; - char line[1024]; + FILE *file; + gradient_t *grad; + grad_segment_t *seg, *prev; + int num_segments; + int i; + int type, color; + char line[1024]; - g_assert(filename != NULL); + g_assert (filename != NULL); - file = fopen(filename, "rb"); - if (!file) - return; + file = fopen (filename, "rb"); + if (!file) + return; - fgets(line, 1024, file); - if (strcmp(line, "GIMP Gradient\n") != 0) - return; + fgets (line, 1024, file); + if (strcmp (line, "GIMP Gradient\n") != 0) + return; - grad = grad_new_gradient(); + grad = grad_new_gradient (); - grad->filename = g_strdup(filename); - grad->name = g_strdup(g_basename(filename)); + grad->filename = g_strdup (filename); + grad->name = g_strdup (g_basename (filename)); - fgets(line, 1024, file); - num_segments = atoi(line); + fgets (line, 1024, file); + num_segments = atoi (line); - if (num_segments < 1) { - g_message (_("grad_load_gradient(): invalid number of segments in \"%s\""), filename); - g_free(grad); - return; - } /* if */ + if (num_segments < 1) + { + g_message (_("grad_load_gradient(): " + "invalid number of segments in \"%s\""), filename); + g_free (grad); + return; + } - prev = NULL; + prev = NULL; - for (i = 0; i < num_segments; i++) { - seg = seg_new_segment(); - seg->prev = prev; + for (i = 0; i < num_segments; i++) + { + seg = seg_new_segment (); + seg->prev = prev; - if (prev) - prev->next = seg; - else - grad->segments = seg; + if (prev) + prev->next = seg; + else + grad->segments = seg; - fgets(line, 1024, file); + fgets (line, 1024, file); - if (sscanf(line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", - &(seg->left), &(seg->middle), &(seg->right), - &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), - &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), - &type, &color) != 13) { - g_message (_("grad_load_gradient(): badly formatted " - "gradient segment %d in \"%s\" --- bad things may " - "happen soon"), i, filename); - } else { - seg->type = (grad_type_t) type; - seg->color = (grad_color_t) color; - } /* else */ + if (sscanf (line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d", + &(seg->left), &(seg->middle), &(seg->right), + &(seg->r0), &(seg->g0), &(seg->b0), &(seg->a0), + &(seg->r1), &(seg->g1), &(seg->b1), &(seg->a1), + &type, &color) != 13) + { + g_message (_("grad_load_gradient(): badly formatted " + "gradient segment %d in \"%s\" --- bad things may " + "happen soon"), i, filename); + } + else + { + seg->type = (grad_type_t) type; + seg->color = (grad_color_t) color; + } - prev = seg; - } /* for */ + prev = seg; + } - fclose(file); + fclose (file); - grad_insert_in_gradients_list(grad); - - /* Check if this gradient is the default one */ - - if (strcmp(default_gradient, grad->name) == 0) - grad_default_gradient = grad; -} /* grad_load_gradient */ + grad_insert_in_gradients_list (grad); + /* Check if this gradient is the default one */ + if (strcmp (default_gradient, grad->name) == 0) + grad_default_gradient = grad; +} /*****/ static void -grad_save_gradient(gradient_t *grad, char *filename) +grad_save_gradient (gradient_t *grad, + char *filename) { - FILE *file; - int num_segments; - grad_segment_t *seg; + FILE *file; + int num_segments; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert (grad != NULL); - if (!filename) { - g_message (_("grad_save_gradient(): can not save gradient with NULL filename")); - return; - } /* if */ + if (!filename) + { + g_message (_("grad_save_gradient(): " + "can not save gradient with NULL filename")); + return; + } - file = fopen(filename, "wb"); - if (!file) { - g_message (_("grad_save_gradient(): can't open \"%s\""), filename); - return; - } /* if */ + file = fopen (filename, "wb"); + if (!file) + { + g_message (_("grad_save_gradient(): can't open \"%s\""), filename); + return; + } - /* File format is: - * - * GIMP Gradient - * number_of_segments - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring - * ... - */ + /* File format is: + * + * GIMP Gradient + * number_of_segments + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * left middle right r0 g0 b0 a0 r1 g1 b1 a1 type coloring + * ... + */ - fprintf(file, "GIMP Gradient\n"); + fprintf (file, "GIMP Gradient\n"); - /* Count number of segments */ + /* Count number of segments */ + num_segments = 0; + seg = grad->segments; - num_segments = 0; - seg = grad->segments; + while (seg) + { + num_segments++; + seg = seg->next; + } - while (seg) { - num_segments++; - seg = seg->next; - } /* while */ + /* Write rest of file */ + fprintf (file, "%d\n", num_segments); - /* Write rest of file */ + for (seg = grad->segments; seg; seg = seg->next) + fprintf (file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, (int) seg->color); - fprintf(file, "%d\n", num_segments); - - for (seg = grad->segments; seg; seg = seg->next) - fprintf(file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n", - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, (int) seg->color); - - fclose(file); - - grad->dirty = 0; -} /* grad_save_gradient */ + fclose(file); + grad->dirty = 0; +} /*****/ static gradient_t * -grad_create_default_gradient(void) +grad_create_default_gradient (void) { - gradient_t *grad; + gradient_t *grad; - grad = grad_new_gradient(); - grad->segments = seg_new_segment(); - - return grad; -} /* grad_create_default_gradient */ + grad = grad_new_gradient(); + grad->segments = seg_new_segment (); + return grad; +} /*****/ static int -grad_insert_in_gradients_list(gradient_t *grad) +grad_insert_in_gradients_list (gradient_t *grad) { - GSList *tmp; - gradient_t *g; - int n; + GSList *tmp; + gradient_t *g; + int n; - /* We insert gradients in alphabetical order. Find the index - * of the gradient after which we will insert the current one. - */ + /* We insert gradients in alphabetical order. Find the index + * of the gradient after which we will insert the current one. + */ - n = 0; - tmp = gradients_list; + n = 0; + tmp = gradients_list; - while (tmp) { - g = tmp->data; + while (tmp) + { + g = tmp->data; - if (strcmp(grad->name, g->name) <= 0) - break; /* We found the one we want */ + if (strcmp (grad->name, g->name) <= 0) + break; /* We found the one we want */ - n++; - tmp = g_slist_next(tmp); - } /* while */ + n++; + tmp = g_slist_next (tmp); + } - num_gradients++; - gradients_list = g_slist_insert(gradients_list, grad, n); - - return n; -} /* grad_insert_in_gradients_list */ + num_gradients++; + gradients_list = g_slist_insert (gradients_list, grad, n); + return n; +} /*****/ static void -grad_dump_gradient(gradient_t *grad, FILE *file) +grad_dump_gradient (gradient_t *grad, + FILE *file) { - grad_segment_t *seg; + grad_segment_t *seg; - fprintf(file, "Name: \"%s\"\n", grad->name); - fprintf(file, "Dirty: %d\n", grad->dirty); - fprintf(file, "Filename: \"%s\"\n", grad->filename); + fprintf (file, "Name: \"%s\"\n", grad->name); + fprintf (file, "Dirty: %d\n", grad->dirty); + fprintf (file, "Filename: \"%s\"\n", grad->filename); - seg = grad->segments; + seg = grad->segments; - while (seg) { - fprintf(file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", - (seg == grad->last_visited) ? '>' : ' ', - seg, - seg->left, seg->middle, seg->right, - seg->r0, seg->g0, seg->b0, seg->a0, - seg->r1, seg->g1, seg->b1, seg->a1, - (int) seg->type, - (int) seg->color, - seg->prev, seg->next); - - seg = seg->next; - } /* while */ -} /* grad_dump_gradient */ + while (seg) + { + fprintf (file, "%c%p | %f %f %f | %f %f %f %f | %f %f %f %f | %d %d | %p %p\n", + (seg == grad->last_visited) ? '>' : ' ', + seg, + seg->left, seg->middle, seg->right, + seg->r0, seg->g0, seg->b0, seg->a0, + seg->r1, seg->g1, seg->b1, seg->a1, + (int) seg->type, + (int) seg->color, + seg->prev, seg->next); + seg = seg->next; + } +} /***** Segment functions *****/ -/*****/ - static grad_segment_t * -seg_new_segment(void) +seg_new_segment (void) { - grad_segment_t *seg; + grad_segment_t *seg; - seg = g_malloc(sizeof(grad_segment_t)); + seg = g_new (grad_segment_t, 1); - seg->left = 0.0; - seg->middle = 0.5; - seg->right = 1.0; + seg->left = 0.0; + seg->middle = 0.5; + seg->right = 1.0; - seg->r0 = seg->g0 = seg->b0 = 0.0; - seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; + seg->r0 = seg->g0 = seg->b0 = 0.0; + seg->r1 = seg->g1 = seg->b1 = seg->a0 = seg->a1 = 1.0; - seg->type = GRAD_LINEAR; - seg->color = GRAD_RGB; + seg->type = GRAD_LINEAR; + seg->color = GRAD_RGB; - seg->prev = seg->next = NULL; - - return seg; -} /* seg_new_segment */ + seg->prev = seg->next = NULL; + return seg; +} /*****/ static void -seg_free_segment(grad_segment_t *seg) +seg_free_segment (grad_segment_t *seg) { - g_assert(seg != NULL); - - g_free(seg); -} /* seg_free_segment */ + g_assert (seg != NULL); + g_free (seg); +} /*****/ static void -seg_free_segments(grad_segment_t *seg) +seg_free_segments (grad_segment_t *seg) { - grad_segment_t *tmp; + grad_segment_t *tmp; - g_assert(seg != NULL); - - while (seg) { - tmp = seg->next; - seg_free_segment(seg); - seg = tmp; - } /* while */ -} /* seg_free_segments */ + g_assert (seg != NULL); + while (seg) + { + tmp = seg->next; + seg_free_segment(seg); + seg = tmp; + } +} /*****/ static grad_segment_t * -seg_get_segment_at(gradient_t *grad, double pos) +seg_get_segment_at (gradient_t *grad, + double pos) { - grad_segment_t *seg; + grad_segment_t *seg; - g_assert(grad != NULL); + g_assert(grad != NULL); - pos = BOUNDS(pos, 0.0, 1.0); /* to handle FP imprecision at the edges of the gradient */ + /* handle FP imprecision at the edges of the gradient */ + pos = BOUNDS (pos, 0.0, 1.0); - if (grad->last_visited) - seg = grad->last_visited; - else - seg = grad->segments; + if (grad->last_visited) + seg = grad->last_visited; + else + seg = grad->segments; - while (seg) - if (pos >= seg->left) { - if (pos <= seg->right) { - grad->last_visited = seg; /* for speed */ - return seg; - } else - seg = seg->next; - } else - seg = seg->prev; + while (seg) + { + if (pos >= seg->left) + { + if (pos <= seg->right) + { + grad->last_visited = seg; /* for speed */ + return seg; + } + else + { + seg = seg->next; + } + } + else + { + seg = seg->prev; + } + } - /* Oops: we should have found a segment, but we didn't */ - - grad_dump_gradient(curr_gradient, stderr); - gimp_fatal_error (_("seg_get_segment_at(): No matching segment for position %0.15f"), pos); - return NULL; /* To shut up -Wall */ -} /* seg_get_segment_at */ + /* Oops: we should have found a segment, but we didn't */ + grad_dump_gradient (curr_gradient, stderr); + gimp_fatal_error (_("seg_get_segment_at(): " + "No matching segment for position %0.15f"), pos); + return NULL; /* To shut up -Wall */ +} /*****/ static grad_segment_t * -seg_get_last_segment(grad_segment_t *seg) +seg_get_last_segment (grad_segment_t *seg) { - if (!seg) - return NULL; + if (!seg) + return NULL; - while (seg->next) - seg = seg->next; - - return seg; -} /* seg_get_last_segment */ + while (seg->next) + seg = seg->next; + return seg; +} /*****/ static void -seg_get_closest_handle(gradient_t *grad, double pos, - grad_segment_t **seg, control_drag_mode_t *handle) +seg_get_closest_handle (gradient_t *grad, + double pos, + grad_segment_t **seg, + control_drag_mode_t *handle) { - double l_delta, m_delta, r_delta; + double l_delta, m_delta, r_delta; - *seg = seg_get_segment_at(grad, pos); + *seg = seg_get_segment_at (grad, pos); - m_delta = fabs(pos - (*seg)->middle); + m_delta = fabs (pos - (*seg)->middle); - if (pos < (*seg)->middle) { - l_delta = fabs(pos - (*seg)->left); + if (pos < (*seg)->middle) + { + l_delta = fabs (pos - (*seg)->left); - if (l_delta < m_delta) - *handle = GRAD_DRAG_LEFT; - else - *handle = GRAD_DRAG_MIDDLE; - } else { - r_delta = fabs(pos - (*seg)->right); - - if (m_delta < r_delta) - *handle = GRAD_DRAG_MIDDLE; - else { - *seg = (*seg)->next; - *handle = GRAD_DRAG_LEFT; - } /* else */ - } /* else */ -} /* seg_get_closest_handle */ + if (l_delta < m_delta) + *handle = GRAD_DRAG_LEFT; + else + *handle = GRAD_DRAG_MIDDLE; + } + else + { + r_delta = fabs (pos - (*seg)->right); + if (m_delta < r_delta) + { + *handle = GRAD_DRAG_MIDDLE; + } + else + { + *seg = (*seg)->next; + *handle = GRAD_DRAG_LEFT; + } + } +} /***** Calculation functions *****/ -/*****/ - static double -calc_linear_factor(double middle, double pos) +calc_linear_factor (double middle, + double pos) { - if (pos <= middle) { - if (middle < EPSILON) - return 0.0; - else - return 0.5 * pos / middle; - } else { - pos -= middle; - middle = 1.0 - middle; - - if (middle < EPSILON) - return 1.0; - else - return 0.5 + 0.5 * pos / middle; - } /* else */ -} /* calc_linear_factor */ + if (pos <= middle) + { + if (middle < EPSILON) + return 0.0; + else + return 0.5 * pos / middle; + } + else + { + pos -= middle; + middle = 1.0 - middle; + if (middle < EPSILON) + return 1.0; + else + return 0.5 + 0.5 * pos / middle; + } +} /*****/ static double -calc_curved_factor(double middle, double pos) +calc_curved_factor (double middle, + double pos) { - if (middle < EPSILON) - middle = EPSILON; - - return pow(pos, log(0.5) / log(middle)); -} /* calc_curved_factor */ + if (middle < EPSILON) + middle = EPSILON; + return pow(pos, log (0.5) / log (middle)); +} /*****/ static double -calc_sine_factor(double middle, double pos) +calc_sine_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return (sin((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; -} /* calc_sine_factor */ + pos = calc_linear_factor (middle, pos); + return (sin ((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0; +} /*****/ static double -calc_sphere_increasing_factor(double middle, double pos) +calc_sphere_increasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos) - 1.0; - - return sqrt(1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ -} /* calc_sphere_increasing_factor */ + pos = calc_linear_factor (middle, pos) - 1.0; + return sqrt (1.0 - pos * pos); /* Works for convex increasing and concave decreasing */ +} /*****/ static double -calc_sphere_decreasing_factor(double middle, double pos) +calc_sphere_decreasing_factor (double middle, + double pos) { - pos = calc_linear_factor(middle, pos); - - return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ -} /* calc_sphere_decreasing_factor */ + pos = calc_linear_factor (middle, pos); + return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */ +} /*****/ static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, + double *g, + double *b) { - double red, green, blue; - double h, s, v; - double min, max; - double delta; + double red, green, blue; + double h, s, v; + double min, max; + double delta; - red = *r; - green = *g; - blue = *b; + red = *r; + green = *g; + blue = *b; - h = 0.0; /* Shut up -Wall */ + h = 0.0; /* Shut up -Wall */ - if (red > green) { - if (red > blue) - max = red; - else - max = blue; + if (red > green) + { + if (red > blue) + max = red; + else + max = blue; - if (green < blue) - min = green; - else - min = blue; - } else { - if (green > blue) - max = green; - else - max = blue; + if (green < blue) + min = green; + else + min = blue; + } + else + { + if (green > blue) + max = green; + else + max = blue; - if (red < blue) - min = red; - else - min = blue; - } /* else */ + if (red < blue) + min = red; + else + min = blue; + } - v = max; + v = max; - if (max != 0.0) - s = (max - min) / max; - else - s = 0.0; + if (max != 0.0) + s = (max - min) / max; + else + s = 0.0; - if (s == 0.0) - h = 0.0; - else { - delta = max - min; + if (s == 0.0) + { + h = 0.0; + } + else + { + delta = max - min; - if (red == max) - h = (green - blue) / delta; - else if (green == max) - h = 2 + (blue - red) / delta; - else if (blue == max) - h = 4 + (red - green) / delta; + if (red == max) + h = (green - blue) / delta; + else if (green == max) + h = 2 + (blue - red) / delta; + else if (blue == max) + h = 4 + (red - green) / delta; - h /= 6.0; + h /= 6.0; - if (h < 0.0) - h += 1.0; - else if (h > 1.0) - h -= 1.0; - } /* else */ - - *r = h; - *g = s; - *b = v; -} /* calc_rgb_to_hsv */ + if (h < 0.0) + h += 1.0; + else if (h > 1.0) + h -= 1.0; + } + *r = h; + *g = s; + *b = v; +} /*****/ static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, + double *s, + double *v) { - double hue, saturation, value; - double f, p, q, t; + double hue, saturation, value; + double f, p, q, t; - if (*s == 0.0) { - *h = *v; - *s = *v; - *v = *v; /* heh */ - } else { - hue = *h * 6.0; - saturation = *s; - value = *v; + if (*s == 0.0) + { + *h = *v; + *s = *v; + *v = *v; /* heh */ + } + else + { + hue = *h * 6.0; + saturation = *s; + value = *v; - if (hue == 6.0) - hue = 0.0; + if (hue == 6.0) + hue = 0.0; - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); + f = hue - (int) hue; + p = value * (1.0 - saturation); + q = value * (1.0 - saturation * f); + t = value * (1.0 - saturation * (1.0 - f)); - switch ((int) hue) { - case 0: - *h = value; - *s = t; - *v = p; - break; + switch ((int) hue) + { + case 0: + *h = value; + *s = t; + *v = p; + break; - case 1: - *h = q; - *s = value; - *v = p; - break; + case 1: + *h = q; + *s = value; + *v = p; + break; - case 2: - *h = p; - *s = value; - *v = t; - break; + case 2: + *h = p; + *s = value; + *v = t; + break; - case 3: - *h = p; - *s = q; - *v = value; - break; + case 3: + *h = p; + *s = q; + *v = value; + break; - case 4: - *h = t; - *s = p; - *v = value; - break; - - case 5: - *h = value; - *s = p; - *v = q; - break; - } /* switch */ - } /* else */ -} /* calc_hsv_to_rgb */ + case 4: + *h = t; + *s = p; + *v = value; + break; + case 5: + *h = value; + *s = p; + *v = q; + break; + } + } +} /***** Files and paths functions *****/ -/*****/ - static gchar * build_user_filename (gchar *name, gchar *path_str) diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c new file mode 100644 index 0000000000..77e4ae427a --- /dev/null +++ b/app/widgets/gimphelp.c @@ -0,0 +1,132 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimphelp.c + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include + +#include "gimphelp.h" +#include "gimprc.h" +#include "plug_in.h" +#include "procedural_db.h" + +#include "libgimp/gimpintl.h" + +/* The standard help function */ +void +gimp_standard_help_func (gpointer help_data) +{ + gchar *help_page; + + help_page = (gchar *) help_data; + gimp_help (help_page); +} + +static void +gimp_help_callback (GtkWidget *widget, + gpointer data) +{ + GimpHelpFunc help_function; + gpointer help_data; + + help_function = (GimpHelpFunc) data; + help_data = gtk_object_get_data (GTK_OBJECT (widget), + "gimp_help_data"); + + if (help_function && use_help) + (* help_function) (help_data); +} + +void +gimp_help_connect_help_accel (GtkWidget *widget, + GimpHelpFunc help_func, + gpointer help_data) +{ + GtkAccelGroup *accel_group; + static guint help_signal_id = 0; + + /* create the help signal if not already done */ + if (! help_signal_id) + { + help_signal_id = + gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass, + "help", + GTK_RUN_LAST, + gtk_signal_default_marshaller, + GTK_TYPE_NONE, + 0, + NULL); + } + + if (help_data) + { + gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", + help_data); + } + + gtk_signal_connect (GTK_OBJECT (widget), "help", + GTK_SIGNAL_FUNC (gimp_help_callback), + (gpointer) help_func); + + /* a new accelerator group for this widget */ + accel_group = gtk_accel_group_new (); + gtk_accel_group_add (accel_group, GDK_F1, 0, 0, + GTK_OBJECT (widget), "help"); + gtk_accel_group_attach (accel_group, GTK_OBJECT (widget)); +} + +/* the main help function */ +void +gimp_help (gchar *help_page) +{ + ProcRecord *proc_rec; + Argument *return_vals; + gint nreturn_vals; + + /* Check if a help browser is already running */ + proc_rec = procedural_db_lookup ("extension_gimp_help_browser_temp"); + if (proc_rec == NULL) + { + proc_rec = procedural_db_lookup ("extension_gimp_help_browser"); + if (proc_rec == NULL) + { + g_message (_("Could not find the GIMP Help Browser procedure\n" + "Note that you still have to compile this plugin " + "manually")); + return; + } + + return_vals = + procedural_db_run_proc ("extension_gimp_help_browser", + &nreturn_vals, + PDB_INT32, RUN_INTERACTIVE, + PDB_STRING, help_page, + PDB_END); + } + else + { + return_vals = + procedural_db_run_proc ("extension_gimp_help_browser_temp", + &nreturn_vals, + PDB_STRING, help_page, + PDB_END); + } + + procedural_db_destroy_args (return_vals, nreturn_vals); +} diff --git a/app/widgets/gimphelp.h b/app/widgets/gimphelp.h new file mode 100644 index 0000000000..0725084c3a --- /dev/null +++ b/app/widgets/gimphelp.h @@ -0,0 +1,39 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimphelp.h + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMP_HELP_H__ +#define __GIMP_HELP_H__ + +#include + +typedef void (* GimpHelpFunc) (gpointer); + +/* the standard help function */ +void gimp_standard_help_func (gpointer help_data); + +/* connect the "F1" accelerator of a window */ +void gimp_help_connect_help_accel (GtkWidget *widget, + GimpHelpFunc help_func, + gpointer help_data); + +/* the main help function */ +void gimp_help (gchar *help_page); + +#endif /* __GIMP_HELP_H__ */ diff --git a/app/widgets/gimpitemfactory.c b/app/widgets/gimpitemfactory.c index a49ed3c3e1..5550911d3a 100644 --- a/app/widgets/gimpitemfactory.c +++ b/app/widgets/gimpitemfactory.c @@ -69,6 +69,7 @@ static GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Open"), "O", file_open_cmd_callback, 0 }, { N_("/File/Acquire"), NULL, NULL, 0, "" }, { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, + { N_("/File/Help..."), NULL, gimp_help_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c index 6a4672a1bf..9e405239c6 100644 --- a/app/widgets/gimppaletteeditor.c +++ b/app/widgets/gimppaletteeditor.c @@ -31,7 +31,6 @@ #include #include #include "appenv.h" -#include "actionarea.h" #include "buildmenu.h" #include "colormaps.h" #include "color_area.h" @@ -41,9 +40,9 @@ #include "errors.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "gradient_header.h" #include "gradient.h" -#include "interface.h" #include "palette.h" #include "palette_entries.h" #include "session.h" @@ -1075,11 +1074,16 @@ static void palette_new_entries_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box (_("New Palette"), - _("Enter a name for new palette"), - NULL, - NULL, NULL, - palette_add_entries_callback, data)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("New Palette"), + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + _("Enter a name for new palette"), + NULL, + NULL, NULL, + palette_add_entries_callback, data); + gtk_widget_show (qbox); } static void @@ -1375,17 +1379,6 @@ palette_close_callback (GtkWidget *widget, } } -static gint -palette_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - palette_close_callback (widget, data); - - return TRUE; -} - - static void color_name_entry_changed (GtkWidget *widget, gpointer data) @@ -2015,18 +2008,6 @@ create_palette_dialog (gint vert) GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; - - static ActionAreaItem vert_action_items[] = - { - { N_("Edit"), palette_edit_palette_callback, NULL, NULL }, - { N_("Close"), palette_close_callback, NULL, NULL } - }; - static ActionAreaItem horz_action_items[] = - { - { N_("Save"), palette_save_palettes_callback, NULL, NULL }, - { N_("Refresh"), palette_refresh_callback, NULL, NULL }, - { N_("Close"), palette_close_callback, NULL, NULL } - }; palette = g_new (PaletteDialog, 1); @@ -2039,26 +2020,42 @@ create_palette_dialog (gint vert) palette->columns_valid = TRUE; palette->freeze_update = FALSE; - palette->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (palette->shell), "color_palette", "Gimp"); - if (!vert) { + palette->shell = + gimp_dialog_new (_("Color Palette Edit"), "color_palette_edit", + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, + + _("Save"), palette_save_palettes_callback, + palette, NULL, FALSE, FALSE, + _("Refresh"), palette_refresh_callback, + palette, NULL, FALSE, FALSE, + _("Close"), palette_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); gtk_widget_set_usize (palette->shell, 615, 200); - gtk_window_set_title (GTK_WINDOW (palette->shell), - _("Color Palette Edit")); } else { - gtk_widget_set_usize (palette->shell, 230, 300); - gtk_window_set_title (GTK_WINDOW (palette->shell), - _("Color Palette")); - } + palette->shell = + gimp_dialog_new (_("Color Palette"), "color_palette", + gimp_standard_help_func, + "dialogs/color_palette_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (palette->shell), "delete_event", - GTK_SIGNAL_FUNC (palette_dialog_delete_callback), - palette); + _("Edit"), palette_edit_palette_callback, + palette, NULL, FALSE, FALSE, + _("Close"), palette_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); + gtk_widget_set_usize (palette->shell, 230, 300); + } /* The main container widget */ if (vert) @@ -2260,20 +2257,6 @@ create_palette_dialog (gint vert) gtk_widget_show (button); } - if (!vert) - { - horz_action_items[0].user_data = palette; - horz_action_items[1].user_data = palette; - horz_action_items[2].user_data = palette; - build_action_area (GTK_DIALOG (palette->shell), horz_action_items, 3, 2); - } - else - { - vert_action_items[0].user_data = palette; - vert_action_items[1].user_data = palette; - build_action_area (GTK_DIALOG (palette->shell), vert_action_items, 2, 1); - } - palette->gc = gdk_gc_new (palette->shell->window); palette_popup_menu (palette); @@ -2441,17 +2424,6 @@ import_dialog_import_callback (GtkWidget *widget, } } -static gint -import_dialog_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - import_dialog_close_callback (widget, data); - - return TRUE; -} - - static void palette_merge_entries_callback (GtkWidget *widget, gpointer data, @@ -2508,12 +2480,17 @@ static void palette_merge_dialog_callback (GtkWidget *widget, gpointer data) { - gtk_widget_show (query_string_box (_("Merge Palette"), - _("Enter a name for merged palette"), - NULL, - NULL, NULL, - palette_merge_entries_callback, - data)); + GtkWidget *qbox; + + qbox = gimp_query_string_box (_("Merge Palette"), + gimp_standard_help_func, + "dialogs/color_palette_edit_dialog.html", + _("Enter a name for merged palette"), + NULL, + NULL, NULL, + palette_merge_entries_callback, + data); + gtk_widget_show (qbox); } static void @@ -2845,24 +2822,23 @@ palette_import_dialog (PaletteDialog *palette) GtkWidget *image; GtkWidget *hscale; - static ActionAreaItem action_items[] = - { - { N_("Import"), import_dialog_import_callback, NULL, NULL }, - { N_("Close"), import_dialog_close_callback, NULL, NULL } - }; - import_dialog = g_new (ImportDialog, 1); import_dialog->image_list = NULL; import_dialog->gimage = NULL; - import_dialog->dialog = dialog = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (dialog), "import_palette", "Gimp"); - gtk_window_set_title (GTK_WINDOW (dialog), _("Import Palette")); + import_dialog->dialog = dialog = + gimp_dialog_new (_("Import Palette"), "import_palette", + gimp_standard_help_func, + "dialogs/import_palette_dialog.html", + GTK_WIN_POS_NONE, + FALSE, TRUE, FALSE, - /* Handle the wm delete event */ - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (import_dialog_delete_callback), - (gpointer)palette); + _("Import"), import_dialog_import_callback, + palette, NULL, FALSE, FALSE, + _("Close"), import_dialog_close_callback, + palette, NULL, TRUE, TRUE, + + NULL); /* The main hbox */ hbox = gtk_hbox_new (FALSE, 4); @@ -2986,11 +2962,6 @@ palette_import_dialog (PaletteDialog *palette) gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); - /* The action area */ - action_items[0].user_data = palette; - action_items[1].user_data = palette; - build_action_area (GTK_DIALOG (dialog), action_items, 2, 1); - /* Fill with the selected gradient */ palette_import_fill_grad_preview (image, curr_gradient); import_dialog->import_type = GRAD_IMPORT; diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c new file mode 100644 index 0000000000..d5380d3ceb --- /dev/null +++ b/app/widgets/gimpwidgets-utils.c @@ -0,0 +1,857 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpui.c + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include "gimpui.h" + +#include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpintl.h" + +/* + * 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; +} + +/* +#include "/home/mitschel/gimpfiles/wilber.xpm" + +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], + wilber_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, + gpointer 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, + * 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, + gpointer help_data, + GtkWindowPosition position, + gint allow_shrink, + gint allow_grow, + gint auto_shrink, + va_list args) +{ + GtkWidget *dialog; + 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_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 */ + gtk_container_set_border_width + (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2); + gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (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 (GTK_DIALOG (dialog)->action_area), hbbox, + FALSE, FALSE, 0); + gtk_widget_show (hbbox); + + /* the action_area buttons */ + label = va_arg (args, gchar*); + 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*); + } + + /* catch the WM delete event if not already done */ + if (! delete_connected) + gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", + (GdkEventFunc) gimp_dialog_delete_callback, + NULL); + + /* 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; +} + +GtkWidget * +gimp_option_menu_new (GtkSignalFunc menu_item_callback, + gpointer initial, /* user_data */ + + /* specify menu items as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...) +{ + GtkWidget *menu; + GtkWidget *menuitem; + GtkWidget *optionmenu; + + /* menu item variables */ + gchar *label; + gpointer data; + gpointer user_data; + + va_list args; + gint i; + gint initial_index; + + menu = gtk_menu_new (); + + /* create the menu items */ + initial_index = 0; + va_start (args, initial); + label = va_arg (args, gchar*); + for (i = 0; label; i++) + { + data = va_arg (args, gpointer); + user_data = va_arg (args, gpointer); + + menuitem = gtk_menu_item_new_with_label (label); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_signal_connect (GTK_OBJECT (menuitem), "activate", + menu_item_callback, data); + gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data); + gtk_widget_show (menuitem); + + /* remember the initial menu item */ + if (user_data == initial) + initial_index = i; + + label = va_arg (args, gchar*); + } + va_end (args); + + optionmenu = gtk_option_menu_new (); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + + /* select the initial menu item */ + gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index); + + return optionmenu; +} + +GtkWidget * +gimp_radio_group_new (GtkSignalFunc radio_button_callback, + gpointer initial, /* user_data */ + + /* specify radio buttons as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...) +{ + GtkWidget *vbox; + GtkWidget *button; + GSList *group; + + /* radio button variables */ + gchar *label; + gpointer data; + gpointer user_data; + + va_list args; + + vbox = gtk_vbox_new (FALSE, 1); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + group = NULL; + + /* create the radio buttons */ + va_start (args, initial); + label = va_arg (args, gchar*); + while (label) + { + data = va_arg (args, gpointer); + user_data = va_arg (args, gpointer); + + button = gtk_radio_button_new_with_label (group, label); + group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "toggled", + (GtkSignalFunc) radio_button_callback, + data); + gtk_object_set_user_data (GTK_OBJECT (button), user_data); + + /* press the initially active radio button */ + if (user_data == initial) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); + + gtk_widget_show (button); + + label = va_arg (args, gchar*); + } + va_end (args); + + return vbox; +} + +GtkWidget * +gimp_spin_button_new (GtkObject **adjustment, /* return value */ + gfloat value, + gfloat lower, + gfloat upper, + gfloat step_increment, + gfloat page_increment, + gfloat page_size, + gfloat climb_rate, + guint digits) +{ + GtkWidget *spinbutton; + + *adjustment = gtk_adjustment_new (value, lower, upper, + step_increment, page_increment, page_size); + + spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment), + climb_rate, digits); + gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), + GTK_SHADOW_NONE); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + gtk_widget_set_usize (spinbutton, 75, 0); + + return spinbutton; +} + + +/* + * String, integer, double and size query boxes + */ + +typedef struct _QueryBox QueryBox; + +struct _QueryBox +{ + GtkWidget *qbox; + GtkWidget *vbox; + GtkWidget *entry; + GtkObject *object; + GimpQueryFunc callback; + gpointer data; +}; + +static QueryBox * create_query_box (gchar *, GimpHelpFunc, gpointer, + GtkSignalFunc, + gchar *, GtkObject *, gchar *, + GimpQueryFunc, gpointer); +static void query_box_cancel_callback (GtkWidget *, gpointer); +static void string_query_box_ok_callback (GtkWidget *, gpointer); +static void int_query_box_ok_callback (GtkWidget *, gpointer); +static void double_query_box_ok_callback (GtkWidget *, gpointer); +static void size_query_box_ok_callback (GtkWidget *, gpointer); + +/* create a generic query box without any entry widget */ +static QueryBox * +create_query_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + GtkSignalFunc ok_callback, + gchar *message, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkWidget *qbox; + GtkWidget *vbox; + GtkWidget *label; + + query_box = g_new (QueryBox, 1); + + qbox = gimp_dialog_new (title, "query_box", + help_func, help_data, + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, + + _("OK"), ok_callback, + query_box, NULL, TRUE, FALSE, + _("Cancel"), query_box_cancel_callback, + query_box, NULL, FALSE, TRUE, + + NULL); + + /* if we are associated with an object, connect to the provided signal */ + if (object && GTK_IS_OBJECT (object) && signal) + gtk_signal_connect (GTK_OBJECT (object), signal, + (GtkSignalFunc) query_box_cancel_callback, + query_box); + else + object = NULL; + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (qbox)->vbox), vbox); + gtk_widget_show (vbox); + + label = gtk_label_new (message); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + query_box->qbox = qbox; + query_box->vbox = vbox; + query_box->entry = NULL; + query_box->object = object; + query_box->callback = callback; + query_box->data = data; + + return query_box; +} + +GtkWidget * +gimp_query_string_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gchar *initial, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkWidget *entry; + + query_box = create_query_box (title, help_func, help_data, + string_query_box_ok_callback, + message, object, signal, callback, data); + + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); + if (initial) + gtk_entry_set_text (GTK_ENTRY (entry), initial); + gtk_widget_grab_focus (entry); + gtk_widget_show (entry); + + query_box->entry = entry; + + return query_box->qbox; +} + +GtkWidget * +gimp_query_int_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gint initial, + gint lower, + gint upper, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkAdjustment* adjustment; + GtkWidget *spinbutton; + + query_box = create_query_box (title, help_func, help_data, + int_query_box_ok_callback, + message, object, signal, callback, data); + + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); + spinbutton = gtk_spin_button_new (adjustment, 1.0, 0); + gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_grab_focus (spinbutton); + gtk_widget_show (spinbutton); + + query_box->entry = spinbutton; + + return query_box->qbox; +} + +GtkWidget * +gimp_query_double_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkAdjustment* adjustment; + GtkWidget *spinbutton; + + query_box = create_query_box (title, help_func, help_data, + double_query_box_ok_callback, + message, object, signal, callback, data); + + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (initial, lower, upper, 1, 10, 0)); + spinbutton = gtk_spin_button_new (adjustment, 1.0, digits); + gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_grab_focus (spinbutton); + gtk_widget_show (spinbutton); + + query_box->entry = spinbutton; + + return query_box->qbox; +} + +GtkWidget * +gimp_query_size_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GUnit unit, + gdouble resolution, + gboolean dot_for_dot, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data) +{ + QueryBox *query_box; + GtkWidget *sizeentry; + + query_box = create_query_box (title, help_func, help_data, + size_query_box_ok_callback, + message, object, signal, callback, data); + + sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, + GIMP_SIZE_ENTRY_UPDATE_SIZE); + if (dot_for_dot) + gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), UNIT_PIXEL); + gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, + resolution, FALSE); + gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits); + gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0, + lower, upper); + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial); + + gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0); + gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry)); + gtk_widget_show (sizeentry); + + query_box->entry = sizeentry; + + return query_box->qbox; +} + +static void +query_box_cancel_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + + query_box = (QueryBox *) data; + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +string_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gchar *string; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the entry data */ + string = g_strdup (gtk_entry_get_text (GTK_ENTRY (query_box->entry))); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, (gpointer) string); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +int_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gint *integer_value; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the spinbutton data */ + integer_value = g_malloc (sizeof (gint)); + *integer_value = + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry)); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, + (gpointer) integer_value); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +double_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gdouble *double_value; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the spinbutton data */ + double_value = g_malloc (sizeof (gdouble)); + *double_value = + gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (query_box->entry)); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, + (gpointer) double_value); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +size_query_box_ok_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + gdouble *double_value; + + query_box = (QueryBox *) data; + + gtk_widget_set_sensitive (query_box->qbox, FALSE); + + /* disconnect, if we are connected to some signal */ + if (query_box->object) + gtk_signal_disconnect_by_data (query_box->object, query_box); + + /* Get the sizeentry data */ + double_value = g_malloc (sizeof (gdouble)); + *double_value = + gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0); + + /* Pass the selected unit to the callback */ + gtk_object_set_data + (GTK_OBJECT (widget), "size_query_unit", + (gpointer) gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry))); + + /* Call the user defined callback */ + (* query_box->callback) (query_box->qbox, query_box->data, + (gpointer) double_value); + + /* Destroy the box */ + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + + +/* + * Message Boxes... + */ + +typedef struct _MessageBox MessageBox; + +struct _MessageBox +{ + GtkWidget *mbox; + GtkCallback callback; + gpointer data; +}; + +static void gimp_message_box_close_callback (GtkWidget *, gpointer); + +GtkWidget * +gimp_message_box (gchar *message, + GtkCallback callback, + gpointer data) +{ + MessageBox *msg_box; + GtkWidget *mbox; + GtkWidget *vbox; + GtkWidget *label; + + if (! message) + return NULL; + + msg_box = g_new (MessageBox, 1); + + mbox = gimp_dialog_new (_("GIMP Message"), "gimp_message", + NULL, NULL, + GTK_WIN_POS_MOUSE, + FALSE, FALSE, FALSE, + + _("OK"), gimp_message_box_close_callback, + msg_box, NULL, TRUE, TRUE, + + NULL); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (mbox)->vbox), vbox); + gtk_widget_show (vbox); + + label = gtk_label_new (message); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); + gtk_widget_show (label); + + msg_box->mbox = mbox; + msg_box->callback = callback; + msg_box->data = data; + + gtk_widget_show (mbox); + + return mbox; +} + +static void +gimp_message_box_close_callback (GtkWidget *widget, + gpointer data) +{ + MessageBox *msg_box; + + msg_box = (MessageBox *) data; + + /* If there is a valid callback, invoke it */ + if (msg_box->callback) + (* msg_box->callback) (widget, msg_box->data); + + /* Destroy the box */ + gtk_widget_destroy (msg_box->mbox); + + g_free (msg_box); +} + + +/* + * Helper Functions... + */ + +/* add aligned label & widget to a two-column table */ +void +gimp_table_attach_aligned (GtkTable *table, + gint row, + gchar *text, + gfloat xalign, + gfloat yalign, + GtkWidget *widget, + gboolean left_adjust) +{ + GtkWidget *label; + + label = gtk_label_new (text); + gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); + gtk_table_attach (table, GTK_WIDGET (label), 0, 1, row, row + 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (label); + + if (left_adjust) + { + GtkWidget *alignment; + + alignment = gtk_alignment_new (0.0, 1.0, 0.0, 0.0); + gtk_table_attach_defaults (table, alignment, 1, 2, row, row + 1); + gtk_widget_show (alignment); + gtk_container_add (GTK_CONTAINER (alignment), widget); + } + else + { + gtk_table_attach_defaults (table, widget, 1, 2, row, row + 1); + } + + gtk_widget_show (widget); +} diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h new file mode 100644 index 0000000000..781fde1448 --- /dev/null +++ b/app/widgets/gimpwidgets-utils.h @@ -0,0 +1,175 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpui.h + * Copyright (C) 1999 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMP_UI_H__ +#define __GIMP_UI_H__ + +#include + +#include "gimphelp.h" + +#include "libgimp/gimpunit.h" + +/* typedefs */ +typedef void (* GimpQueryFunc) (GtkWidget *, gpointer, gpointer); + + +/* widget constructors */ + +GtkWidget * gimp_dialog_new (const gchar *title, + const gchar *wmclass_name, + GimpHelpFunc help_func, + gpointer 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, + gpointer help_data, + GtkWindowPosition position, + gint allow_shrink, + gint allow_grow, + gint auto_shrink, + va_list args); + +GtkWidget * gimp_option_menu_new (GtkSignalFunc menu_item_callback, + gpointer initial, /* user_data */ + + /* specify menu items as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...); + +GtkWidget * gimp_radio_group_new (GtkSignalFunc radio_button_callback, + gpointer initial, /* user_data */ + + /* specify radio buttons as va_list: + * gchar *label, + * gpointer data, + * gpointer user_data, + */ + + ...); + +GtkWidget * gimp_spin_button_new (/* return value: */ + GtkObject **adjustment, + + gfloat value, + gfloat lower, + gfloat upper, + gfloat step_increment, + gfloat page_increment, + gfloat page_size, + gfloat climb_rate, + guint digits); + +/* some simple query dialogs + * if object != NULL then the query boxes will connect their cancel callback + * to the provided signal of this object + * + * it's the caller's job to show the returned widgets + */ + +GtkWidget * gimp_query_string_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gchar *initial, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +GtkWidget * gimp_query_int_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + char *message, + gint initial, + gint lower, + gint upper, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +GtkWidget * gimp_query_double_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +GtkWidget * gimp_query_size_box (gchar *title, + GimpHelpFunc help_func, + gpointer help_data, + gchar *message, + gdouble initial, + gdouble lower, + gdouble upper, + gint digits, + GUnit unit, + gdouble resolution, + gboolean dot_for_dot, + GtkObject *object, + gchar *signal, + GimpQueryFunc callback, + gpointer data); + +/* a simple message box */ + +GtkWidget * gimp_message_box (gchar *message, + GtkCallback callback, + gpointer data); + +/* helper functions */ + +/* add aligned label & widget to a two-column table */ +void gimp_table_attach_aligned (GtkTable *table, + gint row, + gchar *text, + gfloat xalign, + gfloat yalign, + GtkWidget *widget, + gboolean left_adjust); + +#endif /* __GIMP_UI_H__ */ diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c index 1108664b37..8222bbd0c0 100644 --- a/libgimpwidgets/gimpcolorselect.c +++ b/libgimpwidgets/gimpcolorselect.c @@ -16,16 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include #include #include + #include "appenv.h" -#include "actionarea.h" #include "color_select.h" #include "colormaps.h" #include "errors.h" #include "gimpdnd.h" #include "gimprc.h" +#include "gimpui.h" #include "session.h" #include "color_area.h" /* for color_area_draw_rect */ @@ -110,7 +112,6 @@ static void color_select_update_colors (ColorSelect *, gint); static void color_select_ok_callback (GtkWidget *, gpointer); static void color_select_cancel_callback (GtkWidget *, gpointer); -static gint color_select_delete_callback (GtkWidget *, GdkEvent *, gpointer); static gint color_select_xy_expose (GtkWidget *, GdkEventExpose *, ColorSelect *); static gint color_select_xy_events (GtkWidget *, GdkEvent *, @@ -190,12 +191,6 @@ color_select_new (gint r, ColorSelect *csp; GtkWidget *main_vbox; - static ActionAreaItem action_items[] = - { - { N_("OK"), color_select_ok_callback, NULL, NULL }, - { N_("Cancel"), color_select_cancel_callback, NULL, NULL } - }; - csp = g_new (ColorSelect, 1); csp->callback = callback; @@ -211,37 +206,26 @@ color_select_new (gint r, color_select_update_hsv_values (csp); color_select_update_pos (csp); - csp->shell = gtk_dialog_new (); - gtk_window_set_wmclass (GTK_WINDOW (csp->shell), "color_selection", "Gimp"); - gtk_window_set_title (GTK_WINDOW (csp->shell), _("Color Selection")); - gtk_window_set_policy (GTK_WINDOW (csp->shell), FALSE, FALSE, FALSE); + csp->shell = + gimp_dialog_new (_("Color Selection"), "color_selection", + gimp_standard_help_func, + "dialogs/color_selection_dialog.html", + GTK_WIN_POS_NONE, + FALSE, FALSE, FALSE, + wants_updates ? _("Close") : _("OK"), + color_select_ok_callback, + csp, NULL, TRUE, FALSE, + wants_updates ? _("Revert to Old Color") : _("Cancel"), + color_select_cancel_callback, + csp, NULL, FALSE, TRUE, - /* handle the wm close signal */ - gtk_signal_connect (GTK_OBJECT (csp->shell), "delete_event", - (GtkSignalFunc) color_select_delete_callback, csp); + NULL); main_vbox = color_select_widget_new (csp, r, g, b); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (csp->shell)->vbox), main_vbox); gtk_widget_show (main_vbox); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, - TRUE, TRUE, 0); - - /* The action area */ - action_items[0].user_data = csp; - action_items[1].user_data = csp; - if (csp->wants_updates) - { - action_items[0].label = _("Close"); - action_items[1].label = _("Revert to Old Color"); - } - else - { - action_items[0].label = _("OK"); - action_items[1].label = _("Cancel"); - } - build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0); - color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values); color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values); @@ -997,16 +981,6 @@ color_select_ok_callback (GtkWidget *widget, } } -static gint -color_select_delete_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - color_select_cancel_callback (widget, data); - - return TRUE; -} - static void color_select_cancel_callback (GtkWidget *widget, gpointer data) diff --git a/plug-ins/helpbrowser/helpbrowser.c b/plug-ins/helpbrowser/helpbrowser.c index e29d7d004d..52e20dcae2 100644 --- a/plug-ins/helpbrowser/helpbrowser.c +++ b/plug-ins/helpbrowser/helpbrowser.c @@ -855,20 +855,19 @@ idle_load_page (gpointer data) } static void -run_temp_proc (char *name, - int nparams, +run_temp_proc (gchar *name, + gint nparams, GParam *param, - int *nreturn_vals, + gint *nreturn_vals, GParam **return_vals) { static GParam values[1]; GStatusType status = STATUS_SUCCESS; gchar *path; - g_print ("starting idle page loader (%i)\n", getpid()); - /* Make sure all the arguments are there! */ - if (nparams != 1) + if ((nparams != 1) || + !strlen (param[0].data.d_string)) path = "welcome.html"; else path = param[0].data.d_string; @@ -882,8 +881,6 @@ run_temp_proc (char *name, gtk_idle_add (idle_load_page, path); - g_print ("idle page loader started (%i)\n", getpid()); - *nreturn_vals = 1; *return_vals = values; @@ -902,12 +899,8 @@ input_callback (GIOChannel *channel, { /* We have some data in the wire - read it */ /* The below will only ever run a single proc */ - g_print ("before gimp_run_temp (%i)\n", getpid()); - gimp_run_temp (); - g_print ("after gimp_run_temp (%i)\n", getpid()); - return TRUE; } @@ -950,32 +943,13 @@ install_temp_proc (void) static gboolean open_url (gchar *path) { - GParam* return_params; - gint n_return_params; + if (! open_browser_dialog (path)) + return FALSE; - g_print ("before run_procedure(%i)\n", getpid()); + install_temp_proc (); + gtk_main (); - return_params = gimp_run_procedure (GIMP_HELP_TEMP_EXT_NAME, - &n_return_params, - PARAM_STRING, path, - PARAM_END); - - g_print ("after run_procedure(%i)\n", getpid()); - - if (return_params[0].data.d_status == STATUS_SUCCESS) - { - return TRUE; - } - else - { - if (! open_browser_dialog (path)) - return FALSE; - - install_temp_proc (); - gtk_main (); - - return TRUE; - } + return TRUE; } MAIN () @@ -1000,7 +974,7 @@ query () "Michael Natterer ", "Sven Neumann & Michael Natterer", "1999", - "/Xtns/Help Browser", + NULL, "", PROC_EXTENSION, nargs, nreturn_vals, @@ -1035,7 +1009,8 @@ run (char *name, case RUN_NONINTERACTIVE: case RUN_WITH_LAST_VALS: /* Make sure all the arguments are there! */ - if (nparams != 2) + if ((nparams != 2) || + !strlen (param[1].data.d_string)) path = g_strdup ("welcome.html"); else path = g_strdup (param[1].data.d_string);