1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * gimpfontfactoryview.c
5  * Copyright (C) 2018 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 "libgimpwidgets/gimpwidgets.h"
27 
28 #include "widgets-types.h"
29 
30 #include "core/gimpcontainer.h"
31 #include "core/gimpcontext.h"
32 #include "core/gimpdatafactory.h"
33 
34 #include "text/gimpfont.h"
35 
36 #include "gimpfontfactoryview.h"
37 #include "gimpcontainerview.h"
38 #include "gimpmenufactory.h"
39 #include "gimpviewrenderer.h"
40 
41 #include "gimp-intl.h"
42 
43 
G_DEFINE_TYPE(GimpFontFactoryView,gimp_font_factory_view,GIMP_TYPE_DATA_FACTORY_VIEW)44 G_DEFINE_TYPE (GimpFontFactoryView, gimp_font_factory_view,
45                GIMP_TYPE_DATA_FACTORY_VIEW)
46 
47 #define parent_class gimp_font_factory_view_parent_class
48 
49 
50 static void
51 gimp_font_factory_view_class_init (GimpFontFactoryViewClass *klass)
52 {
53 }
54 
55 static void
gimp_font_factory_view_init(GimpFontFactoryView * view)56 gimp_font_factory_view_init (GimpFontFactoryView *view)
57 {
58 }
59 
60 GtkWidget *
gimp_font_factory_view_new(GimpViewType view_type,GimpDataFactory * factory,GimpContext * context,gint view_size,gint view_border_width,GimpMenuFactory * menu_factory)61 gimp_font_factory_view_new (GimpViewType     view_type,
62                             GimpDataFactory *factory,
63                             GimpContext     *context,
64                             gint             view_size,
65                             gint             view_border_width,
66                             GimpMenuFactory *menu_factory)
67 {
68   GimpFontFactoryView *factory_view;
69   GimpContainerEditor *editor;
70 
71   g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
72   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
73   g_return_val_if_fail (view_size > 0 &&
74                         view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
75   g_return_val_if_fail (view_border_width >= 0 &&
76                         view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
77                         NULL);
78   g_return_val_if_fail (menu_factory == NULL ||
79                         GIMP_IS_MENU_FACTORY (menu_factory), NULL);
80 
81   factory_view = g_object_new (GIMP_TYPE_FONT_FACTORY_VIEW,
82                                "view-type",         view_type,
83                                "data-factory",      factory,
84                                "context",           context,
85                                "view-size",         view_size,
86                                "view-border-width", view_border_width,
87                                "menu-factory",      menu_factory,
88                                "menu-identifier",   "<Fonts>",
89                                "ui-path",           "/fonts-popup",
90                                "action-group",      "fonts",
91                                NULL);
92 
93   editor = GIMP_CONTAINER_EDITOR (factory_view);
94 
95   gimp_container_editor_bind_to_async_set (editor,
96                                            gimp_data_factory_get_async_set (factory),
97                                            _("Loading fonts (this may take "
98                                              "a while...)"));
99 
100   return GTK_WIDGET (factory_view);
101 }
102