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
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-01-05 23:47:06 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 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
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2000-01-05 23:47:06 +08:00
|
|
|
*/
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2023-08-15 06:09:08 +08:00
|
|
|
#include <gegl.h>
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 16:16:21 +08:00
|
|
|
#include "libgimpbase/gimpbase.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"
|
2023-08-15 06:09:08 +08:00
|
|
|
#include "gimpwidgetsutils.h"
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2017-02-12 23:10:50 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
2023-10-17 00:43:17 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include <dwmapi.h>
|
|
|
|
#include <gdk/gdkwin32.h>
|
|
|
|
|
|
|
|
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
|
|
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
|
|
#endif
|
|
|
|
#endif
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpdialog
|
|
|
|
* @title: GimpDialog
|
|
|
|
* @short_description: Constructors for #GtkDialog's and action_areas as
|
|
|
|
* well as other dialog-related stuff.
|
|
|
|
*
|
|
|
|
* Constructors for #GtkDialog's and action_areas as well as other
|
|
|
|
* dialog-related stuff.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-11-21 22:19:15 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-07-09 05:57:05 +08:00
|
|
|
PROP_HELP_FUNC,
|
2011-03-20 19:44:03 +08:00
|
|
|
PROP_HELP_ID,
|
|
|
|
PROP_PARENT
|
2003-11-21 22:19:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
typedef struct _GimpDialogPrivate
|
2011-03-20 20:21:59 +08:00
|
|
|
{
|
|
|
|
GimpHelpFunc help_func;
|
|
|
|
gchar *help_id;
|
|
|
|
GtkWidget *help_button;
|
2023-08-15 06:09:08 +08:00
|
|
|
|
|
|
|
GBytes *window_handle;
|
2024-07-13 17:36:05 +08:00
|
|
|
} GimpDialogPrivate;
|
2011-03-20 20:21:59 +08:00
|
|
|
|
2024-07-13 17:36:05 +08:00
|
|
|
#define GET_PRIVATE(obj) ((GimpDialogPrivate *) (gimp_dialog_get_instance_private (GIMP_DIALOG (obj))))
|
2011-03-20 20:21:59 +08:00
|
|
|
|
|
|
|
|
2023-10-17 00:43:17 +08:00
|
|
|
static void gimp_dialog_constructed (GObject *object);
|
|
|
|
static void gimp_dialog_dispose (GObject *object);
|
|
|
|
static void gimp_dialog_finalize (GObject *object);
|
|
|
|
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);
|
2011-01-13 05:03:33 +08:00
|
|
|
|
2023-10-17 00:43:17 +08:00
|
|
|
static void gimp_dialog_hide (GtkWidget *widget);
|
|
|
|
static gboolean gimp_dialog_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
2011-01-13 05:03:33 +08:00
|
|
|
|
2023-10-17 00:43:17 +08:00
|
|
|
static void gimp_dialog_close (GtkDialog *dialog);
|
2011-01-13 05:03:33 +08:00
|
|
|
|
2023-10-17 00:43:17 +08:00
|
|
|
static void gimp_dialog_response (GtkDialog *dialog,
|
|
|
|
gint response_id);
|
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
|
|
|
|
2023-11-03 03:24:31 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2023-10-17 00:43:17 +08:00
|
|
|
static void gimp_dialog_set_title_bar_theme (GtkWidget *dialog);
|
2023-11-03 03:24:31 +08:00
|
|
|
#endif
|
2000-01-05 23:47:06 +08:00
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpDialog, gimp_dialog, GTK_TYPE_DIALOG)
|
2001-09-21 18:47:19 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_dialog_parent_class
|
2001-09-21 18:47:19 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static gboolean show_help_button = TRUE;
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
2011-01-13 05:03:33 +08:00
|
|
|
object_class->constructed = gimp_dialog_constructed;
|
2005-01-07 06:19:35 +08:00
|
|
|
object_class->dispose = gimp_dialog_dispose;
|
2011-03-20 20:21:59 +08:00
|
|
|
object_class->finalize = gimp_dialog_finalize;
|
2003-11-21 22:19:15 +08:00
|
|
|
object_class->set_property = gimp_dialog_set_property;
|
|
|
|
object_class->get_property = gimp_dialog_get_property;
|
|
|
|
|
2006-01-08 01:47:24 +08:00
|
|
|
widget_class->hide = gimp_dialog_hide;
|
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
|
|
|
/**
|
2011-03-20 19:44:03 +08:00
|
|
|
* GimpDialog:help-func:
|
2004-07-09 06:56:29 +08:00
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.2
|
2004-07-09 06:56:29 +08:00
|
|
|
**/
|
2004-07-09 05:57:05 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_HELP_FUNC,
|
2017-06-07 03:19:17 +08:00
|
|
|
g_param_spec_pointer ("help-func",
|
|
|
|
"Help Func",
|
|
|
|
"The help function to call when F1 is hit",
|
2006-01-31 00:10:56 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-09 05:57:05 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2004-07-09 06:56:29 +08:00
|
|
|
/**
|
2011-03-20 19:44:03 +08:00
|
|
|
* GimpDialog:help-id:
|
2004-07-09 06:56:29 +08:00
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.2
|
2004-07-09 06:56:29 +08:00
|
|
|
**/
|
2004-07-09 05:57:05 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_HELP_ID,
|
2017-06-07 03:19:17 +08:00
|
|
|
g_param_spec_string ("help-id",
|
|
|
|
"Help ID",
|
|
|
|
"The help ID to pass to help-func",
|
2003-11-21 22:19:15 +08:00
|
|
|
NULL,
|
2017-02-12 23:31:23 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2011-03-20 19:44:03 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpDialog:parent:
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.8
|
2011-03-20 19:44:03 +08:00
|
|
|
**/
|
|
|
|
g_object_class_install_property (object_class, PROP_PARENT,
|
2017-06-07 03:19:17 +08:00
|
|
|
g_param_spec_object ("parent",
|
|
|
|
"Parent",
|
|
|
|
"The dialog's parent widget",
|
2011-03-20 19:44:03 +08:00
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
GIMP_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2004-07-09 05:57:05 +08:00
|
|
|
}
|
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_init (GimpDialog *dialog)
|
|
|
|
{
|
2006-01-03 20:40:13 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gimp_dialog_response),
|
|
|
|
NULL);
|
2023-10-17 00:43:17 +08:00
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
2024-04-11 22:59:15 +08:00
|
|
|
g_signal_connect (GTK_WIDGET (dialog), "realize",
|
2023-10-17 00:43:17 +08:00
|
|
|
G_CALLBACK (gimp_dialog_set_title_bar_theme),
|
|
|
|
NULL);
|
|
|
|
#endif
|
2005-12-21 04:35:23 +08:00
|
|
|
}
|
|
|
|
|
2011-01-13 05:03:33 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_constructed (GObject *object)
|
2004-07-09 05:57:05 +08:00
|
|
|
{
|
2011-03-20 20:21:59 +08:00
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (object);
|
2004-07-09 05:57:05 +08:00
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2004-07-09 05:57:05 +08:00
|
|
|
|
2011-03-20 20:21:59 +08:00
|
|
|
if (private->help_func)
|
2024-08-25 05:03:04 +08:00
|
|
|
gimp_help_connect (GTK_WIDGET (object), NULL,
|
2011-03-20 20:21:59 +08:00
|
|
|
private->help_func, private->help_id,
|
2019-08-09 19:11:30 +08:00
|
|
|
object, NULL);
|
2004-07-09 05:57:05 +08:00
|
|
|
|
2011-03-20 20:21:59 +08:00
|
|
|
if (show_help_button && private->help_func && private->help_id)
|
2004-10-05 00:21:52 +08:00
|
|
|
{
|
2018-05-01 05:51:43 +08:00
|
|
|
private->help_button = gtk_dialog_add_button (GTK_DIALOG (object),
|
2023-07-15 08:29:49 +08:00
|
|
|
_("_Help"),
|
2018-05-01 05:51:43 +08:00
|
|
|
GTK_RESPONSE_HELP);
|
2004-10-05 00:21:52 +08:00
|
|
|
}
|
2023-08-15 06:09:08 +08:00
|
|
|
|
|
|
|
gimp_widget_set_native_handle (GTK_WIDGET (object), &private->window_handle);
|
2003-11-21 22:19:15 +08:00
|
|
|
}
|
|
|
|
|
2005-01-07 06:19:35 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_dispose (GObject *object)
|
|
|
|
{
|
2024-06-27 19:32:05 +08:00
|
|
|
GdkDisplay *display = NULL;
|
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (object);
|
2005-01-07 06:19:35 +08:00
|
|
|
|
|
|
|
if (g_main_depth () == 0)
|
|
|
|
{
|
|
|
|
display = gtk_widget_get_display (GTK_WIDGET (object));
|
|
|
|
g_object_ref (display);
|
|
|
|
}
|
|
|
|
|
2024-06-27 19:32:05 +08:00
|
|
|
gimp_widget_free_native_handle (GTK_WIDGET (object), &private->window_handle);
|
|
|
|
|
2005-01-07 06:19:35 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
{
|
|
|
|
gdk_display_flush (display);
|
|
|
|
g_object_unref (display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-20 20:21:59 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (object);
|
|
|
|
|
2017-09-03 21:14:51 +08:00
|
|
|
g_clear_pointer (&private->help_id, g_free);
|
2011-03-20 20:21:59 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (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)
|
|
|
|
{
|
2011-03-20 20:21:59 +08:00
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (object);
|
|
|
|
|
2003-11-21 22:19:15 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-09 05:57:05 +08:00
|
|
|
case PROP_HELP_FUNC:
|
2011-03-20 20:21:59 +08:00
|
|
|
private->help_func = g_value_get_pointer (value);
|
2004-07-09 05:57:05 +08:00
|
|
|
break;
|
2011-03-20 19:44:03 +08:00
|
|
|
|
2004-07-09 05:57:05 +08:00
|
|
|
case PROP_HELP_ID:
|
2016-01-18 00:35:33 +08:00
|
|
|
g_free (private->help_id);
|
2011-03-20 20:21:59 +08:00
|
|
|
private->help_id = g_value_dup_string (value);
|
2016-01-18 00:35:33 +08:00
|
|
|
gimp_help_set_help_data (GTK_WIDGET (object), NULL, private->help_id);
|
2003-11-21 22:19:15 +08:00
|
|
|
break;
|
2011-03-20 19:44:03 +08:00
|
|
|
|
|
|
|
case PROP_PARENT:
|
|
|
|
{
|
|
|
|
GtkWidget *parent = g_value_get_object (value);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
if (GTK_IS_WINDOW (parent))
|
2015-01-09 04:13:41 +08:00
|
|
|
{
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (object),
|
|
|
|
GTK_WINDOW (parent));
|
|
|
|
}
|
2011-03-20 19:44:03 +08:00
|
|
|
else
|
2015-01-09 04:13:41 +08:00
|
|
|
{
|
2023-04-28 05:39:24 +08:00
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (parent);
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
|
|
|
{
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (object),
|
|
|
|
GTK_WINDOW (toplevel));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_window_set_screen (GTK_WINDOW (object),
|
|
|
|
gtk_widget_get_screen (parent));
|
|
|
|
gtk_window_set_position (GTK_WINDOW (object),
|
|
|
|
GTK_WIN_POS_MOUSE);
|
|
|
|
}
|
2015-01-09 04:13:41 +08:00
|
|
|
}
|
2011-03-20 19:44:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-11-21 22:19:15 +08:00
|
|
|
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)
|
|
|
|
{
|
2011-03-20 20:21:59 +08:00
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (object);
|
|
|
|
|
2003-11-21 22:19:15 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-09 05:57:05 +08:00
|
|
|
case PROP_HELP_FUNC:
|
2011-03-20 20:21:59 +08:00
|
|
|
g_value_set_pointer (value, private->help_func);
|
2004-07-09 05:57:05 +08:00
|
|
|
break;
|
2011-03-20 19:44:03 +08:00
|
|
|
|
2004-07-09 05:57:05 +08:00
|
|
|
case PROP_HELP_ID:
|
2011-03-20 20:21:59 +08:00
|
|
|
g_value_set_string (value, private->help_id);
|
2003-11-21 22:19:15 +08:00
|
|
|
break;
|
2011-03-20 19:44:03 +08:00
|
|
|
|
2003-11-21 22:19:15 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2001-09-21 18:47:19 +08:00
|
|
|
}
|
|
|
|
|
2006-01-08 01:47:24 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_hide (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
/* set focus to NULL so focus_out callbacks are invoked synchronously */
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (widget), NULL);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->hide (widget);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2009-03-22 23:42:42 +08:00
|
|
|
if (gtk_widget_get_window (widget))
|
2003-03-20 23:49:48 +08:00
|
|
|
{
|
2004-12-15 08:12:27 +08:00
|
|
|
GdkEvent *event = gdk_event_new (GDK_DELETE);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2009-03-22 23:42:42 +08:00
|
|
|
event->any.window = g_object_ref (gtk_widget_get_window (widget));
|
2003-03-20 23:49:48 +08:00
|
|
|
event->any.send_event = TRUE;
|
|
|
|
|
|
|
|
gtk_main_do_event (event);
|
|
|
|
gdk_event_free (event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 20:40:13 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_response (GtkDialog *dialog,
|
|
|
|
gint response_id)
|
|
|
|
{
|
2018-05-01 05:51:43 +08:00
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (dialog);
|
|
|
|
GtkWidget *widget = gtk_dialog_get_widget_for_response (dialog,
|
|
|
|
response_id);
|
2006-01-03 20:40:13 +08:00
|
|
|
|
2018-05-01 05:51:43 +08:00
|
|
|
if (widget &&
|
|
|
|
(! GTK_IS_BUTTON (widget) ||
|
|
|
|
gtk_widget_get_focus_on_click (widget)))
|
2006-01-03 20:40:13 +08:00
|
|
|
{
|
2018-05-01 05:51:43 +08:00
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
}
|
2006-01-03 20:40:13 +08:00
|
|
|
|
2018-05-01 05:51:43 +08:00
|
|
|
/* if our own help button was activated, abort "response" and
|
|
|
|
* call our help callback.
|
|
|
|
*/
|
|
|
|
if (response_id == GTK_RESPONSE_HELP &&
|
|
|
|
widget == private->help_button)
|
|
|
|
{
|
|
|
|
g_signal_stop_emission_by_name (dialog, "response");
|
2006-01-03 20:45:45 +08:00
|
|
|
|
2018-05-01 05:51:43 +08:00
|
|
|
if (private->help_func)
|
|
|
|
private->help_func (private->help_id, dialog);
|
2006-01-03 20:40:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-29 05:33:03 +08:00
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
2019-07-30 21:32:38 +08:00
|
|
|
* gimp_dialog_new: (skip)
|
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().
|
2020-05-06 01:14:58 +08:00
|
|
|
* @parent: (nullable): The @parent widget of this dialog.
|
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-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
|
|
|
/**
|
2019-07-30 21:32:38 +08:00
|
|
|
* gimp_dialog_new_valist: (skip)
|
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;
|
2018-05-01 05:51:43 +08:00
|
|
|
gboolean use_header_bar;
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
2018-05-01 05:51:43 +08:00
|
|
|
g_object_get (gtk_settings_get_default (),
|
|
|
|
"gtk-dialogs-use-header", &use_header_bar,
|
|
|
|
NULL);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
dialog = g_object_new (GIMP_TYPE_DIALOG,
|
2018-05-01 05:51:43 +08:00
|
|
|
"title", title,
|
|
|
|
"role", role,
|
|
|
|
"modal", (flags & GTK_DIALOG_MODAL),
|
|
|
|
"help-func", help_func,
|
|
|
|
"help-id", help_id,
|
|
|
|
"parent", parent,
|
|
|
|
"use-header-bar", use_header_bar,
|
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)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2006-07-20 05:41:46 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_add_button:
|
|
|
|
* @dialog: The @dialog to add a button to.
|
|
|
|
* @button_text: text of button, or stock ID.
|
|
|
|
* @response_id: response ID for the button.
|
|
|
|
*
|
|
|
|
* This function is essentially the same as gtk_dialog_add_button()
|
|
|
|
* except it ensures there is only one help button and automatically
|
|
|
|
* sets the RESPONSE_OK widget as the default response.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: (type Gtk.Widget) (transfer none): the button widget that was added.
|
2006-07-20 05:41:46 +08:00
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_add_button (GimpDialog *dialog,
|
|
|
|
const gchar *button_text,
|
|
|
|
gint response_id)
|
|
|
|
{
|
|
|
|
GtkWidget *button;
|
2018-05-01 05:51:43 +08:00
|
|
|
gboolean use_header_bar;
|
2006-07-20 05:41:46 +08:00
|
|
|
|
|
|
|
/* hide the automatically added help button if another one is added */
|
|
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
|
|
{
|
2011-03-20 20:21:59 +08:00
|
|
|
GimpDialogPrivate *private = GET_PRIVATE (dialog);
|
|
|
|
|
|
|
|
if (private->help_button)
|
2018-05-01 05:51:43 +08:00
|
|
|
{
|
|
|
|
gtk_widget_destroy (private->help_button);
|
|
|
|
private->help_button = NULL;
|
|
|
|
}
|
2006-07-20 05:41:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
button = gtk_dialog_add_button (GTK_DIALOG (dialog), button_text,
|
|
|
|
response_id);
|
|
|
|
|
2018-05-01 05:51:43 +08:00
|
|
|
g_object_get (dialog,
|
|
|
|
"use-header-bar", &use_header_bar,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (use_header_bar &&
|
2018-05-11 00:25:36 +08:00
|
|
|
(response_id == GTK_RESPONSE_OK ||
|
|
|
|
response_id == GTK_RESPONSE_CANCEL ||
|
|
|
|
response_id == GTK_RESPONSE_CLOSE))
|
2006-07-20 05:41:46 +08:00
|
|
|
{
|
2018-05-01 05:51:43 +08:00
|
|
|
GtkWidget *header = gtk_dialog_get_header_bar (GTK_DIALOG (dialog));
|
|
|
|
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK);
|
|
|
|
|
|
|
|
gtk_container_child_set (GTK_CONTAINER (header), button,
|
|
|
|
"position", 0,
|
|
|
|
NULL);
|
2006-07-20 05:41:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-30 21:32:38 +08:00
|
|
|
* gimp_dialog_add_buttons: (skip)
|
2006-07-20 05:41:46 +08:00
|
|
|
* @dialog: The @dialog to add buttons to.
|
2011-11-26 04:39:55 +08:00
|
|
|
* @...: button_text-response_id pairs.
|
2006-07-20 05:41:46 +08:00
|
|
|
*
|
|
|
|
* This function is essentially the same as gtk_dialog_add_buttons()
|
|
|
|
* except it calls gimp_dialog_add_button() instead of gtk_dialog_add_button()
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_dialog_add_buttons (GimpDialog *dialog,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start (args, dialog);
|
|
|
|
|
|
|
|
gimp_dialog_add_buttons_valist (dialog, args);
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
2003-11-06 23:37:33 +08:00
|
|
|
/**
|
2019-07-30 21:32:38 +08:00
|
|
|
* gimp_dialog_add_buttons_valist: (skip)
|
2003-11-06 23:37:33 +08:00
|
|
|
* @dialog: The @dialog to add buttons to.
|
|
|
|
* @args: The buttons as va_list.
|
|
|
|
*
|
2006-07-20 05:41:46 +08:00
|
|
|
* This function is essentially the same as gimp_dialog_add_buttons()
|
2003-11-06 23:37:33 +08:00
|
|
|
* 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
|
|
|
|
2006-07-20 05:41:46 +08:00
|
|
|
gimp_dialog_add_button (dialog, button_text, response_id);
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
}
|
2003-11-12 02:11:56 +08:00
|
|
|
|
2004-10-05 00:21:52 +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.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: response ID
|
2003-11-12 02:11:56 +08:00
|
|
|
**/
|
|
|
|
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));
|
|
|
|
|
2023-10-17 00:43:17 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
gimp_dialog_set_title_bar_theme (GTK_WIDGET (dialog));
|
|
|
|
#endif
|
|
|
|
|
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);
|
2005-05-27 21:05:26 +08:00
|
|
|
delete_handler = g_signal_connect (dialog, "delete-event",
|
2003-11-12 03:36:40 +08:00
|
|
|
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);
|
|
|
|
|
|
|
|
g_main_loop_run (ri.loop);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2004-10-05 00:21:52 +08:00
|
|
|
|
2019-07-30 19:54:29 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_set_alternative_button_order_from_array:
|
2019-07-31 07:53:55 +08:00
|
|
|
* @dialog: The #GimpDialog
|
|
|
|
* @n_buttons: The size of @order
|
|
|
|
* @order: (array length=n_buttons): array of buttons' response ids.
|
2019-07-30 19:54:29 +08:00
|
|
|
*
|
2023-07-26 21:25:39 +08:00
|
|
|
* Reorder @dialog's buttons if [property@Gtk.Settings:gtk-alternative-button-order]
|
2019-07-30 19:54:29 +08:00
|
|
|
* is set to TRUE. This is mostly a wrapper around the GTK function
|
2023-07-26 21:25:39 +08:00
|
|
|
* [method@Gtk.Dialog.set_alternative_button_order], except it won't
|
|
|
|
* output a deprecation warning.
|
2019-07-30 19:54:29 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_dialog_set_alternative_button_order_from_array (GimpDialog *dialog,
|
|
|
|
gint n_buttons,
|
|
|
|
gint *order)
|
|
|
|
{
|
|
|
|
/* since we don't know yet what to do about alternative button order,
|
|
|
|
* just hide the warnings for now...
|
|
|
|
*/
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2019-08-14 13:57:31 +08:00
|
|
|
gtk_dialog_set_alternative_button_order_from_array (GTK_DIALOG (dialog), n_buttons, order);
|
2019-07-30 19:54:29 +08:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
}
|
|
|
|
|
2023-08-15 06:09:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_get_native_handle:
|
|
|
|
* @dialog: The #GimpDialog
|
|
|
|
*
|
|
|
|
* Returns an opaque data handle representing the window in the currently
|
|
|
|
* running platform. You should not try to use this directly. Usually this is to
|
|
|
|
* be used in functions such as [func@Gimp.brushes_popup] which will allow the
|
|
|
|
* core process to set this [class@Dialog] as parent to the newly created popup.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): an opaque [struct@GLib.Bytes] identifying this
|
|
|
|
* window.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GBytes *
|
|
|
|
gimp_dialog_get_native_handle (GimpDialog *dialog)
|
|
|
|
{
|
2024-07-13 17:36:05 +08:00
|
|
|
return GET_PRIVATE (dialog)->window_handle;
|
2023-08-15 06:09:08 +08:00
|
|
|
}
|
|
|
|
|
2004-10-05 00:21:52 +08:00
|
|
|
/**
|
2019-07-30 21:32:38 +08:00
|
|
|
* gimp_dialogs_show_help_button: (skip)
|
2004-10-05 00:21:52 +08:00
|
|
|
* @show: whether a help button should be added when creating a GimpDialog
|
|
|
|
*
|
|
|
|
* This function is for internal use only.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.2
|
2004-10-05 00:21:52 +08:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_dialogs_show_help_button (gboolean show)
|
|
|
|
{
|
|
|
|
show_help_button = show ? TRUE : FALSE;
|
|
|
|
}
|
2023-10-17 00:43:17 +08:00
|
|
|
|
2023-11-03 03:24:31 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2023-10-17 00:43:17 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_set_title_bar_theme (GtkWidget *dialog)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
gboolean use_dark_mode = FALSE;
|
|
|
|
GdkWindow *window = NULL;
|
|
|
|
|
|
|
|
window = gtk_widget_get_window (GTK_WIDGET (dialog));
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
GtkStyleContext *style;
|
|
|
|
GdkRGBA *color = NULL;
|
|
|
|
|
|
|
|
hwnd = (HWND) gdk_win32_window_get_handle (window);
|
|
|
|
/* Workaround since we don't have access to GimpGuiConfig.
|
|
|
|
* If the background color is below the threshold, then we're
|
|
|
|
* likely in dark mode.
|
|
|
|
*/
|
|
|
|
style = gtk_widget_get_style_context (GTK_WIDGET (dialog));
|
|
|
|
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
|
|
|
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color,
|
|
|
|
NULL);
|
|
|
|
if (color)
|
|
|
|
{
|
|
|
|
if (color->red < 0.5 && color->green < 0.5 && color->blue < 0.5)
|
|
|
|
use_dark_mode = TRUE;
|
|
|
|
|
|
|
|
gdk_rgba_free (color);
|
|
|
|
}
|
|
|
|
|
|
|
|
DwmSetWindowAttribute (hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
|
|
&use_dark_mode, sizeof (use_dark_mode));
|
|
|
|
UpdateWindow (hwnd);
|
|
|
|
}
|
|
|
|
}
|
2023-11-03 03:24:31 +08:00
|
|
|
#endif
|