44
44
clock_set_current_time (MidoriBrowser* browser)
46
MidoriExtension* extension;
47
MidoriExtension* extension = g_object_get_data (G_OBJECT (browser), "clock-extension");
48
GtkWidget* label = g_object_get_data (G_OBJECT (browser), "clock-label");
49
const gchar* format = midori_extension_get_string (extension, "format");
51
GDateTime* date = g_date_time_new_now_local ();
52
gint seconds = g_date_time_get_seconds (date);
53
gchar* pretty = g_date_time_format (date, format);
54
gtk_label_set_label (GTK_LABEL (label), pretty);
56
g_date_time_unref (date);
54
extension = g_object_get_data (G_OBJECT (browser), "clock-extension");
55
label = g_object_get_data (G_OBJECT (browser), "clock-label");
56
format = midori_extension_get_string (extension, "format");
58
rawtime = time (NULL);
59
tm = localtime (&rawtime);
61
strftime (datestring, 60, format, tm);
62
gtk_label_set_label (GTK_LABEL (label), datestring);
58
64
if (g_strstr_len (format, -1, "%c")
59
65
|| g_strstr_len (format, -1, "%N")
67
73
/* FIXME: Occasionally there are more than 60 seconds in a minute. */
68
interval = MAX (60 - seconds, 1);
74
interval = MAX (60 - tm->tm_sec, 1);
70
76
clock_set_timeout (browser, interval);