Addition to clock applet
- From: Phil Borman <pb pborman freeserve co uk>
- To: gnome-hackers gnome org
- Subject: Addition to clock applet
- Date: Wed, 7 Nov 2001 22:50:32 +0000
I've added a "fuzzy" mode to the gnome panel clock. Shows the time in english
words, eg "twenty past one". I don't know who to submit this to for
inclusion, or what form it needs to be in, but I'm told the gnome panel
maintainers use this mailing list? Diff attached.
Please cc any reply to me by email as I've not been invited to subscribe to
this mailing list.
44a45
> gboolean fuzzytime;
56a58
> gboolean prop_fuzzytime;
128a131
> gnome_config_set_int("clock/fuzzytime", cd->fuzzytime);
178a182,219
>
> } else if (cd->fuzzytime) {
> int hr = tm->tm_hour;
> int mn = tm->tm_min;
> int pt = 0;
>
> static char *hours[] = {"midnight","one","two","three","four","five","six",
> "seven","eight","nine","ten","eleven","twelve"};
> static char *mins[] = {"o'clock","five","ten","quarter","twenty","twenty five","half"};
> static char *past[] = {"past","to"};
>
> mn += 2; /* two minutes before until 3 minutes after... */
>
> mn /= 5;
>
> if (mn > 6) pt = 1; /* PAST the hour, or TO the hour */
> if (pt) hr++; /* TO the next hour */
> if (hr == 24) hr = 0; /* handle TO midnight */
> if (hr > 12) hr -= 12;
> if (mn > 6) mn = 12 - mn; /* handle 25to, 20to, etc */
>
> if (mn)
> g_snprintf(hour,sizeof(hour),"%s %s\n%s",mins[mn],past[pt],hours[hr]);
> else
> if (hr != 0)
> g_snprintf(hour,sizeof(hour),"%s\no'clock",hours[hr]);
> else
> g_snprintf(hour,sizeof(hour),"%s",hours[hr]);
>
> /* for vertical displays, linefeed after every word & at the end too */
> if ((cd->orient == ORIENT_LEFT || cd->orient == ORIENT_RIGHT) &&
> cd->size >= PIXEL_SIZE_STANDARD) {
> int i;
> for(i=0; i<strlen(hour); i++)
> if(hour[i] == ' ') hour[i] = '\n';
> strcat(hour,"\n");
> }
> g_string_append(gs,hour);
203c244
< if (cd->showdate && !cd->unixtime && !cd->internettime) {
---
> if (cd->showdate && !cd->unixtime && !cd->internettime && !cd->fuzzytime) {
225a267,271
> if (cd->fuzzytime) {
> if (strftime(tooltip, sizeof (tooltip), _("%H:%M, %A, %B %d"), tm) <= 0)
> strcpy (tooltip, "???");
> }
> else {
228c274,275
< applet_widget_set_tooltip(APPLET_WIDGET(cd->applet), tooltip);
---
> }
> applet_widget_set_tooltip(APPLET_WIDGET(cd->applet), tooltip);
388a436,445
> } else if (cd->fuzzytime) {
> ComputerClock *cc;
> gchar *s;
> int i;
> cc = gtk_object_get_user_data(GTK_OBJECT(cd->clockw));
> gtk_label_get(GTK_LABEL(cc->time), &s);
> strcpy (string, s);
> for(i=0; i<strlen(string); i++)
> if(string[i] == '\n')
> string[i] = ' ';
549a607
> cd->fuzzytime = gnome_config_get_int("clock/fuzzytime=0");
640a699
> cd->fuzzytime = cd->prop_fuzzytime;
716a776,784
> set_fuzzytime_cb(GtkWidget * w, gpointer data)
> {
> ClockData *cd = data;
>
> cd->prop_fuzzytime = GTK_TOGGLE_BUTTON(w)->active;
> gnome_property_box_changed (GNOME_PROPERTY_BOX (cd->props));
> }
>
> static void
753a822
> GtkWidget *fuzzytime;
872a942,955
> fuzzytime = gtk_check_button_new_with_label(_("Fuzzy clock"));
> gtk_box_pack_start_defaults(GTK_BOX(vbox), fuzzytime);
> gtk_widget_show(fuzzytime);
>
> if (cd->fuzzytime)
> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fuzzytime),
> TRUE);
> cd->prop_fuzzytime = cd->fuzzytime;
>
> gtk_signal_connect(GTK_OBJECT(fuzzytime),
> "toggled",
> (GtkSignalFunc) set_fuzzytime_cb,
> data);
>
880c963,964
<
---
>
> /* unix time */
895a980,982
> gtk_signal_connect(GTK_OBJECT(unixtime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> fuzzytime);
917a1005,1007
> gtk_signal_connect(GTK_OBJECT(internettime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> fuzzytime);
922a1013,1037
>
> /* fuzzy time */
> gtk_signal_connect(GTK_OBJECT(fuzzytime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> hour_frame);
> gtk_signal_connect(GTK_OBJECT(fuzzytime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> showdate);
> gtk_signal_connect(GTK_OBJECT(fuzzytime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> showtooltip);
> gtk_signal_connect(GTK_OBJECT(fuzzytime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> use_gmt_time);
> gtk_signal_connect(GTK_OBJECT(fuzzytime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> unixtime);
> gtk_signal_connect(GTK_OBJECT(fuzzytime), "toggled",
> (GtkSignalFunc) set_datasensitive_cb,
> internettime);
>
> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fuzzytime),
> cd->fuzzytime);
> cd->prop_fuzzytime = cd->fuzzytime;
> /* */
971a1087
> "Phil Borman <pb pborman freeserve co uk>",
982c1098
< about = gnome_about_new (_("Clock Applet"), "1.0",
---
> about = gnome_about_new (_("Clock Applet"), "1.01",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]