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

« back to all changes in this revision

Viewing changes to libgimp/gimpprogressbar.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:
24
24
 
25
25
#include <gtk/gtk.h>
26
26
 
 
27
#ifdef GDK_WINDOWING_WIN32
 
28
#include <gdk/gdkwin32.h>
 
29
#endif
 
30
 
 
31
#ifdef GDK_WINDOWING_X11
 
32
#include <gdk/gdkx.h>
 
33
#endif
 
34
 
27
35
#include "gimpuitypes.h"
28
36
 
29
37
#include "gimp.h"
31
39
#include "gimpprogressbar.h"
32
40
 
33
41
 
34
 
static void   gimp_progress_bar_class_init (GimpProgressBarClass *klass);
35
 
static void   gimp_progress_bar_init       (GimpProgressBar      *bar);
36
 
 
37
 
static void   gimp_progress_bar_destroy    (GtkObject            *object);
38
 
 
39
 
static void   gimp_progress_bar_start      (const gchar          *message,
40
 
                                            gboolean              cancelable,
41
 
                                            gpointer              user_data);
42
 
static void   gimp_progress_bar_end        (gpointer              user_data);
43
 
static void   gimp_progress_bar_set_text   (const gchar          *message,
44
 
                                            gpointer              user_data);
45
 
static void   gimp_progress_bar_set_value  (gdouble               percentage,
46
 
                                            gpointer              user_data);
47
 
 
48
 
 
49
 
static GtkProgressBarClass *parent_class = NULL;
50
 
 
51
 
 
52
 
GType
53
 
gimp_progress_bar_get_type (void)
54
 
{
55
 
  static GType bar_type = 0;
56
 
 
57
 
  if (! bar_type)
58
 
    {
59
 
      static const GTypeInfo bar_info =
60
 
      {
61
 
        sizeof (GimpProgressBarClass),
62
 
        (GBaseInitFunc) NULL,
63
 
        (GBaseFinalizeFunc) NULL,
64
 
        (GClassInitFunc) gimp_progress_bar_class_init,
65
 
        NULL,           /* class_finalize */
66
 
        NULL,           /* class_data     */
67
 
        sizeof (GimpProgressBar),
68
 
        0,              /* n_preallocs    */
69
 
        (GInstanceInitFunc) gimp_progress_bar_init,
70
 
      };
71
 
 
72
 
      bar_type = g_type_register_static (GTK_TYPE_PROGRESS_BAR,
73
 
                                         "GimpProgressBar",
74
 
                                         &bar_info, 0);
75
 
    }
76
 
 
77
 
  return bar_type;
78
 
}
 
42
static void     gimp_progress_bar_destroy    (GtkObject   *object);
 
43
 
 
44
static void     gimp_progress_bar_start      (const gchar *message,
 
45
                                              gboolean     cancelable,
 
46
                                              gpointer     user_data);
 
47
static void     gimp_progress_bar_end        (gpointer     user_data);
 
48
static void     gimp_progress_bar_set_text   (const gchar *message,
 
49
                                              gpointer     user_data);
 
50
static void     gimp_progress_bar_set_value  (gdouble      percentage,
 
51
                                              gpointer     user_data);
 
52
static void     gimp_progress_bar_pulse      (gpointer     user_data);
 
53
static guint32  gimp_progress_bar_get_window (gpointer     user_data);
 
54
 
 
55
 
 
56
G_DEFINE_TYPE (GimpProgressBar, gimp_progress_bar, GTK_TYPE_PROGRESS_BAR)
 
57
 
 
58
#define parent_class gimp_progress_bar_parent_class
 
59
 
79
60
 
80
61
static void
81
62
gimp_progress_bar_class_init (GimpProgressBarClass *klass)
82
63
{
83
64
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
84
65
 
85
 
  parent_class = g_type_class_peek_parent (klass);
86
 
 
87
66
  object_class->destroy = gimp_progress_bar_destroy;
88
67
}
89
68
 
