~midori/midori/trunk

« back to all changes in this revision

Viewing changes to panels/midori-history.c

  • Committer: Paweł Forysiuk
  • Date: 2013-06-26 21:54:50 UTC
  • mto: This revision was merged to the branch mainline in revision 6236.
  • Revision ID: tuxator@o2.pl-20130626215450-kggoohposem521er
Bump glib2 version to 2.32.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
    return STOCK_HISTORY;
118
118
}
119
119
 
120
 
#if !GLIB_CHECK_VERSION (2, 26, 0)
121
 
static gint
122
 
sokoke_days_between (const time_t* day1,
123
 
                     const time_t* day2)
124
 
{
125
 
    GDate* date1;
126
 
    GDate* date2;
127
 
    gint age;
128
 
 
129
 
    date1 = g_date_new ();
130
 
    date2 = g_date_new ();
131
 
 
132
 
    g_date_set_time_t (date1, *day1);
133
 
    g_date_set_time_t (date2, *day2);
134
 
 
135
 
    age = g_date_days_between (date1, date2);
136
 
 
137
 
    g_date_free (date1);
138
 
    g_date_free (date2);
139
 
 
140
 
    return age;
141
 
}
142
 
#endif
143
 
 
144
120
static gchar*
145
121
midori_history_format_date (KatzeItem *item)
146
122
{
147
123
    gint64 day = katze_item_get_added (item);
148
124
    gchar* sdate;
149
125
    gint age;
150
 
    #if GLIB_CHECK_VERSION (2, 26, 0)
151
126
    GDateTime* now = g_date_time_new_now_local ();
152
127
    GDateTime* then = g_date_time_new_from_unix_local (day);
153
128
    age = g_date_time_get_day_of_year (now) - g_date_time_get_day_of_year (then);
167
142
        sdate = g_date_time_format (then, "%x");
168
143
    g_date_time_unref (now);
169
144
    g_date_time_unref (then);
170
 
    #else
171
 
    gchar token[50];
172
 
    time_t current_time;
173
 
 
174
 
    current_time = time (NULL);
175
 
    age = sokoke_days_between ((time_t*)&day, &current_time);
176
 
 
177
 
    /* A negative age is a date in the future, the clock is probably off */
178
 
    if (age < -1)
179
 
        sdate = g_strdup ("");
180
 
    else if (age > 7 || age < 0)
181
 
    {
182
 
        strftime (token, sizeof (token), "%x", localtime ((time_t*)&day));
183
 
        sdate = g_strdup (token);
184
 
    }
185
 
    else if (age > 6)
186
 
        sdate = g_strdup (_("A week ago"));
187
 
    else if (age > 1)
188
 
        sdate = g_strdup_printf (ngettext ("%d day ago",
189
 
            "%d days ago", (gint)age), (gint)age);
190
 
    else if (age == 0)
191
 
        sdate = g_strdup (_("Today"));
192
 
    else
193
 
        sdate = g_strdup (_("Yesterday"));
194
 
    #endif
 
145
 
195
146
    return sdate;
196
147
}
197
148
 
466
417
        gtk_tree_model_get (model, &iter, 0, &today, -1);
467
418
 
468
419
        day = katze_item_get_added (today);
469
 
        #if GLIB_CHECK_VERSION (2, 26, 0)
470
420
        has_today = g_date_time_get_day_of_month (
471
421
            g_date_time_new_from_unix_local (day))
472
422
         == g_date_time_get_day_of_month (
475
425
            g_date_time_new_from_unix_local (day))
476
426
         == g_date_time_get_day_of_year (
477
427
            g_date_time_new_from_unix_local (current_time));
478
 
        #else
479
 
        has_today = sokoke_days_between ((time_t*)&day, &current_time) == 0;
480
 
        #endif
481
428
        g_object_unref (today);
 
429
 
482
430
        if (has_today)
483
431
        {
484
432
            gchar* tooltip = g_markup_escape_text (katze_item_get_uri (item), -1);