1 | /* rgcacheprogress.cc |
---|
2 | * |
---|
3 | * Copyright (c) 2000, 2001 Conectiva S/A |
---|
4 | * |
---|
5 | * Author: Alfredo K. Kojima <kojima@conectiva.com.br> |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License as |
---|
9 | * published by the Free Software Foundation; either version 2 of the |
---|
10 | * License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
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 |
---|
20 | * USA |
---|
21 | */ |
---|
22 | |
---|
23 | #include "config.h" |
---|
24 | |
---|
25 | #include "rgcacheprogress.h" |
---|
26 | #include "rgmisc.h" |
---|
27 | |
---|
28 | #include "i18n.h" |
---|
29 | |
---|
30 | |
---|
31 | RGCacheProgress::RGCacheProgress(GtkWidget *parent, GtkWidget *label) |
---|
32 | : _parent(parent), _label(label) |
---|
33 | { |
---|
34 | // _prog = gtk_progress_bar_new(); |
---|
35 | |
---|
36 | // gtk_label_set_text(GTK_LABEL(_label), utf8(Op.c_str())); |
---|
37 | |
---|
38 | // gtk_box_pack_start(GTK_BOX(_parent), _prog, FALSE, TRUE, 0); |
---|
39 | |
---|
40 | _prog = parent; |
---|
41 | gtk_label_set_text(GTK_LABEL(_label), utf8(Op.c_str())); |
---|
42 | |
---|
43 | _mapped = false; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | RGCacheProgress::~RGCacheProgress() |
---|
48 | { |
---|
49 | //gtk_widget_destroy(_prog); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | void RGCacheProgress::Update() |
---|
54 | { |
---|
55 | if (!CheckChange()) { |
---|
56 | //RGFlushInterface(); |
---|
57 | return; |
---|
58 | } |
---|
59 | |
---|
60 | if (!_mapped) { |
---|
61 | gtk_widget_show(_prog); |
---|
62 | RGFlushInterface(); |
---|
63 | _mapped = true; |
---|
64 | } |
---|
65 | |
---|
66 | if (MajorChange) |
---|
67 | gtk_label_set_text(GTK_LABEL(_label), utf8(Op.c_str())); |
---|
68 | |
---|
69 | gtk_progress_bar_update(GTK_PROGRESS_BAR(_prog), (float)Percent / 100.0); |
---|
70 | |
---|
71 | RGFlushInterface(); |
---|
72 | |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | void RGCacheProgress::Done() |
---|
77 | { |
---|
78 | gtk_progress_bar_update(GTK_PROGRESS_BAR(_prog), 1.0); |
---|
79 | RGFlushInterface(); |
---|
80 | |
---|
81 | gtk_widget_hide(_prog); |
---|
82 | |
---|
83 | _mapped = false; |
---|
84 | } |
---|