1 /* GIMP - The GNU Image Manipulation Program
2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3 *
4 * gimpmessagedialog.c
5 * Copyright (C) 2004 Sven Neumann <sven@gimp.org>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21 #include "config.h"
22
23 #include <gegl.h>
24 #include <gtk/gtk.h>
25
26 #include "libgimpwidgets/gimpwidgets.h"
27
28 #include "widgets-types.h"
29
30 #include "gimpmessagebox.h"
31 #include "gimpmessagedialog.h"
32
33
G_DEFINE_TYPE(GimpMessageDialog,gimp_message_dialog,GIMP_TYPE_DIALOG)34 G_DEFINE_TYPE (GimpMessageDialog, gimp_message_dialog, GIMP_TYPE_DIALOG)
35
36
37 static void
38 gimp_message_dialog_class_init (GimpMessageDialogClass *klass)
39 {
40 }
41
42 static void
gimp_message_dialog_init(GimpMessageDialog * dialog)43 gimp_message_dialog_init (GimpMessageDialog *dialog)
44 {
45 }
46
47
48 /* public functions */
49
50 GtkWidget *
gimp_message_dialog_new(const gchar * title,const gchar * icon_name,GtkWidget * parent,GtkDialogFlags flags,GimpHelpFunc help_func,const gchar * help_id,...)51 gimp_message_dialog_new (const gchar *title,
52 const gchar *icon_name,
53 GtkWidget *parent,
54 GtkDialogFlags flags,
55 GimpHelpFunc help_func,
56 const gchar *help_id,
57 ...)
58 {
59 GimpMessageDialog *dialog;
60 va_list args;
61
62 g_return_val_if_fail (title != NULL, NULL);
63 g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
64
65 dialog = g_object_new (GIMP_TYPE_MESSAGE_DIALOG,
66 "title", title,
67 "role", "gimp-message-dialog",
68 "modal", (flags & GTK_DIALOG_MODAL),
69 "help-func", help_func,
70 "help-id", help_id,
71 NULL);
72
73 if (parent)
74 {
75 if (! GTK_IS_WINDOW (parent))
76 parent = gtk_widget_get_toplevel (parent);
77
78 if (GTK_IS_WINDOW (parent))
79 {
80 gtk_window_set_transient_for (GTK_WINDOW (dialog),
81 GTK_WINDOW (parent));
82
83 if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
84 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
85 }
86 else
87 {
88 gtk_window_set_screen (GTK_WINDOW (dialog),
89 gtk_widget_get_screen (parent));
90 }
91 }
92
93 va_start (args, help_id);
94
95 gimp_dialog_add_buttons_valist (GIMP_DIALOG (dialog), args);
96
97 va_end (args);
98
99 dialog->box = g_object_new (GIMP_TYPE_MESSAGE_BOX,
100 "icon-name", icon_name,
101 NULL);
102
103 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
104 GTK_WIDGET (dialog->box), FALSE, FALSE, 0);
105 gtk_widget_show (GTK_WIDGET (dialog->box));
106
107 return GTK_WIDGET (dialog);
108 }
109