35
35
/* local function prototypes */
37
static void gimp_ui_help_func (const gchar *help_id,
39
static void gimp_ensure_modules (void);
37
static void gimp_ui_help_func (const gchar *help_id,
39
static void gimp_ensure_modules (void);
40
static void gimp_window_transient_realized (GtkWidget *window,
42
static void gimp_window_set_transient_for (GtkWindow *window,
46
static gboolean gimp_ui_initialized = FALSE;
42
49
/* public functions */
60
67
gimp_ui_init (const gchar *prog_name,
63
static gboolean initialized = FALSE;
65
const gchar *display_name;
70
const gchar *display_name;
71
74
g_return_if_fail (prog_name != NULL);
76
if (gimp_ui_initialized)
79
g_set_prgname (prog_name);
76
81
display_name = gimp_display_name ();
80
const gchar *var_name = NULL;
82
85
#if defined (GDK_WINDOWING_X11)
84
#elif defined (GDK_WINDOWING_DIRECTFB) || defined (GDK_WINDOWING_FB)
85
var_name = "GDK_DISPLAY";
86
const gchar var_name[] = "DISPLAY";
88
const gchar var_name[] = "GDK_DISPLAY";
89
92
putenv (g_strdup_printf ("%s=%s", var_name, display_name));
93
argv = g_new (gchar *, 2);
94
argv[0] = g_strdup (prog_name);
95
argv[1] = g_strdup_printf ("--class=%s", gimp_wm_class ());
97
gtk_init (&argc, &argv);
95
gtk_init (NULL, NULL);
99
97
themerc = gimp_personal_rc_file ("themerc");
100
98
gtk_rc_add_default_file (themerc);
101
gdk_set_program_class (gimp_wm_class ());
103
103
gdk_rgb_set_min_colors (gimp_min_colors ());
104
104
gdk_rgb_set_install (gimp_install_cmap ());
117
117
gimp_dialogs_show_help_button (gimp_show_help_button ());
119
gimp_ui_initialized = TRUE;
123
* gimp_ui_get_display_window:
125
* Returns the #GdkWindow of a display window. The purpose is to allow
126
* to make plug-in dialogs transient to the image display as explained
127
* with gdk_window_set_transient_for().
129
* You shouldn't have to call this function directly. Use
130
* gimp_window_set_transient_for_display() instead.
132
* Return value: A reference to a #GdkWindow or %NULL. You should
133
* unref the window using g_object_unref() as soon as
134
* you don't need it any longer.
139
gimp_ui_get_display_window (guint32 gdisp_ID)
141
#ifndef GDK_NATIVE_WINDOW_POINTER
142
GdkNativeWindow window;
144
g_return_val_if_fail (gimp_ui_initialized, NULL);
146
window = gimp_display_get_window_handle (gdisp_ID);
148
return gdk_window_foreign_new_for_display (gdk_display_get_default (),
156
* gimp_ui_get_progress_window:
158
* Returns the #GdkWindow of the window this plug-in's progress bar is
159
* shown in. Use it to make plug-in dialogs transient to this window
160
* as explained with gdk_window_set_transient_for().
162
* You shouldn't have to call this function directly. Use
163
* gimp_window_set_transient() instead.
165
* Return value: A reference to a #GdkWindow or %NULL. You should
166
* unref the window using g_object_unref() as soon as
167
* you don't need it any longer.
172
gimp_ui_get_progress_window (void)
174
#ifndef GDK_NATIVE_WINDOW_POINTER
175
GdkNativeWindow window;
177
g_return_val_if_fail (gimp_ui_initialized, NULL);
179
window = gimp_progress_get_window_handle ();
181
return gdk_window_foreign_new_for_display (gdk_display_get_default (),
189
* gimp_window_set_transient_for_display:
190
* @window: the #GtkWindow that should become transient
191
* @gdisp_ID: display ID of the image window that should become the parent
193
* Indicates to the window manager that @window is a transient dialog
194
* associated with the GIMP image window that is identified by it's
195
* display ID. See gdk_window_set_transient_for () for more information.
197
* Most of the time you will want to use the convenience function
198
* gimp_window_set_transient().
203
gimp_window_set_transient_for_display (GtkWindow *window,
206
g_return_if_fail (gimp_ui_initialized);
207
g_return_if_fail (GTK_IS_WINDOW (window));
209
gimp_window_set_transient_for (window,
210
gimp_ui_get_display_window (gdisp_ID));
214
* gimp_window_set_transient:
215
* @window: the #GtkWindow that should become transient
217
* Indicates to the window manager that @window is a transient dialog
218
* associated with the GIMP window that the plug-in has been
219
* started from. See also gimp_window_set_transient_for_display().
224
gimp_window_set_transient (GtkWindow *window)
226
g_return_if_fail (gimp_ui_initialized);
227
g_return_if_fail (GTK_IS_WINDOW (window));
229
gimp_window_set_transient_for (window, gimp_ui_get_progress_window ());
142
load_inhibit = gimp_get_module_load_inhibit ();
143
module_path = gimp_gimprc_query ("module-path");
249
gchar *load_inhibit = gimp_get_module_load_inhibit ();
250
gchar *module_path = gimp_gimprc_query ("module-path");
145
252
module_db = gimp_module_db_new (FALSE);
146
254
gimp_module_db_set_load_inhibit (module_db, load_inhibit);
147
255
gimp_module_db_load (module_db, module_path);
257
g_free (module_path);
149
258
g_free (load_inhibit);
150
g_free (module_path);
263
gimp_window_transient_realized (GtkWidget *window,
266
if (GTK_WIDGET_REALIZED (window))
267
gdk_window_set_transient_for (window->window, parent);
271
gimp_window_set_transient_for (GtkWindow *window,
274
gtk_window_set_transient_for (window, NULL);
276
#ifndef GDK_WINDOWING_WIN32
277
g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_FUNC,
279
gimp_window_transient_realized,
285
if (GTK_WIDGET_REALIZED (window))
286
gdk_window_set_transient_for (GTK_WIDGET (window)->window, parent);
288
g_signal_connect_object (window, "realize",
289
G_CALLBACK (gimp_window_transient_realized),
291
g_object_unref (parent);