2003-11-06 23:27:05 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2000-01-05 23:47:06 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdialog.c
|
2003-11-06 23:27:05 +08:00
|
|
|
* Copyright (C) 2000-2003 Michael Natterer <mitch@gimp.org>
|
2000-01-05 23:47:06 +08:00
|
|
|
*
|
|
|
|
* 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.
|
2003-11-06 23:27:05 +08:00
|
|
|
*
|
2000-02-26 11:41:06 +08:00
|
|
|
* 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"
|
|
|
|
|
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
|
|
|
|
2003-11-21 22:19:15 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-07-09 05:57:05 +08:00
|
|
|
PROP_HELP_FUNC,
|
|
|
|
PROP_HELP_ID
|
2003-11-21 22:19:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-11-18 08:04:16 +08:00
|
|
|
static void gimp_dialog_class_init (GimpDialogClass *klass);
|
|
|
|
static void gimp_dialog_init (GimpDialog *dialog);
|
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
|
|
|
|
2004-07-09 05:57:05 +08:00
|
|
|
static GObject * gimp_dialog_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2003-11-21 22:19:15 +08:00
|
|
|
static void gimp_dialog_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_dialog_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2002-11-18 08:04:16 +08:00
|
|
|
static gboolean gimp_dialog_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
2003-03-20 23:49:48 +08:00
|
|
|
static void gimp_dialog_close (GtkDialog *dialog);
|
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,
|
2004-07-09 05:57:05 +08:00
|
|
|
"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)
|
|
|
|
{
|
2004-07-09 05:57:05 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
2001-09-21 18:47:19 +08:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2004-07-09 05:57:05 +08:00
|
|
|
object_class->constructor = gimp_dialog_constructor;
|
2003-11-21 22:19:15 +08:00
|
|
|
object_class->set_property = gimp_dialog_set_property;
|
|
|
|
object_class->get_property = gimp_dialog_get_property;
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
widget_class->delete_event = gimp_dialog_delete_event;
|
2003-03-20 23:49:48 +08:00
|
|
|
|
|
|
|
dialog_class->close = gimp_dialog_close;
|
2003-11-21 22:19:15 +08:00
|
|
|
|
2004-07-09 06:56:29 +08:00
|
|
|
/**
|
|
|
|
* GimpDialog::help-func:
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.2
|
|
|
|
**/
|
2004-07-09 05:57:05 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_HELP_FUNC,
|
|
|
|
g_param_spec_pointer ("help-func", NULL, NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2004-07-09 06:56:29 +08:00
|
|
|
/**
|
|
|
|
* GimpDialog::help-id:
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.2
|
|
|
|
**/
|
2004-07-09 05:57:05 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_HELP_ID,
|
|
|
|
g_param_spec_string ("help-id", NULL, NULL,
|
2003-11-21 22:19:15 +08:00
|
|
|
NULL,
|
2004-07-09 05:57:05 +08:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_dialog_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpHelpFunc help_func;
|
|
|
|
const gchar *help_id;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
help_func = g_object_get_data (object, "gimp-dialog-help-func");
|
|
|
|
help_id = g_object_get_data (object, "gimp-dialog-help-id");
|
|
|
|
|
|
|
|
if (help_func)
|
|
|
|
gimp_help_connect (GTK_WIDGET (object), help_func, help_id, object);
|
|
|
|
|
|
|
|
return object;
|
2003-11-21 22:19:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-09 05:57:05 +08:00
|
|
|
case PROP_HELP_FUNC:
|
|
|
|
g_object_set_data (object, "gimp-dialog-help-func",
|
|
|
|
g_value_get_pointer (value));
|
|
|
|
break;
|
|
|
|
case PROP_HELP_ID:
|
|
|
|
g_object_set_data_full (object, "gimp-dialog-help-id",
|
|
|
|
g_value_dup_string (value),
|
|
|
|
(GDestroyNotify) g_free);
|
2003-11-21 22:19:15 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-09 05:57:05 +08:00
|
|
|
case PROP_HELP_FUNC:
|
|
|
|
g_value_set_pointer (value, g_object_get_data (object,
|
|
|
|
"gimp-dialog-help-func"));
|
|
|
|
break;
|
|
|
|
case PROP_HELP_ID:
|
|
|
|
g_value_set_string (value, g_object_get_data (object,
|
|
|
|
"gimp-dialog-help-id"));
|
2003-11-21 22:19:15 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2001-09-21 18:47:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_init (GimpDialog *dialog)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
|
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)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-03-20 23:49:48 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_close (GtkDialog *dialog)
|
|
|
|
{
|
|
|
|
/* Synthesize delete_event to close dialog. */
|
|
|
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (dialog);
|
|
|
|
|
|
|
|
if (widget->window)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
event = gdk_event_new (GDK_DELETE);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-03-20 23:49:48 +08:00
|
|
|
event->any.window = g_object_ref (widget->window);
|
|
|
|
event->any.send_event = TRUE;
|
|
|
|
|
|
|
|
gtk_main_do_event (event);
|
|
|
|
gdk_event_free (event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-29 05:33:03 +08:00
|
|
|
|
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().
|
2003-11-06 23:27:05 +08:00
|
|
|
* @role: The dialog's @role which will be set with
|
|
|
|
* gtk_window_set_role().
|
|
|
|
* @parent: The @parent widget of this dialog.
|
|
|
|
* @flags: The @flags (see the #GtkDialog documentation).
|
2001-07-31 01:17:36 +08:00
|
|
|
* @help_func: The function which will be called if the user presses "F1".
|
2003-08-24 03:35:05 +08:00
|
|
|
* @help_id: The help_id which will be passed to @help_func.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @...: A %NULL-terminated @va_list destribing the
|
2001-07-31 01:17:36 +08:00
|
|
|
* action_area buttons.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
2003-11-06 23:27:05 +08:00
|
|
|
* Creates a new @GimpDialog widget.
|
|
|
|
*
|
2000-02-26 22:28:08 +08:00
|
|
|
* This function simply packs the action_area arguments passed in "..."
|
2003-11-06 23:27:05 +08:00
|
|
|
* into a @va_list variable and passes everything to gimp_dialog_new_valist().
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
|
|
|
* For a description of the format of the @va_list describing the
|
2003-11-06 23:27:05 +08:00
|
|
|
* action_area buttons see gtk_dialog_new_with_buttons().
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
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 *
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_dialog_new (const gchar *title,
|
|
|
|
const gchar *role,
|
|
|
|
GtkWidget *parent,
|
|
|
|
GtkDialogFlags flags,
|
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
...)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
va_list args;
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
|
|
|
|
g_return_val_if_fail (title != NULL, NULL);
|
|
|
|
g_return_val_if_fail (role != NULL, NULL);
|
|
|
|
|
|
|
|
va_start (args, help_id);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
dialog = gimp_dialog_new_valist (title, role,
|
|
|
|
parent, flags,
|
|
|
|
help_func, help_id,
|
|
|
|
args);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
2003-11-06 23:27:05 +08:00
|
|
|
* gimp_dialog_new_valist:
|
2001-07-31 01:17:36 +08:00
|
|
|
* @title: The dialog's title which will be set with
|
|
|
|
* gtk_window_set_title().
|
2003-11-06 23:27:05 +08:00
|
|
|
* @role: The dialog's @role which will be set with
|
|
|
|
* gtk_window_set_role().
|
2004-02-28 20:37:49 +08:00
|
|
|
* @parent: The @parent widget of this dialog or %NULL.
|
2003-11-06 23:27:05 +08:00
|
|
|
* @flags: The @flags (see the #GtkDialog documentation).
|
2001-07-31 01:17:36 +08:00
|
|
|
* @help_func: The function which will be called if the user presses "F1".
|
2003-08-24 03:35:05 +08:00
|
|
|
* @help_id: The help_id which will be passed to @help_func.
|
2003-11-06 23:37:33 +08:00
|
|
|
* @args: A @va_list destribing the action_area buttons.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
2004-02-29 05:33:03 +08:00
|
|
|
* Creates a new @GimpDialog widget. If a GtkWindow is specified as
|
|
|
|
* @parent then the dialog will be made transient for this window.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
2003-11-06 23:27:05 +08:00
|
|
|
* For a description of the format of the @va_list describing the
|
|
|
|
* action_area buttons see gtk_dialog_new_with_buttons().
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
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 *
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_dialog_new_valist (const gchar *title,
|
|
|
|
const gchar *role,
|
|
|
|
GtkWidget *parent,
|
|
|
|
GtkDialogFlags flags,
|
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
va_list args)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
g_return_val_if_fail (title != NULL, NULL);
|
2003-11-06 23:27:05 +08:00
|
|
|
g_return_val_if_fail (role != NULL, NULL);
|
2004-02-28 20:37:49 +08:00
|
|
|
g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
dialog = g_object_new (GIMP_TYPE_DIALOG,
|
2004-07-09 05:57:05 +08:00
|
|
|
"title", title,
|
|
|
|
"role", role,
|
|
|
|
"modal", (flags & GTK_DIALOG_MODAL),
|
|
|
|
"help-func", help_func,
|
|
|
|
"help-id", help_id,
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
2001-09-21 18:47:19 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
if (GTK_IS_WINDOW (parent))
|
|
|
|
{
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
|
|
|
GTK_WINDOW (parent));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-08 23:32:38 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (dialog),
|
|
|
|
gtk_widget_get_screen (parent));
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
2002-01-26 02:34:33 +08:00
|
|
|
|
2004-02-29 05:33:03 +08:00
|
|
|
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
|
|
|
|
g_signal_connect_object (parent, "destroy",
|
|
|
|
G_CALLBACK (gimp_dialog_close),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_dialog_add_buttons_valist (GIMP_DIALOG (dialog), args);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return dialog;
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:37:33 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_add_buttons_valist:
|
|
|
|
* @dialog: The @dialog to add buttons to.
|
|
|
|
* @args: The buttons as va_list.
|
|
|
|
*
|
|
|
|
* This function is essentially the same as gtk_dialog_add_buttons()
|
|
|
|
* except it takes a va_list instead of '...'
|
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_dialog_add_buttons_valist (GimpDialog *dialog,
|
|
|
|
va_list args)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
const gchar *button_text;
|
|
|
|
gint response_id;
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG (dialog));
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
while ((button_text = va_arg (args, const gchar *)))
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
response_id = va_arg (args, gint);
|
2000-01-07 00:40:17 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
}
|
2003-11-12 02:11:56 +08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GtkDialog *dialog;
|
|
|
|
gint response_id;
|
|
|
|
GMainLoop *loop;
|
|
|
|
gboolean destroyed;
|
|
|
|
} RunInfo;
|
|
|
|
|
|
|
|
static void
|
|
|
|
run_shutdown_loop (RunInfo *ri)
|
|
|
|
{
|
|
|
|
if (g_main_loop_is_running (ri->loop))
|
|
|
|
g_main_loop_quit (ri->loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
run_unmap_handler (GtkDialog *dialog,
|
|
|
|
RunInfo *ri)
|
|
|
|
{
|
|
|
|
run_shutdown_loop (ri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
run_response_handler (GtkDialog *dialog,
|
|
|
|
gint response_id,
|
|
|
|
RunInfo *ri)
|
|
|
|
{
|
|
|
|
ri->response_id = response_id;
|
|
|
|
|
|
|
|
run_shutdown_loop (ri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
run_delete_handler (GtkDialog *dialog,
|
|
|
|
GdkEventAny *event,
|
|
|
|
RunInfo *ri)
|
|
|
|
{
|
|
|
|
run_shutdown_loop (ri);
|
|
|
|
|
|
|
|
return TRUE; /* Do not destroy */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
run_destroy_handler (GtkDialog *dialog,
|
|
|
|
RunInfo *ri)
|
|
|
|
{
|
|
|
|
/* shutdown_loop will be called by run_unmap_handler */
|
|
|
|
|
|
|
|
ri->destroyed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_dialog_run:
|
|
|
|
* @dialog: a #GimpDialog
|
|
|
|
*
|
|
|
|
* This function does exactly the same as gtk_dialog_run() except it
|
|
|
|
* does not make the dialog modal while the #GMainLoop is running.
|
|
|
|
*
|
|
|
|
* Return value: response ID
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gimp_dialog_run (GimpDialog *dialog)
|
|
|
|
{
|
|
|
|
RunInfo ri = { NULL, GTK_RESPONSE_NONE, NULL };
|
|
|
|
gulong response_handler;
|
|
|
|
gulong unmap_handler;
|
|
|
|
gulong destroy_handler;
|
|
|
|
gulong delete_handler;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG (dialog), -1);
|
|
|
|
|
|
|
|
g_object_ref (dialog);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
2003-11-12 03:36:40 +08:00
|
|
|
response_handler = g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (run_response_handler),
|
|
|
|
&ri);
|
|
|
|
unmap_handler = g_signal_connect (dialog, "unmap",
|
|
|
|
G_CALLBACK (run_unmap_handler),
|
|
|
|
&ri);
|
|
|
|
delete_handler = g_signal_connect (dialog, "delete_event",
|
|
|
|
G_CALLBACK (run_delete_handler),
|
|
|
|
&ri);
|
|
|
|
destroy_handler = g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (run_destroy_handler),
|
|
|
|
&ri);
|
2003-11-12 02:11:56 +08:00
|
|
|
|
|
|
|
ri.loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
|
|
|
GDK_THREADS_LEAVE ();
|
|
|
|
g_main_loop_run (ri.loop);
|
|
|
|
GDK_THREADS_ENTER ();
|
|
|
|
|
|
|
|
g_main_loop_unref (ri.loop);
|
|
|
|
|
2003-11-12 03:36:40 +08:00
|
|
|
ri.loop = NULL;
|
2003-11-12 02:11:56 +08:00
|
|
|
ri.destroyed = FALSE;
|
|
|
|
|
|
|
|
if (!ri.destroyed)
|
|
|
|
{
|
|
|
|
g_signal_handler_disconnect (dialog, response_handler);
|
|
|
|
g_signal_handler_disconnect (dialog, unmap_handler);
|
|
|
|
g_signal_handler_disconnect (dialog, delete_handler);
|
|
|
|
g_signal_handler_disconnect (dialog, destroy_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (dialog);
|
|
|
|
|
|
|
|
return ri.response_id;
|
|
|
|
}
|