Author: juha
Date: 2008-03-04 17:01:09 +0000 (Tue, 04 Mar 2008)
New Revision: 26662

Modified:
   xfcalendar/trunk/configure.in.in
   xfcalendar/trunk/src/mainbox.c
   xfcalendar/trunk/src/parameters.c
Log:
1) removed libical week start day setting and replaced that by reading
   first week day from locale. There is still undocumented parameter
   in case locael setting is wrong. (Bug 3898)
2) Fixed Bug 3913 - "Phantom" marks in calendar when switching month
version 4.5.13.3



Modified: xfcalendar/trunk/configure.in.in
===================================================================
--- xfcalendar/trunk/configure.in.in    2008-03-04 08:46:57 UTC (rev 26661)
+++ xfcalendar/trunk/configure.in.in    2008-03-04 17:01:09 UTC (rev 26662)
@@ -9,7 +9,7 @@
 dnl
 
 dnl Version information
-m4_define([orage_version], [4.5.13.2-svn])
+m4_define([orage_version], [4.5.13.3-svn])
 
 m4_define([gtk_minimum_version], [2.6.0])
 m4_define([xfce_minimum_version], [4.4.0])

Modified: xfcalendar/trunk/src/mainbox.c
===================================================================
--- xfcalendar/trunk/src/mainbox.c      2008-03-04 08:46:57 UTC (rev 26661)
+++ xfcalendar/trunk/src/mainbox.c      2008-03-04 17:01:09 UTC (rev 26662)
@@ -234,21 +234,11 @@
 {
 #undef P_N
 #define P_N "upd_calendar: "
-    static guint year=-1, month=-1;
-    guint year_n, month_n, day_n;
 
 #ifdef ORAGE_DEBUG
     orage_message(-100, P_N);
 #endif
-    /* we only need to do this if it is really a new month. We may get
-     * many of these while calender is changing months and it is enough
-     * to show only the last one, which is visible */
-    gtk_calendar_get_date(calendar, &year_n, &month_n, &day_n);
-    if (month != month_n || year != year_n) { /* need really do it */
-        orage_mark_appointments();
-        year = year_n;
-        month = month_n;
-    }
+    orage_mark_appointments();
     return(FALSE); /* we do this only once */
 }
 
@@ -256,14 +246,22 @@
 {
 #undef P_N
 #define P_N "mCalendar_month_changed_cb: "
+    static guint timer=0;
 #ifdef ORAGE_DEBUG
     orage_message(-100, P_N);
 #endif
     /* orage_mark_appointments is rather heavy (=slow), so doing
      * it here is not a good idea. We can't keep up with the autorepeat
-     * speed if we do the whole thing here. bug 2080 proofs it. so let's
-     * throw it to background and do it later */
-    g_timeout_add(500, (GtkFunction)upd_calendar, calendar);
+     * speed if we do the whole thing here. Bug 2080 prooves it. So let's
+     * throw it to background and do it later. We stop previously 
+     * running updates since this new one will overwrite them anyway.
+     * Let's clear still the view to fix bug 3913 (only needed 
+     * if there are changes in the calendar) */
+    if (timer)
+        g_source_remove(timer);
+    if (calendar->num_marked_dates) /* undocumented, internal field; ugly */
+        gtk_calendar_clear_marks(calendar);
+    timer = g_timeout_add(500, (GtkFunction)upd_calendar, calendar);
 }
 
 static void build_menu(void)

Modified: xfcalendar/trunk/src/parameters.c
===================================================================
--- xfcalendar/trunk/src/parameters.c   2008-03-04 08:46:57 UTC (rev 26661)
+++ xfcalendar/trunk/src/parameters.c   2008-03-04 17:01:09 UTC (rev 26662)
@@ -28,6 +28,10 @@
 #include <string.h>
 #endif
 
+#include <stdio.h>
+#include <locale.h>
+#include <langinfo.h>
+
 #include <glib.h>
 #include <glib/gprintf.h>
 #include <gtk/gtk.h>
@@ -97,9 +101,13 @@
     /* select_always_today */
     GtkWidget *always_today_frame;
     GtkWidget *always_today_checkbutton;
-    /* ical week start day (0 = Monday, 1 = Tuesday,... 6 = Sunday) */
-    GtkWidget *ical_weekstartday_frame;
-    GtkWidget *ical_weekstartday_combobox;
+
+/* code removed. relying in get_first_weekday_from_locale now
+/ * ical week start day (0 = Monday, 1 = Tuesday,... 6 = Sunday) * /
+GtkWidget *ical_weekstartday_frame;
+GtkWidget *ical_weekstartday_combobox;
+*/
+
     /* icon size */
     GtkWidget *icon_size_frame;
     GtkWidget *icon_size_x_spin;
@@ -116,7 +124,31 @@
     GtkWidget *dialog_action_area1;
 } Itf;
 