90
69
static void
91
70
gimp_progress_bar_init (GimpProgressBar *bar)
92
71
{
 
72
  GimpProgressVtable vtable = { 0, };
 
73
 
93
74
  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (bar), " ");
94
 
 
95
 
  bar->progress_callback = gimp_progress_install (gimp_progress_bar_start,
96
 
                                                  gimp_progress_bar_end,
97
 
                                                  gimp_progress_bar_set_text,
98
 
                                                  gimp_progress_bar_set_value,
99
 
                                                  bar);
 
75
  gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (bar), PANGO_ELLIPSIZE_END);
 
76
 
 
77
  vtable.start      = gimp_progress_bar_start;
 
78
  vtable.end        = gimp_progress_bar_end;
 
79
  vtable.set_text   = gimp_progress_bar_set_text;
 
80
  vtable.set_value  = gimp_progress_bar_set_value;
 
81
  vtable.pulse      = gimp_progress_bar_pulse;
 
82
  vtable.get_window = gimp_progress_bar_get_window;
 
83
 
 
84
  bar->progress_callback = gimp_progress_install_vtable (&vtable, bar);
100
85
}
101
86
 
102
87
static void
160
145
{
161
146
  GimpProgressBar *bar = GIMP_PROGRESS_BAR (user_data);
162
147
 
163
 
  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), percentage);
164
 
 
165
 
  if (GTK_WIDGET_DRAWABLE (bar))
166
 
    while (g_main_context_pending (NULL))
167
 
      g_main_context_iteration (NULL, TRUE);
 
148
  if (percentage >= 0.0)
 
149
    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar), percentage);
 
150
  else
 
151
    gtk_progress_bar_pulse (GTK_PROGRESS_BAR (bar));
 
152
 
 
153
  if (GTK_WIDGET_DRAWABLE (bar))
 
154
    while (g_main_context_pending (NULL))
 
155
      g_main_context_iteration (NULL, TRUE);
 
156
}
 
157
 
 
158
static void
 
159
gimp_progress_bar_pulse (gpointer user_data)
 
160
{
 
161
  GimpProgressBar *bar = GIMP_PROGRESS_BAR (user_data);
 
162
 
 
163
  gtk_progress_bar_pulse (GTK_PROGRESS_BAR (bar));
 
164
 
 
165
  if (GTK_WIDGET_DRAWABLE (bar))
 
166
    while (g_main_context_pending (NULL))
 
167
      g_main_context_iteration (NULL, TRUE);
 
168
}
 
169
 
 
170
static GdkNativeWindow
 
171
gimp_window_get_native (GtkWindow *window)
 
172
{
 
173
  g_return_val_if_fail (GTK_IS_WINDOW (window), 0);
 
174
 
 
175
#ifdef GDK_NATIVE_WINDOW_POINTER
 
176
#ifdef __GNUC__
 
177
#warning gimp_window_get_native() unimplementable for the target windowing system
 
178
#endif
 
179
#endif
 
180
 
 
181
#ifdef GDK_WINDOWING_WIN32
 
182
  if (window && GTK_WIDGET_REALIZED (window))
 
183
    return GDK_WINDOW_HWND (GTK_WIDGET (window)->window);
 
184
#endif
 
185
 
 
186
#ifdef GDK_WINDOWING_X11
 
187
  if (window && GTK_WIDGET_REALIZED (window))
 
188
    return GDK_WINDOW_XID (GTK_WIDGET (window)->window);
 
189
#endif
 
190
 
 
191
  return 0;
 
192
}
 
193
 
 
194
static guint32
 
195
gimp_progress_bar_get_window (gpointer user_data)
 
196
{
 
197
  GimpProgressBar *bar = GIMP_PROGRESS_BAR (user_data);
 
198
  GtkWidget       *toplevel;
 
199
 
 
200
  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (bar));
 
201
 
 
202
  if (GTK_IS_WINDOW (toplevel))
 
203
    return (guint32) gimp_window_get_native (GTK_WINDOW (toplevel));
 
204
 
 
205
  return 0;
168
206
}
169
207
 
170
208
/**