1309.3.1
by Julián Unrrein
Delete marlin-progress-info-widget .h and .c source files. |
1 |
/***
|
1811.1.1
by Jeremy Wootten
Code clean: tabs, trailing space, headers, comments |
2 |
Copyright (C) 2007, 2011 Red Hat, Inc.
|
3 |
Copyright (C) 2013 elementary Developers
|
|
4 |
||
5 |
This program is free software: you can redistribute it and/or modify it
|
|
6 |
under the terms of the GNU Lesser General Public License version 3, as published
|
|
7 |
by the Free Software Foundation.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful, but
|
|
10 |
WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
11 |
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
12 |
PURPOSE. See the GNU General Public License for more details.
|
|
13 |
||
14 |
You should have received a copy of the GNU General Public License along
|
|
15 |
with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
||
17 |
Authors: Alexander Larsson <alexl@redhat.com>
|
|
18 |
Cosimo Cecchi <cosimoc@redhat.com>
|
|
19 |
Julián Unrrein <junrrein@gmail.com>
|
|
1309.3.1
by Julián Unrrein
Delete marlin-progress-info-widget .h and .c source files. |
20 |
***/
|
21 |
||
22 |
public class Marlin.Progress.InfoWidget : Gtk.Box { |
|
23 |
||
1309.3.2
by Julián Unrrein
Implement all methods. |
24 |
private Marlin.Progress.Info info; |
25 |
||
1309.3.4
by Julián Unrrein
Small code refactor. |
26 |
Gtk.Widget status; /* Gtk.Label */ |
27 |
Gtk.Widget details; /* Gtk.Label */ |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
28 |
Gtk.Widget progress_bar; |
29 |
||
1309.3.1
by Julián Unrrein
Delete marlin-progress-info-widget .h and .c source files. |
30 |
public InfoWidget (Marlin.Progress.Info info) { |
1309.3.2
by Julián Unrrein
Implement all methods. |
31 |
this.info = info; |
1309.3.4
by Julián Unrrein
Small code refactor. |
32 |
|
33 |
build_and_show_widget (); |
|
34 |
||
35 |
update_data (); |
|
36 |
update_progress (); |
|
37 |
||
38 |
this.info.changed.connect (update_data); |
|
39 |
this.info.progress_changed.connect (update_progress); |
|
40 |
||
41 |
this.info.finished.connect (() => { |
|
42 |
destroy (); |
|
43 |
});
|
|
44 |
}
|
|
1811.1.1
by Jeremy Wootten
Code clean: tabs, trailing space, headers, comments |
45 |
|
1309.3.4
by Julián Unrrein
Small code refactor. |
46 |
private void build_and_show_widget () { |
1309.3.2
by Julián Unrrein
Implement all methods. |
47 |
this.orientation = Gtk.Orientation.VERTICAL; |
48 |
this.homogeneous = false; |
|
49 |
this.spacing = 5; |
|
1309.3.3
by Julián Unrrein
Small code refactor. |
50 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
51 |
this.status = new Gtk.Label ("status"); |
52 |
(this.status as Gtk.Label).set_size_request (500, -1); |
|
53 |
(this.status as Gtk.Label).set_line_wrap (true); |
|
54 |
(this.status as Gtk.Label).set_line_wrap_mode (Pango.WrapMode.WORD_CHAR); |
|
55 |
(this.status as Gtk.Misc).set_alignment ((float) 0.0, (float) 0.5); |
|
56 |
pack_start (status, true, false, 0); |
|
1309.3.3
by Julián Unrrein
Small code refactor. |
57 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
58 |
var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10); |
59 |
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
|
1309.3.3
by Julián Unrrein
Small code refactor. |
60 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
61 |
this.progress_bar = new Gtk.ProgressBar (); |
62 |
(this.progress_bar as Gtk.ProgressBar).pulse_step = 0.05; |
|
63 |
box.pack_start (this.progress_bar, true, false, 0); |
|
64 |
hbox.pack_start (box, true, true, 0); |
|
1309.3.3
by Julián Unrrein
Small code refactor. |
65 |
|
1696.2.3
by Daniel Foré
button from icon name is smarter |
66 |
var button = new Gtk.Button.from_icon_name ("process-stop-symbolic", Gtk.IconSize.BUTTON); |
1696.2.2
by Daniel Foré
use symbolic icon and flat button |
67 |
button.get_style_context ().add_class ("flat"); |
1309.3.3
by Julián Unrrein
Small code refactor. |
68 |
button.clicked.connect (() => { |
69 |
this.info.cancel (); |
|
70 |
button.sensitive = false; |
|
71 |
});
|
|
1811.1.1
by Jeremy Wootten
Code clean: tabs, trailing space, headers, comments |
72 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
73 |
hbox.pack_start (button, false, false, 0); |
1309.3.3
by Julián Unrrein
Small code refactor. |
74 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
75 |
pack_start (hbox, false, false, 0); |
1309.3.3
by Julián Unrrein
Small code refactor. |
76 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
77 |
this.details = new Gtk.Label ("details"); |
78 |
(this.details as Gtk.Label).set_line_wrap (true); |
|
79 |
(this.details as Gtk.Misc).set_alignment ((float) 0.0, (float) 0.5); |
|
80 |
pack_start (details, true, false, 0); |
|
1309.3.3
by Julián Unrrein
Small code refactor. |
81 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
82 |
show_all (); |
83 |
}
|
|
84 |
||
85 |
private void update_data () { |
|
86 |
string status = this.info.get_status (); |
|
87 |
(this.status as Gtk.Label).set_text (status); |
|
88 |
||
89 |
string details = this.info.get_details (); |
|
90 |
string markup = Markup.printf_escaped ("<span size='small'>%s</span>", details); |
|
91 |
(this.details as Gtk.Label).set_markup (markup); |
|
92 |
}
|
|
1309.3.3
by Julián Unrrein
Small code refactor. |
93 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
94 |
private void update_progress () { |
95 |
double progress = this.info.get_progress (); |
|
1309.3.3
by Julián Unrrein
Small code refactor. |
96 |
|
1309.3.2
by Julián Unrrein
Implement all methods. |
97 |
if (progress < 0) |
98 |
(this.progress_bar as Gtk.ProgressBar).pulse (); |
|
99 |
else
|
|
100 |
(this.progress_bar as Gtk.ProgressBar).set_fraction (progress); |
|
101 |
}
|
|
1309.3.4
by Julián Unrrein
Small code refactor. |
102 |
}
|