+/* Return the first day of the week, where 0=monday, 6=sunday.
+ *     Borrowed from GTK+:s Calendar Widget, but modified
+ *     to return 0..6 mon..sun, which is what libical uses */
+int get_first_weekday_from_locale()
+{
+    union { unsigned int word; char *string; } langinfo;
+    int week_1stday = 0;
+    int first_weekday = 1;
+    unsigned int week_origin;
 
+    setlocale(LC_TIME, "");
+    langinfo.string = nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
+    first_weekday = langinfo.string[0];
+    langinfo.string = nl_langinfo(_NL_TIME_WEEK_1STDAY);
+    week_origin = langinfo.word;
+    if (week_origin == 19971130) /* Sunday */
+        week_1stday = 0;
+    else if (week_origin == 19971201) /* Monday */
+        week_1stday = 1;
+    else
+        orage_message(150, "get_first_weekday: unknown value of 
_NL_TIME_WEEK_1STDAY.");
+
+    return((week_1stday + first_weekday - 2 + 7) % 7);
+}
+
 static void dialog_response(GtkWidget *dialog, gint response_id
         , gpointer user_data)
 {
@@ -382,6 +414,7 @@
             GTK_TOGGLE_BUTTON(itf->always_today_checkbutton));
 }
 
+/* code removed. relying in get_first_weekday_from_locale now
 static void ical_weekstartday_changed(GtkWidget *dialog, gpointer user_data)
 {
     Itf *itf = (Itf *)user_data;
@@ -389,6 +422,7 @@
     g_par.ical_weekstartday = gtk_combo_box_get_active(
             GTK_COMBO_BOX(itf->ical_weekstartday_combobox));
 }
+*/
 
 static void set_icon_size()
 {
@@ -654,9 +688,11 @@
 static void create_parameter_dialog_extra_setup_tab(Itf *dialog)
 {
     GtkWidget *hbox, *vbox, *label, *event;
+    /* code removed. relying in get_first_weekday_from_locale now
     gchar *weekday_array[7] = {
             _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday")
           , _("Friday"), _("Saturday"), _("Sunday")};
+     */
 
     dialog->extra_vbox = gtk_vbox_new(FALSE, 0);
     dialog->extra_tab = 
@@ -684,7 +720,8 @@
     g_signal_connect(G_OBJECT(dialog->always_today_checkbutton), "toggled"
             , G_CALLBACK(always_today_changed), dialog);
 
-    /***** ical week start day (0 = Monday, 1 = Tuesday,... 6 = Sunday) *****/
+    /* code removed. relying in get_first_weekday_from_locale now
+    / ***** ical week start day (0 = Monday, 1 = Tuesday,... 6 = Sunday) ***** 
/
     hbox = gtk_hbox_new(FALSE, 0);
     dialog->ical_weekstartday_frame = xfce_create_framebox_with_content(
             _("Ical week start day"), hbox);
@@ -693,7 +730,7 @@
 
     dialog->ical_weekstartday_combobox = orage_create_combo_box_with_content(
             weekday_array, 7);
-    event =  gtk_event_box_new(); /* only needed for tooltips */
+    event =  gtk_event_box_new(); / * only needed for tooltips * /
     gtk_container_add(GTK_CONTAINER(event), 
dialog->ical_weekstartday_combobox);
     gtk_box_pack_start(GTK_BOX(hbox)
             , event, FALSE, FALSE, 5);
@@ -704,6 +741,7 @@
             , NULL);
     g_signal_connect(G_OBJECT(dialog->ical_weekstartday_combobox), "changed"
             , G_CALLBACK(ical_weekstartday_changed), dialog);
+    */
 
     /***** tray icon size  (0 = use static icon) *****/
     vbox = gtk_vbox_new(FALSE, 0);
@@ -870,7 +908,10 @@
     xfce_rc_write_bool_entry(rc, "Set ontop", g_par.set_ontop);
     xfce_rc_write_int_entry(rc, "Dynamic icon X", g_par.icon_size_x);
     xfce_rc_write_int_entry(rc, "Dynamic icon Y", g_par.icon_size_y);
-    xfce_rc_write_int_entry(rc, "Ical week start day", 
g_par.ical_weekstartday);
+    /* we write this with X so that we do not read it back unless
+     * it is manually changed. It should need changes really seldom. */
+    xfce_rc_write_int_entry(rc, "XIcal week start day"
+            , g_par.ical_weekstartday);
     xfce_rc_write_bool_entry(rc, "Show days", g_par.show_days);
     xfce_rc_write_int_entry(rc, "Foreign file count", g_par.foreign_count);
     /* add what we have and remove the rest */
@@ -948,8 +989,9 @@
     g_par.set_ontop = xfce_rc_read_bool_entry(rc, "Set ontop", FALSE);
     g_par.icon_size_x = xfce_rc_read_int_entry(rc, "Dynamic icon X", 42);
     g_par.icon_size_y = xfce_rc_read_int_entry(rc, "Dynamic icon Y", 32);
-    g_par.ical_weekstartday = 
-            xfce_rc_read_int_entry(rc, "Ical week start day", 0); /* monday */
+    /* 0 = monday, ..., 6 = sunday */
+    g_par.ical_weekstartday = xfce_rc_read_int_entry(rc, "Ical week start day"
+            , get_first_weekday_from_locale());
     g_par.show_days = xfce_rc_read_bool_entry(rc, "Show days", FALSE);
     g_par.foreign_count = 
             xfce_rc_read_int_entry(rc, "Foreign file count", 0);

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to