Skip to content

Commit a91ef6b

Browse files
committed
No main window, can launch updated app
1 parent fa289ba commit a91ef6b

File tree

3 files changed

+88
-36
lines changed

3 files changed

+88
-36
lines changed

appimageupdategui/main.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void main (string[] args) {
100100

101101
window_main.add (vbox_main);
102102

103-
window_main.show_all();
103+
// window_main.show_all(); // Currently we are not showing the Main screen at all (TODO)
104104

105105
on_open_clicked();
106106

appimageupdategui/progress.vala

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,26 @@ public class ProgressWindow : Window {
99
private string file_name;
1010
private string[] files_to_be_updated;
1111
private int counter;
12-
private int file_counts;
12+
private int total_steps;
1313

1414
private ProgressBar progress;
1515

1616
private Label action_label;
1717
private Label message_label;
1818

1919
private Image icon_image;
20+
private Spinner spinner;
21+
22+
private Revealer revealer1;
23+
private Revealer revealer2;
2024

2125
private Button btn_cancel;
2226
private Button btn_show_files;
2327
private Button btn_quit;
2428

2529
private Pid child_pid;
26-
30+
31+
private string result_file_name;
2732

2833
public ProgressWindow(string file_name, string[] files_to_be_updated) {
2934
var builder = new Builder();
@@ -55,8 +60,18 @@ public class ProgressWindow : Window {
5560

5661
icon_image = builder.get_object("icon_image") as Image;
5762

63+
spinner = builder.get_object("spinner") as Spinner;
64+
65+
revealer1 = builder.get_object("revealer1") as Revealer;
66+
revealer1.set_reveal_child (true);
67+
revealer2 = builder.get_object("revealer2") as Revealer;
68+
revealer2.set_reveal_child (false);
69+
70+
spinner.set_vexpand(true);
71+
spinner.set_hexpand(true);
72+
5873
btn_cancel = builder.get_object("btn_cancel") as Button;
59-
btn_cancel.clicked.connect(cancel);
74+
btn_cancel.clicked.connect(main_quit);
6075

6176
btn_quit = builder.get_object("btn_quit") as Button;
6277
btn_quit.clicked.connect(Gtk.main_quit);
@@ -115,9 +130,7 @@ public class ProgressWindow : Window {
115130
ChildWatch.add (child_pid, (pid, status) => {
116131
// Triggered when the child indicated by child_pid exits
117132
Process.close_pid (pid);
118-
btn_cancel.set_label("Close");
119-
btn_quit.set_visible(true);
120-
btn_show_files.set_visible(true);
133+
121134
});
122135

123136
} catch (SpawnError e) {
@@ -137,14 +150,27 @@ public class ProgressWindow : Window {
137150
string line;
138151
channel.read_line (out line, null, null);
139152
stdout.printf(line); // Be verbose
140-
file_counts = 30; // TODO: Get from command line output
153+
total_steps = 30; // TODO: Get from command line output
141154
action_label.label = line.substring(0, line.length - 1);
142155
counter++;
143-
progress.set_fraction( 1.0f * counter / file_counts);
156+
progress.set_fraction( 1.0f * counter / total_steps);
157+
if(progress.get_fraction() == 1) spinner.stop();
158+
if(line.contains("Target 100.0% complete")) {
159+
result_file_name=line.replace("Read ","").replace(". Target 100.0% complete.","");
160+
result_file_name=result_file_name.substring(0, result_file_name.length - 1).strip();
161+
result_file_name=Path.build_path (Path.DIR_SEPARATOR_S, Path.get_dirname(this.file_name), Path.get_basename(result_file_name));
162+
}
144163
if(line.contains("checksum matches OK")) {
164+
revealer1.set_reveal_child (false);
165+
revealer2.set_reveal_child (true);
145166
icon_image.icon_name="emblem-ok-symbolic";
167+
Posix.system("chmod 0755 " + result_file_name); // Because the CLI does not reliably do it (FIXME)
168+
btn_show_files.set_visible(true);
146169
}
170+
147171
if(line.contains("Cannot")) {
172+
revealer1.set_reveal_child (false);
173+
revealer2.set_reveal_child (true);
148174
icon_image.icon_name="dialog-error-symbolic";
149175
}
150176
} catch (IOChannelError e) {
@@ -181,13 +207,19 @@ public class ProgressWindow : Window {
181207
}
182208

183209
private void show_files() {
184-
// To be implemented
185-
this.close();
210+
print(result_file_name);
211+
try {
212+
Posix.system(result_file_name + " &");
213+
214+
} catch (SpawnError e) {
215+
stdout.printf("Error launching file: " + e.message);
216+
}
217+
main_quit();
186218
}
187219

188220
private void cancel() {
189221
Posix.kill(child_pid, Posix.SIGTERM);
190-
this.close();
222+
main_quit();
191223
}
192224

193225
}

appimageupdategui/ui/progress.ui

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- Generated with glade 3.16.1 -->
2+
<!-- Generated with glade 3.19.0 -->
33
<interface>
44
<requires lib="gtk+" version="3.10"/>
55
<object class="GtkBox" id="main_box">
@@ -12,29 +12,35 @@
1212
<property name="orientation">vertical</property>
1313
<property name="spacing">8</property>
1414
<child>
15-
<object class="GtkImage" id="icon_image">
15+
<object class="GtkRevealer" id="revealer1">
16+
<property name="height_request">64</property>
1617
<property name="visible">True</property>
1718
<property name="can_focus">False</property>
18-
<property name="yalign">0</property>
19-
<property name="ypad">16</property>
20-
<property name="pixel_size">64</property>
21-
<property name="icon_name">emblem-synchronizing-symbolic</property>
22-
<property name="icon_size">6</property>
19+
<property name="transition_type">crossfade</property>
20+
<property name="reveal_child">True</property>
21+
<child>
22+
<object class="GtkSpinner" id="spinner">
23+
<property name="width_request">128</property>
24+
<property name="visible">True</property>
25+
<property name="can_focus">False</property>
26+
<property name="active">True</property>
27+
</object>
28+
</child>
2329
</object>
2430
<packing>
2531
<property name="expand">False</property>
26-
<property name="fill">False</property>
32+
<property name="fill">True</property>
2733
<property name="position">0</property>
2834
</packing>
2935
</child>
3036
<child>
3137
<object class="GtkLabel" id="action_label">
3238
<property name="visible">True</property>
3339
<property name="can_focus">False</property>
34-
<property name="xalign">0</property>
3540
<property name="ellipsize">end</property>
3641
<property name="single_line_mode">True</property>
3742
<property name="lines">1</property>
43+
<property name="xalign">0</property>
3844
</object>
3945
<packing>
4046
<property name="expand">False</property>
@@ -50,9 +56,9 @@
5056
<property name="margin_right">5</property>
5157
<property name="spacing">10</property>
5258
<child>
53-
<object class="GtkButton" id="btn_cancel">
54-
<property name="label" translatable="yes">Cancel</property>
55-
<property name="visible">True</property>
59+
<object class="GtkButton" id="btn_show_files">
60+
<property name="label" translatable="yes">Launch now</property>
61+
<property name="visible">False</property>
5662
<property name="can_focus">True</property>
5763
<property name="receives_default">True</property>
5864
</object>
@@ -63,17 +69,7 @@
6369
</packing>
6470
</child>
6571
<child>
66-
<object class="GtkButton" id="btn_show_files">
67-
<property name="label" translatable="yes">Launch now</property>
68-
<property name="visible">True</property>
69-
<property name="can_focus">True</property>
70-
<property name="receives_default">True</property>
71-
</object>
72-
<packing>
73-
<property name="expand">False</property>
74-
<property name="fill">True</property>
75-
<property name="position">1</property>
76-
</packing>
72+
<placeholder/>
7773
</child>
7874
<child>
7975
<object class="GtkButton" id="btn_quit">
@@ -114,8 +110,8 @@
114110
<object class="GtkLabel" id="message_label">
115111
<property name="visible">True</property>
116112
<property name="can_focus">False</property>
117-
<property name="xalign">0</property>
118113
<property name="ellipsize">end</property>
114+
<property name="xalign">0</property>
119115
<attributes>
120116
<attribute name="size" value="9000"/>
121117
</attributes>
@@ -126,5 +122,29 @@
126122
<property name="position">4</property>
127123
</packing>
128124
</child>
125+
<child>
126+
<object class="GtkRevealer" id="revealer2">
127+
<property name="visible">True</property>
128+
<property name="can_focus">False</property>
129+
<property name="transition_type">crossfade</property>
130+
<property name="reveal_child">True</property>
131+
<child>
132+
<object class="GtkImage" id="icon_image">
133+
<property name="visible">True</property>
134+
<property name="can_focus">False</property>
135+
<property name="yalign">0</property>
136+
<property name="ypad">16</property>
137+
<property name="pixel_size">64</property>
138+
<property name="icon_name">emblem-synchronizing-symbolic</property>
139+
<property name="icon_size">6</property>
140+
</object>
141+
</child>
142+
</object>
143+
<packing>
144+
<property name="expand">False</property>
145+
<property name="fill">True</property>
146+
<property name="position">5</property>
147+
</packing>
148+
</child>
129149
</object>
130150
</interface>

0 commit comments

Comments
 (0)