2000-02-26 11:41:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2000-01-05 23:47:06 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdialog.c
|
|
|
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2000-02-26 11:41:06 +08:00
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-01-05 23:47:06 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-03-17 03:14:04 +08:00
|
|
|
#include <string.h> /* strcmp */
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "gimpwidgetstypes.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include "gimpdialog.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimphelpui.h"
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
typedef void (* GimpDialogCancelCallback) (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static void gimp_dialog_class_init (GimpDialogClass *klass);
|
|
|
|
static void gimp_dialog_init (GimpDialog *dialog);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static gboolean gimp_dialog_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static GtkDialogClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_dialog_get_type (void)
|
|
|
|
{
|
|
|
|
static GType dialog_type = 0;
|
|
|
|
|
|
|
|
if (! dialog_type)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
{
|
2001-09-21 18:47:19 +08:00
|
|
|
static const GTypeInfo dialog_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpDialogClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_dialog_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpDialog),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_dialog_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
|
|
|
|
"GimpDialog",
|
|
|
|
&dialog_info, 0);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
return dialog_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_class_init (GimpDialogClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
widget_class->delete_event = gimp_dialog_delete_event;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_init (GimpDialog *dialog)
|
|
|
|
{
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dialog_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event)
|
|
|
|
{
|
|
|
|
GimpDialogCancelCallback cancel_callback;
|
|
|
|
GtkWidget *cancel_widget;
|
|
|
|
gpointer cancel_data;
|
|
|
|
|
|
|
|
cancel_callback = (GimpDialogCancelCallback)
|
|
|
|
g_object_get_data (G_OBJECT (widget), "gimp_dialog_cancel_callback");
|
|
|
|
|
|
|
|
cancel_widget = (GtkWidget *)
|
|
|
|
g_object_get_data (G_OBJECT (widget), "gimp_dialog_cancel_widget");
|
|
|
|
|
|
|
|
cancel_data =
|
|
|
|
g_object_get_data (G_OBJECT (widget), "gimp_dialog_cancel_data");
|
|
|
|
|
|
|
|
/* the cancel callback has to destroy the dialog */
|
|
|
|
if (cancel_callback)
|
|
|
|
{
|
|
|
|
cancel_callback (cancel_widget, cancel_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_new:
|
2001-07-31 01:17:36 +08:00
|
|
|
* @title: The dialog's title which will be set with
|
|
|
|
* gtk_window_set_title().
|
2000-02-26 22:28:08 +08:00
|
|
|
* @wmclass_name: The dialog's @wmclass_name which will be set with
|
|
|
|
* gtk_window_set_wmclass(). The @wmclass_class will be
|
|
|
|
* automatically set to "Gimp".
|
2001-07-31 01:17:36 +08:00
|
|
|
* @help_func: The function which will be called if the user presses "F1".
|
|
|
|
* @help_data: The data pointer which will be passed to @help_func.
|
|
|
|
* @position: The dialog's initial position which will be set with
|
|
|
|
* gtk_window_set_position().
|
2000-02-26 22:28:08 +08:00
|
|
|
* @allow_shrink: The dialog's @allow_shrink flag, ...
|
2001-07-31 01:17:36 +08:00
|
|
|
* @allow_grow: ... it't @allow_grow flag and ...
|
|
|
|
* @auto_shrink: ... it's @auto_shrink flag which will all be set with
|
|
|
|
* gtk_window_set_policy().
|
|
|
|
* @...: A #NULL terminated @va_list destribing the
|
|
|
|
* action_area buttons.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
|
|
|
* This function simply packs the action_area arguments passed in "..."
|
|
|
|
* into a @va_list variable and passes everything to gimp_dialog_newv().
|
|
|
|
*
|
|
|
|
* For a description of the format of the @va_list describing the
|
|
|
|
* action_area buttons see gimp_dialog_create_action_areav().
|
|
|
|
*
|
2001-09-21 18:47:19 +08:00
|
|
|
* Returns: A #GimpDialog.
|
2001-07-31 01:17:36 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_new (const gchar *title,
|
|
|
|
const gchar *wmclass_name,
|
|
|
|
GimpHelpFunc help_func,
|
2000-11-18 08:25:42 +08:00
|
|
|
const gchar *help_data,
|
2000-01-05 23:47:06 +08:00
|
|
|
GtkWindowPosition position,
|
|
|
|
gint allow_shrink,
|
|
|
|
gint allow_grow,
|
|
|
|
gint auto_shrink,
|
|
|
|
|
|
|
|
/* specify action area buttons as va_list:
|
2001-08-01 07:28:56 +08:00
|
|
|
* const gchar *label,
|
|
|
|
* GCallback callback,
|
|
|
|
* gpointer callback_data,
|
|
|
|
* GObject *slot_object,
|
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
* gboolean default_action,
|
|
|
|
* gboolean connect_delete,
|
2000-01-05 23:47:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_newv:
|
2001-07-31 01:17:36 +08:00
|
|
|
* @title: The dialog's title which will be set with
|
|
|
|
* gtk_window_set_title().
|
2000-02-26 22:28:08 +08:00
|
|
|
* @wmclass_name: The dialog's @wmclass_name which will be set with
|
|
|
|
* gtk_window_set_wmclass(). The @wmclass_class will be
|
|
|
|
* automatically set to "Gimp".
|
2001-07-31 01:17:36 +08:00
|
|
|
* @help_func: The function which will be called if the user presses "F1".
|
|
|
|
* @help_data: The data pointer which will be passed to @help_func.
|
|
|
|
* @position: The dialog's initial position which will be set with
|
|
|
|
* gtk_window_set_position().
|
2000-02-26 22:28:08 +08:00
|
|
|
* @allow_shrink: The dialog's @allow_shrink flag, ...
|
2001-07-31 01:17:36 +08:00
|
|
|
* @allow_grow: ... it't @allow_grow flag and ...
|
|
|
|
* @auto_shrink: ... it's @auto_shrink flag which will all be set with
|
|
|
|
* gtk_window_set_policy().
|
|
|
|
* @args: A @va_list as obtained with va_start() describing the
|
|
|
|
* action_area buttons.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
|
|
|
* This function performs all neccessary setps to set up a standard GIMP
|
|
|
|
* dialog.
|
|
|
|
*
|
|
|
|
* The @va_list describing the action_area buttons will be passed to
|
|
|
|
* gimp_dialog_create_action_areav().
|
|
|
|
*
|
2001-09-21 18:47:19 +08:00
|
|
|
* Returns: A #GimpDialog.
|
2001-08-01 07:28:56 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_newv (const gchar *title,
|
|
|
|
const gchar *wmclass_name,
|
|
|
|
GimpHelpFunc help_func,
|
2000-11-18 08:25:42 +08:00
|
|
|
const gchar *help_data,
|
2000-01-05 23:47:06 +08:00
|
|
|
GtkWindowPosition position,
|
|
|
|
gint allow_shrink,
|
|
|
|
gint allow_grow,
|
|
|
|
gint auto_shrink,
|
|
|
|
va_list args)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
g_return_val_if_fail (title != NULL, NULL);
|
|
|
|
g_return_val_if_fail (wmclass_name != NULL, NULL);
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
dialog = g_object_new (GIMP_TYPE_DIALOG, NULL);
|
|
|
|
|
2000-01-05 23:47:06 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
2000-02-26 22:28:08 +08:00
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (dialog), wmclass_name, "Gimp");
|
2000-01-05 23:47:06 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), position);
|
2002-01-26 02:34:33 +08:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: need a new API for gimp_dialog_new()
|
|
|
|
#endif
|
|
|
|
|
2000-01-05 23:47:06 +08:00
|
|
|
gtk_window_set_policy (GTK_WINDOW (dialog),
|
|
|
|
allow_shrink, allow_grow, auto_shrink);
|
|
|
|
|
|
|
|
/* prepare the action_area */
|
2001-09-21 18:47:19 +08:00
|
|
|
gimp_dialog_create_action_areav (GIMP_DIALOG (dialog), args);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
/* connect the "F1" help key */
|
|
|
|
if (help_func)
|
2001-08-01 07:28:56 +08:00
|
|
|
gimp_help_connect (dialog, help_func, help_data);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_create_action_area:
|
2001-09-21 18:47:19 +08:00
|
|
|
* @dialog: The #GimpDialog you want to create the action_area for.
|
2001-07-31 01:17:36 +08:00
|
|
|
* @...: A #NULL terminated @va_list destribing the action_area buttons.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
|
|
|
* This function simply packs the action_area arguments passed in "..."
|
|
|
|
* into a @va_list variable and passes everything to
|
|
|
|
* gimp_dialog_create_action_areav().
|
2001-08-01 07:28:56 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
2001-09-21 18:47:19 +08:00
|
|
|
gimp_dialog_create_action_area (GimpDialog *dialog,
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
/* specify action area buttons as va_list:
|
2000-11-18 08:25:42 +08:00
|
|
|
* const gchar *label,
|
2001-07-31 01:17:36 +08:00
|
|
|
* GCallback callback,
|
|
|
|
* gpointer callback_data,
|
|
|
|
* GObject *slot_object,
|
2000-01-05 23:47:06 +08:00
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
* gboolean default_action,
|
|
|
|
* gboolean connect_delete,
|
|
|
|
*/
|
|
|
|
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start (args, dialog);
|
|
|
|
|
|
|
|
gimp_dialog_create_action_areav (dialog, args);
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_create_action_areav:
|
2001-09-21 18:47:19 +08:00
|
|
|
* @dialog: The #GimpDialog you want to create the action_area for.
|
2000-02-26 22:28:08 +08:00
|
|
|
* @args: A @va_list as obtained with va_start() describing the action_area
|
2001-02-07 03:00:48 +08:00
|
|
|
* buttons.
|
2001-02-07 01:53:33 +08:00
|
|
|
*
|
|
|
|
* Please note that the delete_event will only be connected to the first
|
|
|
|
* button with the "connect_delete" boolean set to true. It is possible
|
|
|
|
* to just connect the delete_event to a callback without adding a new
|
|
|
|
* button with a special label "_delete_event_", connect_delete == true
|
|
|
|
* and callback != NULL.
|
2001-08-01 07:28:56 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
2001-09-21 18:47:19 +08:00
|
|
|
gimp_dialog_create_action_areav (GimpDialog *dialog,
|
|
|
|
va_list args)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2001-07-31 01:17:36 +08:00
|
|
|
GtkWidget *button;
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
/* action area variables */
|
2001-07-31 01:17:36 +08:00
|
|
|
const gchar *label;
|
|
|
|
GCallback callback;
|
|
|
|
gpointer callback_data;
|
|
|
|
GObject *slot_object;
|
|
|
|
GtkWidget **widget_ptr;
|
|
|
|
gboolean default_action;
|
|
|
|
gboolean connect_delete;
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
gboolean delete_connected = FALSE;
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG (dialog));
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
label = va_arg (args, const gchar *);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
/* the action_area buttons */
|
|
|
|
while (label)
|
|
|
|
{
|
2001-07-31 01:17:36 +08:00
|
|
|
callback = va_arg (args, GCallback);
|
|
|
|
callback_data = va_arg (args, gpointer);
|
|
|
|
slot_object = va_arg (args, GObject *);
|
2000-01-27 09:22:27 +08:00
|
|
|
widget_ptr = va_arg (args, GtkWidget **);
|
2000-01-05 23:47:06 +08:00
|
|
|
default_action = va_arg (args, gboolean);
|
|
|
|
connect_delete = va_arg (args, gboolean);
|
|
|
|
|
2001-07-31 01:17:36 +08:00
|
|
|
if (slot_object == (GObject *) 1)
|
|
|
|
slot_object = G_OBJECT (dialog);
|
2000-01-07 00:40:17 +08:00
|
|
|
|
2001-07-31 01:17:36 +08:00
|
|
|
if (callback_data == NULL)
|
|
|
|
callback_data = dialog;
|
2000-01-07 00:40:17 +08:00
|
|
|
|
2001-02-07 01:53:33 +08:00
|
|
|
/*
|
|
|
|
* Dont create a button if the label is "_delete_event_" --
|
|
|
|
* some dialogs just need to connect to the delete_event from
|
|
|
|
* the window...
|
|
|
|
*/
|
|
|
|
if (connect_delete &&
|
|
|
|
callback &&
|
2001-07-31 01:17:36 +08:00
|
|
|
! delete_connected &&
|
2001-02-07 01:53:33 +08:00
|
|
|
strcmp (label, "_delete_event_") == 0)
|
|
|
|
{
|
|
|
|
if (widget_ptr)
|
|
|
|
*widget_ptr = GTK_WIDGET (dialog);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-07-31 01:17:36 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "gimp_dialog_cancel_callback",
|
|
|
|
callback);
|
|
|
|
g_object_set_data (G_OBJECT (dialog), "gimp_dialog_cancel_widget",
|
|
|
|
slot_object ? slot_object : G_OBJECT (dialog));
|
2001-09-21 18:47:19 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "gimp_dialog_cancel_data",
|
|
|
|
callback_data);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
delete_connected = TRUE;
|
|
|
|
}
|
|
|
|
|
2001-02-07 01:53:33 +08:00
|
|
|
/* otherwise just create the requested button. */
|
|
|
|
else
|
|
|
|
{
|
2001-09-21 18:47:19 +08:00
|
|
|
button = gtk_dialog_add_button (GTK_DIALOG (dialog),
|
|
|
|
label, GTK_RESPONSE_NONE);
|
2001-02-07 01:53:33 +08:00
|
|
|
|
|
|
|
if (callback)
|
|
|
|
{
|
|
|
|
if (slot_object)
|
2001-07-31 01:17:36 +08:00
|
|
|
g_signal_connect_swapped (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (callback),
|
|
|
|
slot_object);
|
2001-02-07 01:53:33 +08:00
|
|
|
else
|
2001-07-31 01:17:36 +08:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (callback),
|
|
|
|
callback_data);
|
2001-02-07 01:53:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widget_ptr)
|
|
|
|
*widget_ptr = button;
|
|
|
|
|
2001-07-31 01:17:36 +08:00
|
|
|
if (connect_delete && callback && ! delete_connected)
|
2001-02-07 01:53:33 +08:00
|
|
|
{
|
2001-09-21 18:47:19 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "gimp_dialog_cancel_callback",
|
2001-07-31 01:17:36 +08:00
|
|
|
callback);
|
2001-09-21 18:47:19 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "gimp_dialog_cancel_widget",
|
2001-07-31 01:17:36 +08:00
|
|
|
slot_object ? slot_object : G_OBJECT (button));
|
2001-09-21 18:47:19 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "gimp_dialog_cancel_data",
|
|
|
|
callback_data);
|
2001-02-07 01:53:33 +08:00
|
|
|
|
|
|
|
delete_connected = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (default_action)
|
|
|
|
gtk_widget_grab_default (button);
|
|
|
|
}
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2000-02-14 21:23:12 +08:00
|
|
|
label = va_arg (args, gchar *);
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
}
|