Changeset 81

Show
Ignore:
Timestamp:
04/17/08 15:05:50
Author:
pvanhoof
Message:

2008-04-17 Philip Van Hoof <pvanhoof@gnome.org>

        • Introduced the library libtmut-1.0
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r76 r81  
     12008-04-17  Philip Van Hoof  <pvanhoof@gnome.org> 
     2 
     3        * Introduced the library libtmut-1.0 
     4 
    152008-04-15  Philip Van Hoof  <pvanhoof@gnome.org> 
    26 
  • trunk/src/Makefile.am

    r80 r81  
    3131 
    3232libtmut_1_0_la_SOURCES = $(libtmut_headers) \ 
     33        tmut-shared.c \ 
    3334        tmut-platform-factory.c \ 
    3435        tmut-menu-view.c \ 
  • trunk/src/tmut-main.c

    r47 r81  
    2828#include <tny-account-store-view.h> 
    2929 
    30  
    3130#include "tmut-platform-factory.h" 
    3231#include "tmut-menu-view.h" 
    3332#include "tmut-shell-window.h" 
    34  
    35 TnyPlatformFactory *platfact = NULL; 
    36 GHashTable *send_queues = NULL; 
     33#include "tmut-shared.h" 
    3734 
    3835int  
     
    7774} 
    7875 
    79  
    80 gchar * 
    81 _get_readable_date (time_t mtime) 
    82 { 
    83         time_t now; 
    84         struct tm file_time; 
    85  
    86         /**  
    87          * We reuse a static char. Now hold your breath and listen. This is not 
    88          * wrong and I'll explain why: each component that uses this function 
    89          * is called from the Gtk+ context. The Gtk+ context can never run in 
    90          * parallel with another context because Gtk+ is locked using its 
    91          * gdk_threads_enter/leave lock. This means that there's always at most 
    92          * one thread doing Gtk+ things. This means that this function does not 
    93          * have to be thread safe. And that means that we can have a static  
    94          * buffer that we'll play with. Else we could also do a pthread_once  
    95          * or something.  
    96          * 
    97          * I here the children cry things like: waaayyyy?? Well the reason is to 
    98          * avoid a malloc(). This stuff happens quite often. If we can reuse one 
    99          * buffer each time, that's fine! The GtkTreeView (if this time that is 
    100          * consumer)  makes its own copy. Same for any other Gtk+ component that 
    101          * accepts strings (like a GtkEntry or a GtkLabel). It will make its own 
    102          * copy anyway! If we are going to copy here, that's two copies rather  
    103          * than just the one copy in Gtk+ that we have no control over. 
    104          **/ 
    105  
    106         static gchar readable_date[64]; 
    107  
    108         gsize readable_date_size; 
    109         int days_now, days_then; 
    110  
    111         gmtime_r (&mtime, &file_time); 
    112         now = time (NULL);  
    113  
    114         /* The idea is that if the amount of days is not the same, we display 
    115          * the full date. Else we just display the time. Note that there's a 
    116          * hidden bug in this: days_then is the remote timezone, days_now is the 
    117          * local timezone. At some point we should fix this! */ 
    118  
    119         days_now = now / (24*60*60); 
    120         days_then = mtime / (24*60*60); 
    121  
    122         /* I think we can fix this using localtime_r */ 
    123  
    124         if (days_now == days_then) {  
    125                 /* Translator: this date-format is the date format for when creating a 
    126                  * reply of a message if the date is today */ 
    127                 readable_date_size = strftime (readable_date, 63, _("%X"), &file_time); 
    128         } else {  
    129                 /* Translator: this date-format is the date format for when creating a 
    130                  * reply of a message if the date is not today */ 
    131                 readable_date_size = strftime (readable_date, 63, _("%x"), &file_time); 
    132         } 
    133  
    134         if (readable_date_size > 0) 
    135                 return readable_date; 
    136  
    137         return NULL; 
    138 }