~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to libgimp/gimpui.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
/*  local function prototypes  */
36
36
 
37
 
static void  gimp_ui_help_func   (const gchar *help_id,
38
 
                                  gpointer     help_data);
39
 
static void  gimp_ensure_modules (void);
 
37
static void  gimp_ui_help_func              (const gchar *help_id,
 
38
                                             gpointer     help_data);
 
39
static void  gimp_ensure_modules            (void);
 
40
static void  gimp_window_transient_realized (GtkWidget   *window,
 
41
                                             GdkWindow   *parent);
 
42
static void  gimp_window_set_transient_for  (GtkWindow   *window,
 
43
                                             GdkWindow   *parent);
 
44
 
 
45
 
 
46
static gboolean gimp_ui_initialized = FALSE;
40
47
 
41
48
 
42
49
/*  public functions  */
58
65
 **/
59
66
void
60
67
gimp_ui_init (const gchar *prog_name,
61
 
              gboolean     preview)
 
68
              gboolean     preview)
62
69
{
63
 
  static gboolean initialized = FALSE;
64
 
 
65
 
  const gchar  *display_name;
66
 
  gint          argc;
67
 
  gchar       **argv;
68
 
  gchar        *themerc;
69
 
  GdkScreen    *screen;
 
70
  const gchar *display_name;
 
71
  gchar       *themerc;
 
72
  GdkScreen   *screen;
70
73
 
71
74
  g_return_if_fail (prog_name != NULL);
72
75
 
73
 
  if (initialized)
 
76
  if (gimp_ui_initialized)
74
77
    return;
75
78
 
 
79
  g_set_prgname (prog_name);
 
80
 
76
81
  display_name = gimp_display_name ();
77
82
 
78
83
  if (display_name)
79
84
    {
80
 
      const gchar *var_name = NULL;
81
 
 
82
85
#if defined (GDK_WINDOWING_X11)
83
 
      var_name = "DISPLAY";
84
 
#elif defined (GDK_WINDOWING_DIRECTFB) || defined (GDK_WINDOWING_FB)
85
 
      var_name = "GDK_DISPLAY";
 
86
      const gchar var_name[] = "DISPLAY";
 
87
#else
 
88
      const gchar var_name[] = "GDK_DISPLAY";
86
89
#endif
87
90
 
88
91
      if (var_name)
89
92
        putenv (g_strdup_printf ("%s=%s", var_name, display_name));
90
93
    }
91
94
 
92
 
  argc    = 2;
93
 
  argv    = g_new (gchar *, 2);
94
 
  argv[0] = g_strdup (prog_name);
95
 
  argv[1] = g_strdup_printf ("--class=%s", gimp_wm_class ());
96
 
 
97
 
  gtk_init (&argc, &argv);
 
95
  gtk_init (NULL, NULL);
98
96
 
99
97
  themerc = gimp_personal_rc_file ("themerc");
100
98
  gtk_rc_add_default_file (themerc);
101
99
  g_free (themerc);
102
100
 
 
101
  gdk_set_program_class (gimp_wm_class ());
 
102
 
103
103
  gdk_rgb_set_min_colors (gimp_min_colors ());
104
104
  gdk_rgb_set_install (gimp_install_cmap ());
105
105
 
116
116
 
117
117
  gimp_dialogs_show_help_button (gimp_show_help_button ());
118
118
 
119
 
  initialized = TRUE;
 
119
  gimp_ui_initialized = TRUE;
 
120
}
 
121
 
 
122
/**
 
123
 * gimp_ui_get_display_window:
 
124
 *
 
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().
 
128
 *
 
129
 * You shouldn't have to call this function directly. Use
 
130
 * gimp_window_set_transient_for_display() instead.
 
131
 *
 
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.
 
135
 *
 
136
 * Since: GIMP 2.4
 
137
 */
 
138
GdkWindow *
 
139
gimp_ui_get_display_window (guint32 gdisp_ID)
 
140
{
 
141
#ifndef GDK_NATIVE_WINDOW_POINTER
 
142
  GdkNativeWindow  window;
 
143
 
 
144
  g_return_val_if_fail (gimp_ui_initialized, NULL);
 
145
 
 
146
  window = gimp_display_get_window_handle (gdisp_ID);
 
147
  if (window)
 
148
    return gdk_window_foreign_new_for_display (gdk_display_get_default (),
 
149
                                               window);
 
150
#endif
 
151
 
 
152
  return NULL;
 
153
}
 
