1 /* GIMP - The GNU Image Manipulation Program
2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3 *
4 * gimpfontselect.c
5 * Copyright (C) 2004 Michael Natterer <mitch@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 "libgimpbase/gimpbase.h"
27 #include "libgimpwidgets/gimpwidgets.h"
28
29 #include "widgets-types.h"
30
31 #include "core/gimp.h"
32 #include "core/gimpcontext.h"
33 #include "core/gimpparamspecs.h"
34
35 #include "text/gimpfont.h"
36
37 #include "pdb/gimppdb.h"
38
39 #include "gimpcontainerbox.h"
40 #include "gimpfontfactoryview.h"
41 #include "gimpfontselect.h"
42
43
44 static void gimp_font_select_constructed (GObject *object);
45
46 static GimpValueArray * gimp_font_select_run_callback (GimpPdbDialog *dialog,
47 GimpObject *object,
48 gboolean closing,
49 GError **error);
50
51
G_DEFINE_TYPE(GimpFontSelect,gimp_font_select,GIMP_TYPE_PDB_DIALOG)52 G_DEFINE_TYPE (GimpFontSelect, gimp_font_select, GIMP_TYPE_PDB_DIALOG)
53
54 #define parent_class gimp_font_select_parent_class
55
56
57 static void
58 gimp_font_select_class_init (GimpFontSelectClass *klass)
59 {
60 GObjectClass *object_class = G_OBJECT_CLASS (klass);
61 GimpPdbDialogClass *pdb_class = GIMP_PDB_DIALOG_CLASS (klass);
62
63 object_class->constructed = gimp_font_select_constructed;
64
65 pdb_class->run_callback = gimp_font_select_run_callback;
66 }
67
68 static void
gimp_font_select_init(GimpFontSelect * select)69 gimp_font_select_init (GimpFontSelect *select)
70 {
71 }
72
73 static void
gimp_font_select_constructed(GObject * object)74 gimp_font_select_constructed (GObject *object)
75 {
76 GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object);
77 GtkWidget *content_area;
78
79 G_OBJECT_CLASS (parent_class)->constructed (object);
80
81 dialog->view =
82 gimp_font_factory_view_new (GIMP_VIEW_TYPE_LIST,
83 dialog->context->gimp->font_factory,
84 dialog->context,
85 GIMP_VIEW_SIZE_MEDIUM, 1,
86 dialog->menu_factory);
87
88 gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
89 6 * (GIMP_VIEW_SIZE_MEDIUM + 2),
90 6 * (GIMP_VIEW_SIZE_MEDIUM + 2));
91
92 gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
93
94 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
95 gtk_box_pack_start (GTK_BOX (content_area), dialog->view, TRUE, TRUE, 0);
96 gtk_widget_show (dialog->view);
97 }
98
99 static GimpValueArray *
gimp_font_select_run_callback(GimpPdbDialog * dialog,GimpObject * object,gboolean closing,GError ** error)100 gimp_font_select_run_callback (GimpPdbDialog *dialog,
101 GimpObject *object,
102 gboolean closing,
103 GError **error)
104 {
105 return gimp_pdb_execute_procedure_by_name (dialog->pdb,
106 dialog->caller_context,
107 NULL, error,
108 dialog->callback_name,
109 G_TYPE_STRING, gimp_object_get_name (object),
110 GIMP_TYPE_INT32, closing,
111 G_TYPE_NONE);
112 }
113