support platforms without UTF-8 and use native file picker
This commit is contained in:
parent
7c2023803e
commit
b428c3a627
|
@ -110,25 +110,34 @@ public class ConversationItemSkeleton : Grid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string format_time(DateTime datetime, string format_24h, string format_12h) {
|
||||||
|
string format = Util.is_24h_format() ? format_24h : format_12h;
|
||||||
|
if (!get_charset(null)) {
|
||||||
|
// No UTF-8 support, use simple colon for time instead
|
||||||
|
format = format.replace("∶", ":");
|
||||||
|
}
|
||||||
|
return datetime.format(format);
|
||||||
|
}
|
||||||
|
|
||||||
private static string get_relative_time(DateTime datetime) {
|
private static string get_relative_time(DateTime datetime) {
|
||||||
DateTime now = new DateTime.now_local();
|
DateTime now = new DateTime.now_local();
|
||||||
TimeSpan timespan = now.difference(datetime);
|
TimeSpan timespan = now.difference(datetime);
|
||||||
if (timespan > 365 * TimeSpan.DAY) {
|
if (timespan > 365 * TimeSpan.DAY) {
|
||||||
return datetime.format(Util.is_24h_format() ?
|
return format_time(datetime,
|
||||||
/* xgettext:no-c-format */ /* Date + time in 24h format (w/o seconds) */ _("%x, %H\u2236%M") :
|
/* xgettext:no-c-format */ /* Date + time in 24h format (w/o seconds) */ _("%x, %H∶%M"),
|
||||||
/* xgettext:no-c-format */ /* Date + time in 12h format (w/o seconds)*/ _("%x, %l\u2236%M %p"));
|
/* xgettext:no-c-format */ /* Date + time in 12h format (w/o seconds)*/ _("%x, %l∶%M %p"));
|
||||||
} else if (timespan > 7 * TimeSpan.DAY) {
|
} else if (timespan > 7 * TimeSpan.DAY) {
|
||||||
return datetime.format(Util.is_24h_format() ?
|
return format_time(datetime,
|
||||||
/* xgettext:no-c-format */ /* Month, day and time in 24h format (w/o seconds) */ _("%b %d, %H\u2236%M") :
|
/* xgettext:no-c-format */ /* Month, day and time in 24h format (w/o seconds) */ _("%b %d, %H∶%M"),
|
||||||
/* xgettext:no-c-format */ /* Month, day and time in 12h format (w/o seconds) */ _("%b %d, %l\u2236%M %p"));
|
/* xgettext:no-c-format */ /* Month, day and time in 12h format (w/o seconds) */ _("%b %d, %l∶%M %p"));
|
||||||
} else if (datetime.get_day_of_month() != new DateTime.now_utc().get_day_of_month()) {
|
} else if (datetime.get_day_of_month() != new DateTime.now_utc().get_day_of_month()) {
|
||||||
return datetime.format(Util.is_24h_format() ?
|
return format_time(datetime,
|
||||||
/* xgettext:no-c-format */ /* Day of week and time in 12h format (w/o seconds) */ _("%a, %H\u2236%M") :
|
/* xgettext:no-c-format */ /* Day of week and time in 24h format (w/o seconds) */ _("%a, %H∶%M"),
|
||||||
/* xgettext:no-c-format */ _("%a, %l\u2236%M %p"));
|
/* xgettext:no-c-format */ /* Day of week and time in 12h format (w/o seconds) */_("%a, %l∶%M %p"));
|
||||||
} else if (timespan > 9 * TimeSpan.MINUTE) {
|
} else if (timespan > 9 * TimeSpan.MINUTE) {
|
||||||
return datetime.format(Util.is_24h_format() ?
|
return format_time(datetime,
|
||||||
/* xgettext:no-c-format */ /* Time in 24h format (w/o seconds) */ _("%H\u2236%M") :
|
/* xgettext:no-c-format */ /* Time in 24h format (w/o seconds) */ _("%H∶%M"),
|
||||||
/* xgettext:no-c-format */ /* Time in 12h format (w/o seconds) */ _("%l\u2236%M %p"));
|
/* xgettext:no-c-format */ /* Time in 12h format (w/o seconds) */ _("%l∶%M %p"));
|
||||||
} else if (timespan > TimeSpan.MINUTE) {
|
} else if (timespan > TimeSpan.MINUTE) {
|
||||||
ulong mins = (ulong) (timespan.abs() / TimeSpan.MINUTE);
|
ulong mins = (ulong) (timespan.abs() / TimeSpan.MINUTE);
|
||||||
/* xgettext:this is the beginning of a sentence. */
|
/* xgettext:this is the beginning of a sentence. */
|
||||||
|
|
0
main/src/ui/conversation_summary/message_item.vala
Normal file
0
main/src/ui/conversation_summary/message_item.vala
Normal file
|
@ -146,18 +146,26 @@ public class Dialog : Gtk.Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_select_avatar() {
|
private void show_select_avatar() {
|
||||||
FileChooserDialog chooser = new FileChooserDialog (
|
FileChooserNative chooser = new FileChooserNative (
|
||||||
_("Select avatar"), this, FileChooserAction.OPEN,
|
_("Select avatar"), this, FileChooserAction.OPEN,
|
||||||
_("Cancel"), ResponseType.CANCEL,
|
_("Select"), _("Cancel"));
|
||||||
_("Select"), ResponseType.ACCEPT);
|
|
||||||
FileFilter filter = new FileFilter();
|
FileFilter filter = new FileFilter();
|
||||||
filter.add_mime_type("image/*");
|
filter.add_pattern("*.png");
|
||||||
chooser.set_filter(filter);
|
filter.add_pattern("*.jpg");
|
||||||
|
filter.add_pattern("*.jpeg");
|
||||||
|
filter.add_pattern("*.gif");
|
||||||
|
filter.add_pattern("*.svg");
|
||||||
|
filter.add_pattern("*.bmp");
|
||||||
|
filter.set_filter_name(_("Images"));
|
||||||
|
chooser.add_filter(filter);
|
||||||
|
filter = new FileFilter();
|
||||||
|
filter.set_filter_name(_("All files"));
|
||||||
|
filter.add_pattern("*");
|
||||||
|
chooser.add_filter(filter);
|
||||||
if (chooser.run() == Gtk.ResponseType.ACCEPT) {
|
if (chooser.run() == Gtk.ResponseType.ACCEPT) {
|
||||||
string uri = chooser.get_filename();
|
string uri = chooser.get_filename();
|
||||||
stream_interactor.get_module(AvatarManager.IDENTITY).publish(selected_account, uri);
|
stream_interactor.get_module(AvatarManager.IDENTITY).publish(selected_account, uri);
|
||||||
}
|
}
|
||||||
chooser.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool on_active_switch_state_changed(bool state) {
|
private bool on_active_switch_state_changed(bool state) {
|
||||||
|
|
|
@ -35,10 +35,9 @@ public class ConversationTitlebarWidget : Button, Plugins.ConversationTitlebarWi
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_clicked() {
|
public void on_clicked() {
|
||||||
FileChooserDialog chooser = new FileChooserDialog (
|
FileChooserNative chooser = new FileChooserNative (
|
||||||
"Select file", null, FileChooserAction.OPEN,
|
"Select file", get_toplevel() as Window, FileChooserAction.OPEN,
|
||||||
"Cancel", ResponseType.CANCEL,
|
"Select", "Cancel");
|
||||||
"Select", ResponseType.ACCEPT);
|
|
||||||
int? max_file_size = stream_interactor.get_module(Manager.IDENTITY).get_max_file_size(conversation.account);
|
int? max_file_size = stream_interactor.get_module(Manager.IDENTITY).get_max_file_size(conversation.account);
|
||||||
if (max_file_size != null) {
|
if (max_file_size != null) {
|
||||||
FileFilter filter = new FileFilter();
|
FileFilter filter = new FileFilter();
|
||||||
|
@ -53,7 +52,6 @@ public class ConversationTitlebarWidget : Button, Plugins.ConversationTitlebarWi
|
||||||
string uri = chooser.get_filename();
|
string uri = chooser.get_filename();
|
||||||
stream_interactor.get_module(Manager.IDENTITY).send(conversation, uri);
|
stream_interactor.get_module(Manager.IDENTITY).send(conversation, uri);
|
||||||
}
|
}
|
||||||
chooser.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_upload_available(Account account) {
|
public void on_upload_available(Account account) {
|
||||||
|
|
Loading…
Reference in a new issue