1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * gimpdialogfactory.h
5  * Copyright (C) 2001 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 #ifndef __GIMP_DIALOG_FACTORY_H__
22 #define __GIMP_DIALOG_FACTORY_H__
23 
24 
25 #include "core/gimpobject.h"
26 
27 #define GIMP_DIALOG_VISIBILITY_KEY "gimp-dialog-visibility"
28 
29 typedef enum
30 {
31   GIMP_DIALOG_VISIBILITY_UNKNOWN = 0,
32   GIMP_DIALOG_VISIBILITY_INVISIBLE,
33   GIMP_DIALOG_VISIBILITY_VISIBLE,
34   GIMP_DIALOG_VISIBILITY_HIDDEN
35 } GimpDialogVisibilityState;
36 
37 
38 /* In order to support constructors of various types, these functions
39  * takes the union of the set of arguments required for each type of
40  * widget constructor. If this set becomes too big we can consider
41  * passing a struct or use varargs.
42  */
43 typedef GtkWidget * (* GimpDialogNewFunc)     (GimpDialogFactory      *factory,
44                                                GimpContext            *context,
45                                                GimpUIManager          *ui_manager,
46                                                gint                    view_size);
47 
48 
49 struct _GimpDialogFactoryEntry
50 {
51   gchar                *identifier;
52   gchar                *name;
53   gchar                *blurb;
54   gchar                *icon_name;
55   gchar                *help_id;
56 
57   GimpDialogNewFunc     new_func;
58   GimpDialogRestoreFunc restore_func;
59   gint                  view_size;
60 
61   gboolean              singleton;
62   gboolean              session_managed;
63   gboolean              remember_size;
64   gboolean              remember_if_open;
65 
66   /* If TRUE the visibility of the dialog is toggleable */
67   gboolean              hideable;
68 
69   /* If TRUE the entry is for a GimpImageWindow, FALSE otherwise */
70   gboolean              image_window;
71 
72   /* If TRUE the entry is for a dockable, FALSE otherwise */
73   gboolean              dockable;
74 };
75 
76 
77 #define GIMP_TYPE_DIALOG_FACTORY            (gimp_dialog_factory_get_type ())
78 #define GIMP_DIALOG_FACTORY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DIALOG_FACTORY, GimpDialogFactory))
79 #define GIMP_DIALOG_FACTORY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DIALOG_FACTORY, GimpDialogFactoryClass))
80 #define GIMP_IS_DIALOG_FACTORY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DIALOG_FACTORY))
81 #define GIMP_IS_DIALOG_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DIALOG_FACTORY))
82 #define GIMP_DIALOG_FACTORY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DIALOG_FACTORY, GimpDialogFactoryClass))
83 
84 
85 typedef struct _GimpDialogFactoryPrivate  GimpDialogFactoryPrivate;
86 typedef struct _GimpDialogFactoryClass    GimpDialogFactoryClass;
87 
88 /**
89  * GimpDialogFactory:
90  *
91  * A factory with the main purpose of creating toplevel windows and
92  * position them according to the session information kept within the
93  * factory. Over time it has accumulated more functionality than this.
94  */
95 struct _GimpDialogFactory
96 {
97   GimpObject                parent_instance;
98 
99   GimpDialogFactoryPrivate *p;
100 };
101 
102 struct _GimpDialogFactoryClass
103 {
104   GimpObjectClass  parent_class;
105 
106   void (* dock_window_added)   (GimpDialogFactory *factory,
107                                 GimpDockWindow    *dock_window);
108   void (* dock_window_removed) (GimpDialogFactory *factory,
109                                 GimpDockWindow    *dock_window);
110 };
111 
112 
113 GType               gimp_dialog_factory_get_type             (void) G_GNUC_CONST;
114 GimpDialogFactory * gimp_dialog_factory_new                  (const gchar             *name,
115                                                               GimpContext             *context,
116                                                               GimpMenuFactory         *menu_factory);
117 
118 void                gimp_dialog_factory_register_entry       (GimpDialogFactory       *factory,
119                                                               const gchar             *identifier,
120                                                               const gchar             *name,
121                                                               const gchar             *blurb,
122                                                               const gchar             *icon_name,
123                                                               const gchar             *help_id,
124                                                               GimpDialogNewFunc        new_func,
125                                                               GimpDialogRestoreFunc    restore_func,
126                                                               gint                     view_size,
127                                                               gboolean                 singleton,
128                                                               gboolean                 session_managed,
129                                                               gboolean                 remember_size,
130                                                               gboolean                 remember_if_open,
131                                                               gboolean                 hideable,
132                                                               gboolean                 image_window,
133                                                               gboolean                 dockable);
134 
135 GimpDialogFactoryEntry *
136                     gimp_dialog_factory_find_entry           (GimpDialogFactory       *factory,
137                                                               const gchar             *identifier);
138 GimpSessionInfo *   gimp_dialog_factory_find_session_info    (GimpDialogFactory       *factory,
139                                                               const gchar             *identifier);
140 GtkWidget *         gimp_dialog_factory_find_widget          (GimpDialogFactory       *factory,
141                                                               const gchar             *identifiers);
142 
143 GtkWidget *         gimp_dialog_factory_dialog_new           (GimpDialogFactory       *factory,
144                                                               GdkScreen               *screen,
145                                                               gint                     monitor,
146                                                               GimpUIManager           *ui_manager,
147                                                               const gchar             *identifier,
148                                                               gint                     view_size,
149                                                               gboolean                 present);
150 
151 GimpContext *       gimp_dialog_factory_get_context          (GimpDialogFactory       *factory);
152 GimpMenuFactory *   gimp_dialog_factory_get_menu_factory     (GimpDialogFactory       *factory);
153 GList *             gimp_dialog_factory_get_open_dialogs     (GimpDialogFactory       *factory);
154 
155 GList *             gimp_dialog_factory_get_session_infos    (GimpDialogFactory       *factory);
156 void                gimp_dialog_factory_add_session_info     (GimpDialogFactory       *factory,
157                                                               GimpSessionInfo         *info);
158 
159 GtkWidget *         gimp_dialog_factory_dialog_raise         (GimpDialogFactory       *factory,
160                                                               GdkScreen               *screen,
161                                                               gint                     monitor,
162                                                               const gchar             *identifiers,
163                                                               gint                     view_size);
164 
165 GtkWidget *         gimp_dialog_factory_dockable_new         (GimpDialogFactory       *factory,
166                                                               GimpDock                *dock,
167                                                               const gchar             *identifier,
168                                                               gint                     view_size);
169 
170 void                gimp_dialog_factory_add_dialog           (GimpDialogFactory       *factory,
171                                                               GtkWidget               *dialog,
172                                                               GdkScreen               *screen,
173                                                               gint                     monitor);
174 void                gimp_dialog_factory_add_foreign          (GimpDialogFactory       *factory,
175                                                               const gchar             *identifier,
176                                                               GtkWidget               *dialog,
177                                                               GdkScreen               *screen,
178                                                               gint                     monitor);
179 
180 void                gimp_dialog_factory_position_dialog      (GimpDialogFactory       *factory,
181                                                               const gchar             *identifier,
182                                                               GtkWidget               *dialog,
183                                                               GdkScreen               *screen,
184                                                               gint                     monitor);
185 void                gimp_dialog_factory_remove_dialog        (GimpDialogFactory       *factory,
186                                                               GtkWidget               *dialog);
187 
188 void                gimp_dialog_factory_hide_dialog          (GtkWidget               *dialog);
189 
190 void                gimp_dialog_factory_save                 (GimpDialogFactory       *factory,
191                                                               GimpConfigWriter        *writer);
192 void                gimp_dialog_factory_restore              (GimpDialogFactory       *factory,
193                                                               GdkScreen               *screen,
194                                                               gint                     monitor);
195 
196 void                gimp_dialog_factory_set_state            (GimpDialogFactory       *factory,
197                                                               GimpDialogsState         state);
198 GimpDialogsState    gimp_dialog_factory_get_state            (GimpDialogFactory       *factory);
199 
200 void                gimp_dialog_factory_show_with_display    (GimpDialogFactory       *factory);
201 void                gimp_dialog_factory_hide_with_display    (GimpDialogFactory       *factory);
202 
203 void                gimp_dialog_factory_set_busy             (GimpDialogFactory       *factory);
204 void                gimp_dialog_factory_unset_busy           (GimpDialogFactory       *factory);
205 
206 GimpDialogFactory * gimp_dialog_factory_from_widget          (GtkWidget               *dialog,
207                                                               GimpDialogFactoryEntry **entry);
208 
209 void                gimp_dialog_factory_set_has_min_size     (GtkWindow               *window,
210                                                               gboolean                 has_min_size);
211 gboolean            gimp_dialog_factory_get_has_min_size     (GtkWindow               *window);
212 
213 GimpDialogFactory * gimp_dialog_factory_get_singleton        (void);
214 void                gimp_dialog_factory_set_singleton        (GimpDialogFactory       *factory);
215 
216 
217 #endif  /*  __GIMP_DIALOG_FACTORY_H__  */
218