40
40
package_summary.ellipsize = Pango.EllipsizeMode.END;
41
41
image.gicon = package.get_icon ();
43
if (package.update_available) {
44
action_button.label = _("Update");
45
} else if (package.installed) {
46
action_stack.no_show_all = true;
50
package.notify["installed"].connect (() => update_buttons ());
51
package.notify["update-available"].connect (() => update_buttons ());
43
package.notify["state"].connect (update_state);
53
45
package.change_information.bind_property ("can-cancel", cancel_button, "sensitive", GLib.BindingFlags.SYNC_CREATE);
54
package.change_information.progress_changed.connect (() => update_progress ());
55
package.change_information.status_changed.connect (() => update_status ());
46
package.change_information.progress_changed.connect (update_progress);
47
package.change_information.status_changed.connect (update_progress_status);
49
update_progress_status ();
56
50
update_progress ();
118
private void update_status () {
112
private void update_progress_status () {
119
113
progress_bar.text = package.change_information.get_status ();
120
if (package.change_information.status == Pk.Status.FINISHED) {
121
action_stack.set_visible_child_name ("buttons");
123
action_stack.set_visible_child_name ("progress");
124
action_stack.no_show_all = false;
125
action_stack.show_all ();
129
116
private void update_progress () {
130
var progress = package.change_information.get_progress ();
117
double progress = package.change_information.get_progress ();
131
118
if (progress < 1.0f) {
132
action_stack.set_visible_child_name ("progress");
133
119
progress_bar.fraction = progress;
134
action_stack.no_show_all = false;
135
action_stack.show_all ();
137
action_stack.set_visible_child_name ("buttons");
141
private void update_buttons () {
142
if (package.installed) {
143
if (package.update_available) {
123
private void update_state () {
124
switch (package.state) {
125
case Package.State.NOT_INSTALLED:
126
action_button.label = _("Install");
127
action_button.no_show_all = false;
128
action_button.show_all ();
130
action_stack.no_show_all = false;
131
action_stack.show_all ();
133
action_stack.set_visible_child_name ("buttons");
135
case Package.State.INSTALLED:
136
action_stack.no_show_all = true;
137
action_stack.hide ();
139
action_stack.set_visible_child_name ("buttons");
141
case Package.State.UPDATE_AVAILABLE:
144
142
action_button.label = _("Update");
145
143
action_button.no_show_all = false;
146
144
action_button.show_all ();
148
146
action_stack.no_show_all = false;
149
147
action_stack.show_all ();
151
action_stack.no_show_all = true;
152
action_stack.hide ();
155
action_button.label = _("Install");
156
action_button.no_show_all = false;
157
action_button.show_all ();
159
action_stack.no_show_all = false;
160
action_stack.show_all ();
149
action_stack.set_visible_child_name ("buttons");
151
case Package.State.INSTALLING:
152
case Package.State.UPDATING:
153
case Package.State.REMOVING:
154
action_stack.no_show_all = false;
155
action_stack.show_all ();
157
action_stack.set_visible_child_name ("progress");
166
164
private void action_cancelled () {