mirror of
https://gitlab.gnome.org/World/tootle
synced 2025-02-16 11:30:48 +01:00
Fix #240
This commit is contained in:
parent
577f0c1b68
commit
bc5a4a53fe
50
data/ui/widgets/timeline_footer.ui
Normal file
50
data/ui/widgets/timeline_footer.ui
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<template class="TootleViewsTimelineFooter" parent="GtkListBoxRow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="activatable">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="revealer">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="reveal_child">True</property>
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">8</property>
|
||||
<property name="margin_right">8</property>
|
||||
<property name="margin_top">8</property>
|
||||
<property name="margin_bottom">8</property>
|
||||
<property name="transition_duration">100</property>
|
||||
<property name="transition_type">crossfade</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label">Label</property>
|
||||
<property name="single_line_mode">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page0</property>
|
||||
<property name="title" translatable="yes">page0</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
@ -38,8 +38,7 @@ public class Tootle.Desktop {
|
||||
}
|
||||
|
||||
// Download a file from the web to a user's configured Downloads folder
|
||||
public delegate void DownloadCallback (string path);
|
||||
public static void download (string url, owned DownloadCallback cb, owned Network.ErrorCallback ecb) {
|
||||
public async static string download (string url) throws Error {
|
||||
message (@"Downloading file: $url...");
|
||||
|
||||
var file_name = Path.get_basename (url);
|
||||
@ -56,29 +55,26 @@ public class Tootle.Desktop {
|
||||
dir_path,
|
||||
str_hash (dir_name).to_string () + file_name);
|
||||
|
||||
new Request.GET (url)
|
||||
.then ((sess, msg) => {
|
||||
try {
|
||||
var dir = File.new_for_path (dir_path);
|
||||
if (!dir.query_exists ())
|
||||
dir.make_directory ();
|
||||
var dir = File.new_for_path (dir_path);
|
||||
if (!dir.query_exists ())
|
||||
dir.make_directory_with_parents ();
|
||||
|
||||
var file = File.new_for_path (file_path);
|
||||
if (!file.query_exists ()) {
|
||||
var data = msg.response_body.data;
|
||||
FileOutputStream stream = file.create (FileCreateFlags.PRIVATE);
|
||||
stream.write (data);
|
||||
}
|
||||
message (@"OK: File written to: $file_path");
|
||||
cb (file_path);
|
||||
var file = File.new_for_path (file_path);
|
||||
|
||||
} catch (Error e) {
|
||||
warning ("Error: %s\n", e.message);
|
||||
ecb (0, e.message);
|
||||
}
|
||||
})
|
||||
.on_error ((owned) ecb)
|
||||
.exec ();
|
||||
if (!file.query_exists ()) {
|
||||
var msg = yield new Request.GET (url)
|
||||
.await ();
|
||||
|
||||
var data = msg.response_body.data;
|
||||
FileOutputStream stream = file.create (FileCreateFlags.PRIVATE);
|
||||
stream.write (data);
|
||||
|
||||
message (@"OK: File written to: $file_path");
|
||||
}
|
||||
else
|
||||
message ("OK: File exists already");
|
||||
|
||||
return file_path;
|
||||
}
|
||||
|
||||
public static string fallback_icon (string normal, string fallback, string fallback2 = "broken") {
|
||||
|
@ -51,6 +51,7 @@ public class Tootle.Views.Timeline : IAccountListener, IStreamListener, Views.Ba
|
||||
this.page_prev = null;
|
||||
this.page_next = null;
|
||||
this.is_last_page = false;
|
||||
this.needs_attention = false;
|
||||
base.clear ();
|
||||
}
|
||||
|
||||
|
@ -41,18 +41,17 @@ public class Tootle.Widgets.Attachment.Slot : FlowBoxChild {
|
||||
button.tooltip_text = attachment.description;
|
||||
}
|
||||
|
||||
void download () {
|
||||
Desktop.download (attachment.url, path => {
|
||||
app.toast (_("File saved to Downloads"));
|
||||
},
|
||||
() => {});
|
||||
}
|
||||
|
||||
void open () {
|
||||
Desktop.download (attachment.url, path => {
|
||||
Desktop.open_uri (path);
|
||||
},
|
||||
() => {});
|
||||
Desktop.download.begin (attachment.url, (obj, res) => {
|
||||
try {
|
||||
var path = Desktop.download.end (res);
|
||||
Desktop.open_uri (path);
|
||||
}
|
||||
catch (Error e) {
|
||||
app.error (_("Error"), e.message);
|
||||
warning ("!!!" + e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
|
Loading…
x
Reference in New Issue
Block a user