~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/widgets/gimpprogressbox.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * gimpprogressbox.c
5
5
 * Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
6
6
 *
7
 
 * This program is free software; you can redistribute it and/or modify
 
7
 * This program is free software: you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * the Free Software Foundation; either version 3 of the License, or
10
10
 * (at your option) any later version.
11
11
 *
12
12
 * This program is distributed in the hope that it will be useful,
15
15
 * GNU General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
19
 */
21
20
 
22
21
#include "config.h"
37
36
 
38
37
static void     gimp_progress_box_progress_iface_init (GimpProgressInterface *iface);
39
38
 
40
 
static void     gimp_progress_box_destroy            (GtkObject    *object);
 
39
static void     gimp_progress_box_dispose            (GObject      *object);
41
40
 
42
41
static GimpProgress *
43
42
                gimp_progress_box_progress_start     (GimpProgress *progress,
53
52
static void     gimp_progress_box_progress_pulse     (GimpProgress *progress);
54
53
 
55
54
 
56
 
G_DEFINE_TYPE_WITH_CODE (GimpProgressBox, gimp_progress_box, GTK_TYPE_VBOX,
 
55
G_DEFINE_TYPE_WITH_CODE (GimpProgressBox, gimp_progress_box, GTK_TYPE_BOX,
57
56
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
58
57
                                                gimp_progress_box_progress_iface_init))
59
58
 
63
62
static void
64
63
gimp_progress_box_class_init (GimpProgressBoxClass *klass)
65
64
{
66
 
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
 
65
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
67
66
 
68
 
  object_class->destroy = gimp_progress_box_destroy;
 
67
  object_class->dispose = gimp_progress_box_dispose;
69
68
}
70
69
 
71
70
static void
72
71
gimp_progress_box_init (GimpProgressBox *box)
73
72
{
 
73
  gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
 
74
                                  GTK_ORIENTATION_VERTICAL);
 
75
 
74
76
  gtk_box_set_spacing (GTK_BOX (box), 6);
75
77
 
76
78
  box->progress = gtk_progress_bar_new ();
101
103
}
102
104
 
103
105
static void
104
 
gimp_progress_box_destroy (GtkObject *object)
 
106
gimp_progress_box_dispose (GObject *object)
105
107
{
106
108
  GimpProgressBox *box = GIMP_PROGRESS_BOX (object);
107
109
 
108
 
  GTK_OBJECT_CLASS (parent_class)->destroy (object);
 
110
  G_OBJECT_CLASS (parent_class)->dispose (object);
109
111
 
110
112
  box->progress = NULL;
111
113
}
131
133
      box->cancelable = cancelable;
132
134
      box->value      = 0.0;
133
135
 
134
 
      if (GTK_WIDGET_DRAWABLE (box->progress))
135
 
        gdk_window_process_updates (box->progress->window, TRUE);
 
136
      if (gtk_widget_is_drawable (box->progress))
 
137
        gdk_window_process_updates (gtk_widget_get_window (box->progress),
 
138
                                    TRUE);
136
139
 
137
140
      return progress;
138
141
    }
175
178
 
176
179
      gtk_label_set_text (GTK_LABEL (box->label), message);
177
180
 
178
 
      if (GTK_WIDGET_DRAWABLE (box->progress))
179
 
        gdk_window_process_updates (box->progress->window, TRUE);
 
181
      if (gtk_widget_is_drawable (box->progress))
 
182
        gdk_window_process_updates (gtk_widget_get_window (box->progress),
 
183
                                    TRUE);
180
184
    }
181
185
}
182
186
 
188
192
    {
189
193
      GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
190
194
      GtkProgressBar  *bar = GTK_PROGRESS_BAR (box->progress);
 
195
      GtkAllocation    allocation;
 
196
 
 
197
      gtk_widget_get_allocation (GTK_WIDGET (bar), &allocation);
191
198
 
192
199
      box->value = percentage;
193
200
 
194
201
      /* only update the progress bar if this causes a visible change */
195
 
      if (fabs (GTK_WIDGET (bar)->allocation.width *
 
202
      if (fabs (allocation.width *
196
203
                (percentage - gtk_progress_bar_get_fraction (bar))) > 1.0)
197
204
        {
198
205
          gtk_progress_bar_set_fraction (bar, box->value);
199
206
 
200
 
          if (GTK_WIDGET_DRAWABLE (box->progress))
201
 
            gdk_window_process_updates (box->progress->window, TRUE);
 
207
          if (gtk_widget_is_drawable (box->progress))
 
208
            gdk_window_process_updates (gtk_widget_get_window (box->progress),
 
209
                                        TRUE);
202
210
        }
203
211
    }
204
212
}
224
232
 
225
233
      gtk_progress_bar_pulse (bar);
226
234
 
227
 
      if (GTK_WIDGET_DRAWABLE (box->progress))
228
 
        gdk_window_process_updates (box->progress->window, TRUE);
 
235
      if (gtk_widget_is_drawable (box->progress))
 
236
        gdk_window_process_updates (gtk_widget_get_window (box->progress),
 
237
                                    TRUE);
229
238
    }
230
239
}
231
240