154
 
 
155
/**
 
156
 * gimp_ui_get_progress_window:
 
157
 *
 
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().
 
161
 *
 
162
 * You shouldn't have to call this function directly. Use
 
163
 * gimp_window_set_transient() instead.
 
164
 *
 
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.
 
168
 *
 
169
 * Since: GIMP 2.4
 
170
 */
 
171
GdkWindow *
 
172
gimp_ui_get_progress_window (void)
 
173
{
 
174
#ifndef GDK_NATIVE_WINDOW_POINTER
 
175
  GdkNativeWindow  window;
 
176
 
 
177
  g_return_val_if_fail (gimp_ui_initialized, NULL);
 
178
 
 
179
  window = gimp_progress_get_window_handle ();
 
180
  if (window)
 
181
    return gdk_window_foreign_new_for_display (gdk_display_get_default (),
 
182
                                               window);
 
183
#endif
 
184
 
 
185
  return NULL;
 
186
}
 
187
 
 
188
/**
 
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
 
192
 *
 
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.
 
196
 *
 
197
 * Most of the time you will want to use the convenience function
 
198
 * gimp_window_set_transient().
 
199
 *
 
200
 * Since: GIMP 2.4
 
201
 */
 
202
void
 
203
gimp_window_set_transient_for_display (GtkWindow *window,
 
204
                                       guint32    gdisp_ID)
 
205
{
 
206
  g_return_if_fail (gimp_ui_initialized);
 
207
  g_return_if_fail (GTK_IS_WINDOW (window));
 
208
 
 
209
  gimp_window_set_transient_for (window,
 
210
                                 gimp_ui_get_display_window (gdisp_ID));
 
211
}
 
212
 
 
213
/**
 
214
 * gimp_window_set_transient:
 
215
 * @window: the #GtkWindow that should become transient
 
216
 *
 
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().
 
220
 *
 
221
 * Since: GIMP 2.4
 
222
 */
 
223
void
 
224
gimp_window_set_transient (GtkWindow *window)
 
225
{
 
226
  g_return_if_fail (gimp_ui_initialized);
 
227
  g_return_if_fail (GTK_IS_WINDOW (window));
 
228
 
 
229
  gimp_window_set_transient_for (window, gimp_ui_get_progress_window ());
120
230
}
121
231
 
122
232
 
136
246
 
137
247
  if (! module_db)
138
248
    {
139
 
      gchar *load_inhibit;
140
 
      gchar *module_path;
141
 
 
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");
144
251
 
145
252
      module_db = gimp_module_db_new (FALSE);
 
253
 
146
254
      gimp_module_db_set_load_inhibit (module_db, load_inhibit);
147
255
      gimp_module_db_load (module_db, module_path);
148
256
 
 
257
      g_free (module_path);
149
258
      g_free (load_inhibit);
150
 
      g_free (module_path);
151
259
    }
152
260
}
 
261
 
 
262
static void
 
263
gimp_window_transient_realized (GtkWidget *window,
 
264
                                GdkWindow *parent)
 
265
{
 
266
  if (GTK_WIDGET_REALIZED (window))
 
267
    gdk_window_set_transient_for (window->window, parent);
 
268
}
 
269
 
 
270
static void
 
271
gimp_window_set_transient_for (GtkWindow *window,
 
272
                               GdkWindow *parent)
 
273
{
 
274
  gtk_window_set_transient_for (window, NULL);
 
275
 
 
276
#ifndef GDK_WINDOWING_WIN32
 
277
  g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_FUNC,
 
278
                                        0, 0, NULL,
 
279
                                        gimp_window_transient_realized,
 
280
                                        NULL);
 
281
 
 
282
  if (! parent)
 
283
    return;
 
284
 
 
285
  if (GTK_WIDGET_REALIZED (window))
 
286
    gdk_window_set_transient_for (GTK_WIDGET (window)->window, parent);
 
287
 
 
288
  g_signal_connect_object (window, "realize",
 
289
                           G_CALLBACK (gimp_window_transient_realized),
 
290
                           parent, 0);
 
291
  g_object_unref (parent);
 
292
#endif
 
293
}