637
637
private Gee.HashMap<string, Gdk.Pixbuf> icon_cache = null;
638
638
Gee.HashMap<string, Gdk.Pixbuf> scaled_icon_cache = null;
640
private string HH_MM_FORMAT_STRING = null;
641
private string LONG_DATE_FORMAT_STRING = null;
642
private string START_MULTIDAY_DATE_FORMAT_STRING = null;
643
private string END_MULTIDAY_DATE_FORMAT_STRING = null;
644
private string START_MULTIMONTH_DATE_FORMAT_STRING = null;
640
646
public void init () {
641
647
// load application-wide stock icons as IconSets
642
648
factory = new Gtk.IconFactory();
675
681
public void terminate() {
685
* @brief Helper for getting a format string that matches the
686
* user's LC_TIME settings from the system. This is intended
687
* to help support the use case where a user wants the text
688
* from one locale, but the timestamp format of another.
690
* Stolen wholesale from code written for Geary by Jim Nelson
691
* and from Marcel Stimberg's original patch to Shotwell to
692
* try to fix this; both are graciously thanked for their help.
694
private void fetch_lc_time_format() {
695
// temporarily unset LANGUAGE, as it interferes with LC_TIME
697
string? old_language = Environment.get_variable("LANGUAGE");
698
if (old_language != null) {
699
Environment.unset_variable("LANGUAGE");
702
// switch LC_MESSAGES to LC_TIME...
703
string? old_messages = Intl.setlocale(LocaleCategory.MESSAGES, null);
704
string? lc_time = Intl.setlocale(LocaleCategory.TIME, null);
706
if (lc_time != null) {
707
Intl.setlocale(LocaleCategory.MESSAGES, lc_time);
710
// ...precache the timestamp string...
711
HH_MM_FORMAT_STRING = _("%I:%M %p");
712
LONG_DATE_FORMAT_STRING = _("%a %b %d, %Y");
713
START_MULTIDAY_DATE_FORMAT_STRING = _("%a %b %d");
714
END_MULTIDAY_DATE_FORMAT_STRING = _("%d, %Y");
715
START_MULTIMONTH_DATE_FORMAT_STRING = _("%a %b %d");
717
// ...put everything back like we found it.
718
if (old_messages != null) {
719
Intl.setlocale(LocaleCategory.MESSAGES, old_messages);
722
if (old_language != null) {
723
Environment.set_variable("LANGUAGE", old_language, true);
728
* @brief Returns a precached format string that matches the
729
* user's LC_TIME settings.
731
public string get_hh_mm_format_string() {
732
if (HH_MM_FORMAT_STRING == null) {
733
fetch_lc_time_format();
736
return HH_MM_FORMAT_STRING;
739
public string get_long_date_format_string() {
740
if (LONG_DATE_FORMAT_STRING == null) {
741
fetch_lc_time_format();
744
return LONG_DATE_FORMAT_STRING;
747
public string get_start_multiday_span_format_string() {
748
if (START_MULTIDAY_DATE_FORMAT_STRING == null) {
749
fetch_lc_time_format();
752
return START_MULTIDAY_DATE_FORMAT_STRING;
755
public string get_end_multiday_span_format_string() {
756
if (END_MULTIDAY_DATE_FORMAT_STRING == null) {
757
fetch_lc_time_format();
760
return END_MULTIDAY_DATE_FORMAT_STRING;
763
public string get_start_multimonth_span_format_string() {
764
if (START_MULTIMONTH_DATE_FORMAT_STRING == null) {
765
fetch_lc_time_format();
768
return START_MULTIMONTH_DATE_FORMAT_STRING;
771
public string get_end_multimonth_span_format_string() {
772
return get_long_date_format_string();
678
775
public File get_ui(string filename) {
679
776
return AppDirs.get_resources_dir().get_child("ui").get_child(filename);