~ubuntu-branches/ubuntu/raring/shotwell/raring

« back to all changes in this revision

Viewing changes to src/Resources.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-09-20 15:21:41 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20120920152141-lcfo2j5d8f3zs0c6
Tags: 0.13.0-0ubuntu1
* New upstream bugfix release
* debian/watch:
  - Watch for stable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
637
637
    private Gee.HashMap<string, Gdk.Pixbuf> icon_cache = null;
638
638
    Gee.HashMap<string, Gdk.Pixbuf> scaled_icon_cache = null;
639
639
    
 
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;
 
645
        
640
646
    public void init () {
641
647
        // load application-wide stock icons as IconSets
642
648
        factory = new Gtk.IconFactory();
674
680
    
675
681
    public void terminate() {
676
682
    }
 
683
    
 
684
    /**
 
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.
 
689
     * 
 
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.
 
693
     */
 
694
    private void fetch_lc_time_format() {
 
695
        // temporarily unset LANGUAGE, as it interferes with LC_TIME
 
696
        // and friends.
 
697
        string? old_language = Environment.get_variable("LANGUAGE");
 
698
        if (old_language != null) {
 
699
            Environment.unset_variable("LANGUAGE");
 
700
        }
 
701
        
 
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);
 
705
        
 
706
        if (lc_time != null) {
 
707
            Intl.setlocale(LocaleCategory.MESSAGES, lc_time);
 
708
        }
 
709
        
 
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");
 
716
        
 
717
        // ...put everything back like we found it.
 
718
        if (old_messages != null) {
 
719
            Intl.setlocale(LocaleCategory.MESSAGES, old_messages);
 
720
        }
 
721
        
 
722
        if (old_language != null) {
 
723
            Environment.set_variable("LANGUAGE", old_language, true);
 
724
        }
 
725
    }
 
726
    
 
727
    /**
 
728
     * @brief Returns a precached format string that matches the
 
729
     * user's LC_TIME settings.  
 
730
     */
 
731
    public string get_hh_mm_format_string() {
 
732
        if (HH_MM_FORMAT_STRING == null) {
 
733
            fetch_lc_time_format();
 
734
        }
 
735
        
 
736
        return HH_MM_FORMAT_STRING;
 
737
    }
 
738
    
 
739
    public string get_long_date_format_string() {
 
740
        if (LONG_DATE_FORMAT_STRING == null) {
 
741
            fetch_lc_time_format();
 
742
        }
 
743
        
 
744
        return LONG_DATE_FORMAT_STRING;
 
745
    }
 
746
    
 
747
    public string get_start_multiday_span_format_string() {
 
748
        if (START_MULTIDAY_DATE_FORMAT_STRING == null) {
 
749
            fetch_lc_time_format();
 
750
        }
 
751
        
 
752
        return START_MULTIDAY_DATE_FORMAT_STRING;
 
753
    }
 
754
 
 
755
    public string get_end_multiday_span_format_string() {
 
756
        if (END_MULTIDAY_DATE_FORMAT_STRING == null) {
 
757
            fetch_lc_time_format();
 
758
        }
 
759
        
 
760
        return END_MULTIDAY_DATE_FORMAT_STRING;
 
761
    }
 
762
 
 
763
    public string get_start_multimonth_span_format_string() {
 
764
        if (START_MULTIMONTH_DATE_FORMAT_STRING == null) {
 
765
            fetch_lc_time_format();
 
766
        }
 
767
        
 
768
        return START_MULTIMONTH_DATE_FORMAT_STRING;
 
769
    }
 
770
 
 
771
    public string get_end_multimonth_span_format_string() {
 
772
        return get_long_date_format_string();
 
773
    }
677
774
 
678
775
    public File get_ui(string filename) {
679
776
        return AppDirs.get_resources_dir().get_child("ui").get_child(filename);