1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "libgimpwidgets/gimpwidgets.h"
25
#include "dialogs-types.h"
27
#include "core/gimp.h"
28
#include "core/gimpcontext.h"
30
#include "widgets/gimpdialogfactory.h"
31
#include "widgets/gimphelp-ids.h"
32
#include "widgets/gimpmenufactory.h"
35
#include "dialogs-constructors.h"
37
#include "gimp-intl.h"
40
GimpDialogFactory *global_dialog_factory = NULL;
41
GimpDialogFactory *global_dock_factory = NULL;
42
GimpDialogFactory *global_toolbox_factory = NULL;
45
#define FOREIGN(id,remember_size) \
46
{ id, NULL, NULL, NULL, NULL, \
47
NULL, 0, TRUE, TRUE, remember_size, FALSE }
49
#define TOPLEVEL(id,new_func,singleton,session_managed,remember_size) \
50
{ id, NULL, NULL, NULL, NULL, \
51
new_func, 0, singleton, session_managed, remember_size, FALSE }
54
static const GimpDialogFactoryEntry toplevel_entries[] =
56
/* foreign toplevels without constructor */
57
FOREIGN ("gimp-brightness-contrast-tool-dialog", FALSE),
58
FOREIGN ("gimp-color-picker-tool-dialog", TRUE),
59
FOREIGN ("gimp-colorize-tool-dialog", FALSE),
60
FOREIGN ("gimp-crop-tool-dialog", FALSE),
61
FOREIGN ("gimp-curves-tool-dialog", TRUE),
62
FOREIGN ("gimp-color-balance-tool-dialog", FALSE),
63
FOREIGN ("gimp-hue-saturation-tool-dialog", FALSE),
64
FOREIGN ("gimp-levels-tool-dialog", TRUE),
65
FOREIGN ("gimp-measure-tool-dialog", FALSE),
66
FOREIGN ("gimp-posterize-tool-dialog", FALSE),
67
FOREIGN ("gimp-rotate-tool-dialog", FALSE),
68
FOREIGN ("gimp-scale-tool-dialog", FALSE),
69
FOREIGN ("gimp-shear-tool-dialog", FALSE),
70
FOREIGN ("gimp-text-tool-dialog", TRUE),
71
FOREIGN ("gimp-threshold-tool-dialog", FALSE),
72
FOREIGN ("gimp-perspective-tool-dialog", FALSE),
74
FOREIGN ("gimp-toolbox-color-dialog", FALSE),
75
FOREIGN ("gimp-gradient-editor-color-dialog", FALSE),
76
FOREIGN ("gimp-palette-editor-color-dialog", FALSE),
77
FOREIGN ("gimp-colormap-editor-color-dialog", FALSE),
79
FOREIGN ("gimp-keyboard-shortcuts-dialog", TRUE),
80
FOREIGN ("gimp-controller-action-dialog", TRUE),
82
/* ordinary toplevels */
83
TOPLEVEL ("gimp-image-new-dialog",
84
dialogs_image_new_new, FALSE, TRUE, FALSE),
85
TOPLEVEL ("gimp-file-open-dialog",
86
dialogs_file_open_new, TRUE, TRUE, TRUE),
87
TOPLEVEL ("gimp-file-open-location-dialog",
88
dialogs_file_open_location_new, FALSE, TRUE, FALSE),
89
TOPLEVEL ("gimp-file-save-dialog",
90
dialogs_file_save_new, FALSE, TRUE, TRUE),
92
/* singleton toplevels */
93
TOPLEVEL ("gimp-preferences-dialog",
94
dialogs_preferences_get, TRUE, TRUE, FALSE),
95
TOPLEVEL ("gimp-module-dialog",
96
dialogs_module_get, TRUE, TRUE, TRUE),
97
TOPLEVEL ("gimp-tips-dialog",
98
dialogs_tips_get, TRUE, FALSE, FALSE),
99
TOPLEVEL ("gimp-about-dialog",
100
dialogs_about_get, TRUE, FALSE, FALSE),
101
TOPLEVEL ("gimp-error-dialog",
102
dialogs_error_get, TRUE, FALSE, FALSE),
103
TOPLEVEL ("gimp-quit-dialog",
104
dialogs_quit_get, TRUE, FALSE, FALSE)
107
#define DOCKABLE(id,name,blurb,stock_id,help_id,\
108
new_func,preview_size,singleton) \
109
{ id, name, blurb, stock_id, help_id, \
110
new_func, preview_size, singleton, FALSE, FALSE, TRUE }
112
#define LISTGRID(id,name,blurb,stock_id,help_id,\
114
{ "gimp-"#id"-list", name, blurb, stock_id, help_id, \
115
dialogs_##id##_list_view_new, preview_size, FALSE, FALSE, FALSE, TRUE }, \
116
{ "gimp-"#id"-grid", name, blurb, stock_id, help_id, \
117
dialogs_##id##_grid_view_new, preview_size, FALSE, FALSE, FALSE, TRUE }
119
static const GimpDialogFactoryEntry dock_entries[] =
121
/* singleton dockables */
122
DOCKABLE ("gimp-tool-options",
123
N_("Tool Options"), NULL, GIMP_STOCK_TOOL_OPTIONS,
124
GIMP_HELP_TOOL_OPTIONS_DIALOG,
125
dialogs_tool_options_get, 0, TRUE),
126
DOCKABLE ("gimp-device-status",
127
N_("Devices"), N_("Device Status"), GIMP_STOCK_DEVICE_STATUS,
128
GIMP_HELP_DEVICE_STATUS_DIALOG,
129
dialogs_device_status_get, 0, TRUE),
130
DOCKABLE ("gimp-error-console",
131
N_("Errors"), N_("Error Console"), GIMP_STOCK_WARNING,
132
GIMP_HELP_ERRORS_DIALOG,
133
dialogs_error_console_get, 0, TRUE),
135
/* list & grid views */
136
LISTGRID (image, N_("Images"), NULL, GIMP_STOCK_IMAGES,
137
GIMP_HELP_IMAGE_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
138
LISTGRID (brush, N_("Brushes"), NULL, GIMP_STOCK_BRUSH,
139
GIMP_HELP_BRUSH_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
140
LISTGRID (pattern, N_("Patterns"), NULL, GIMP_STOCK_PATTERN,
141
GIMP_HELP_PATTERN_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
142
LISTGRID (gradient, N_("Gradients"), NULL, GIMP_STOCK_GRADIENT,
143
GIMP_HELP_GRADIENT_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
144
LISTGRID (palette, N_("Palettes"), NULL, GIMP_STOCK_PALETTE,
145
GIMP_HELP_PALETTE_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
146
LISTGRID (font, N_("Fonts"), NULL, GIMP_STOCK_FONT,
147
GIMP_HELP_FONT_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
148
LISTGRID (tool, N_("Tools"), NULL, GIMP_STOCK_TOOLS,
149
GIMP_HELP_TOOLS_DIALOG, GIMP_VIEW_SIZE_SMALL),
150
LISTGRID (buffer, N_("Buffers"), NULL, GIMP_STOCK_BUFFER,
151
GIMP_HELP_BUFFER_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
152
LISTGRID (document, N_("History"), N_("Document History"), GTK_STOCK_OPEN,
153
GIMP_HELP_DOCUMENT_DIALOG, GIMP_VIEW_SIZE_LARGE),
154
LISTGRID (template, N_("Templates"), N_("Image Templates"), GIMP_STOCK_TEMPLATE,
155
GIMP_HELP_TEMPLATE_DIALOG, GIMP_VIEW_SIZE_SMALL),
158
DOCKABLE ("gimp-layer-list",
159
N_("Layers"), NULL, GIMP_STOCK_LAYERS,
160
GIMP_HELP_LAYER_DIALOG,
161
dialogs_layer_list_view_new, 0, FALSE),
162
DOCKABLE ("gimp-channel-list",
163
N_("Channels"), NULL, GIMP_STOCK_CHANNELS,
164
GIMP_HELP_CHANNEL_DIALOG,
165
dialogs_channel_list_view_new, 0, FALSE),
166
DOCKABLE ("gimp-vectors-list",
167
N_("Paths"), NULL, GIMP_STOCK_PATHS,
168
GIMP_HELP_PATH_DIALOG,
169
dialogs_vectors_list_view_new, 0, FALSE),
170
DOCKABLE ("gimp-indexed-palette",
171
N_("Colormap"), NULL, GIMP_STOCK_INDEXED_PALETTE,
172
GIMP_HELP_INDEXED_PALETTE_DIALOG,
173
dialogs_colormap_editor_new, 0, FALSE),
174
DOCKABLE ("gimp-histogram-editor",
175
N_("Histogram"), NULL, GIMP_STOCK_HISTOGRAM,
176
GIMP_HELP_HISTOGRAM_DIALOG,
177
dialogs_histogram_editor_new, 0, FALSE),
178
DOCKABLE ("gimp-selection-editor",
179
N_("Selection"), N_("Selection Editor"), GIMP_STOCK_SELECTION,
180
GIMP_HELP_SELECTION_DIALOG,
181
dialogs_selection_editor_new, 0, FALSE),
182
DOCKABLE ("gimp-undo-history",
183
N_("Undo"), N_("Undo History"), GIMP_STOCK_UNDO_HISTORY,
184
GIMP_HELP_UNDO_DIALOG,
185
dialogs_undo_editor_new, 0, FALSE),
187
/* display related */
188
DOCKABLE ("gimp-navigation-view",
189
N_("Navigation"), N_("Display Navigation"), GIMP_STOCK_NAVIGATION,
190
GIMP_HELP_NAVIGATION_DIALOG,
191
dialogs_navigation_editor_new, 0, FALSE),
194
DOCKABLE ("gimp-color-editor",
195
N_("FG/BG"), N_("FG/BG Color"), GIMP_STOCK_DEFAULT_COLORS,
196
GIMP_HELP_COLOR_DIALOG,
197
dialogs_color_editor_new, 0, FALSE),
199
/* singleton editors */
200
DOCKABLE ("gimp-brush-editor",
201
N_("Brush Editor"), NULL, GIMP_STOCK_BRUSH,
202
GIMP_HELP_BRUSH_EDITOR_DIALOG,
203
dialogs_brush_editor_get, 0, TRUE),
204
DOCKABLE ("gimp-gradient-editor",
205
N_("Gradient Editor"), NULL, GIMP_STOCK_GRADIENT,
206
GIMP_HELP_GRADIENT_EDITOR_DIALOG,
207
dialogs_gradient_editor_get, 0, TRUE),
208
DOCKABLE ("gimp-palette-editor",
209
N_("Palette Editor"), NULL, GIMP_STOCK_PALETTE,
210
GIMP_HELP_PALETTE_EDITOR_DIALOG,
211
dialogs_palette_editor_get, 0, TRUE)
215
/* public functions */
218
dialogs_init (Gimp *gimp,
219
GimpMenuFactory *menu_factory)
223
g_return_if_fail (GIMP_IS_GIMP (gimp));
224
g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
226
global_dialog_factory = gimp_dialog_factory_new ("toplevel",
227
gimp_get_user_context (gimp),
231
global_toolbox_factory = gimp_dialog_factory_new ("toolbox",
232
gimp_get_user_context (gimp),
234
dialogs_toolbox_get);
235
gimp_dialog_factory_set_constructor (global_toolbox_factory,
236
dialogs_dockable_constructor);
238
global_dock_factory = gimp_dialog_factory_new ("dock",
239
gimp_get_user_context (gimp),
242
gimp_dialog_factory_set_constructor (global_dock_factory,
243
dialogs_dockable_constructor);
245
for (i = 0; i < G_N_ELEMENTS (toplevel_entries); i++)
246
gimp_dialog_factory_register_entry (global_dialog_factory,
247
toplevel_entries[i].identifier,
248
gettext (toplevel_entries[i].name),
249
gettext (toplevel_entries[i].blurb),
250
toplevel_entries[i].stock_id,
251
toplevel_entries[i].help_id,
252
toplevel_entries[i].new_func,
253
toplevel_entries[i].preview_size,
254
toplevel_entries[i].singleton,
255
toplevel_entries[i].session_managed,
256
toplevel_entries[i].remember_size,
257
toplevel_entries[i].remember_if_open);
259
for (i = 0; i < G_N_ELEMENTS (dock_entries); i++)
260
gimp_dialog_factory_register_entry (global_dock_factory,
261
dock_entries[i].identifier,
262
gettext (dock_entries[i].name),
263
gettext (dock_entries[i].blurb),
264
dock_entries[i].stock_id,
265
dock_entries[i].help_id,
266
dock_entries[i].new_func,
267
dock_entries[i].preview_size,
268
dock_entries[i].singleton,
269
dock_entries[i].session_managed,
270
dock_entries[i].remember_size,
271
dock_entries[i].remember_if_open);
275
dialogs_exit (Gimp *gimp)
277
g_return_if_fail (GIMP_IS_GIMP (gimp));
279
if (global_dialog_factory)
281
g_object_unref (global_dialog_factory);
282
global_dialog_factory = NULL;
285
/* destroy the "global_toolbox_factory" _before_ destroying the
286
* "global_dock_factory" because the "global_toolbox_factory" owns
287
* dockables which were created by the "global_dock_factory". This
288
* way they are properly removed from the "global_dock_factory", which
289
* would complain about stale entries otherwise.
291
if (global_toolbox_factory)
293
g_object_unref (global_toolbox_factory);
294
global_toolbox_factory = NULL;
297
if (global_dock_factory)
299
g_object_unref (global_dock_factory);
300
global_dock_factory = NULL;
305
dialogs_get_toolbox (void)
309
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (global_toolbox_factory), NULL);
311
for (list = global_toolbox_factory->open_dialogs;
313
list = g_list_next (list))
315
if (GTK_WIDGET_TOPLEVEL (list->data))