Author: juha
Date: 2008-02-07 21:49:38 +0000 (Thu, 07 Feb 2008)
New Revision: 26601

Modified:
   xfcalendar/trunk/src/appointment.c
   xfcalendar/trunk/src/appointment.h
   xfcalendar/trunk/src/day-view.c
   xfcalendar/trunk/src/event-list.c
   xfcalendar/trunk/src/parameters.c
Log:
Refreshing day list similarly to event list 


Modified: xfcalendar/trunk/src/appointment.c
===================================================================
--- xfcalendar/trunk/src/appointment.c  2008-02-07 20:51:01 UTC (rev 26600)
+++ xfcalendar/trunk/src/appointment.c  2008-02-07 21:49:38 UTC (rev 26601)
@@ -49,6 +49,7 @@
 #include "mainbox.h"
 #include "ical-code.h"
 #include "event-list.h"
+#include "day-view.h"
 #include "appointment.h"
 #include "parameters.h"
 
@@ -674,6 +675,10 @@
     if (apptw->el)
         ((el_win *)apptw->el)->apptw_list = 
                 g_list_remove(((el_win *)apptw->el)->apptw_list, apptw);
+    /* remove myself from day list appointment monitoring list */
+    else if (apptw->dw)
+        ((day_win *)apptw->dw)->apptw_list = 
+                g_list_remove(((day_win *)apptw->dw)->apptw_list, apptw);
     gtk_widget_destroy(apptw->Window);
     gtk_object_destroy(GTK_OBJECT(apptw->Tooltips));
     g_free(apptw->xf_uid);
@@ -1016,6 +1021,15 @@
     appWindow_check_and_close((appt_win *)user_data);
 }
 
+static void refresh_dependent_data(appt_win *apptw)
+{
+    if (apptw->el != NULL)
+        refresh_el_win((el_win *)apptw->el);
+    if (apptw->dw != NULL)
+        refresh_day_win((day_win *)apptw->dw);
+    orage_mark_appointments();
+}
+
 static gboolean save_xfical_from_appt_win(appt_win *apptw)
 {
     gboolean ok = FALSE;
@@ -1048,9 +1062,7 @@
         if (ok) {
             apptw->appointment_new = FALSE;
             mark_appointment_unchanged(apptw);
-            if (apptw->el != NULL)
-                refresh_el_win((el_win *)apptw->el);
-            orage_mark_appointments();
+            refresh_dependent_data(apptw);
         }
     }
     return(ok);
@@ -1109,10 +1121,7 @@
             xfical_file_close(TRUE);
         }
 
-        if (apptw->el != NULL)
-            refresh_el_win((el_win *)apptw->el);
-        orage_mark_appointments();
-
+        refresh_dependent_data(apptw);
         app_free_memory(apptw);
     }
 }
@@ -2353,6 +2362,7 @@
     apptw->par = NULL;
     apptw->appt = NULL;
     apptw->el = NULL;
+    apptw->dw = NULL;
     apptw->appointment_changed = FALSE;
     apptw->Tooltips = gtk_tooltips_new();
     apptw->accel_group = gtk_accel_group_new();

Modified: xfcalendar/trunk/src/appointment.h
===================================================================
--- xfcalendar/trunk/src/appointment.h  2008-02-07 20:51:01 UTC (rev 26600)
+++ xfcalendar/trunk/src/appointment.h  2008-02-07 21:49:38 UTC (rev 26601)
@@ -173,6 +173,7 @@
     gchar *xf_uid;
     gchar *par;
     void  *el;          /* used to refresh calling event list */
+    void  *dw;          /* used to refresh calling day list */
     gboolean appointment_add;       /* are we adding app */
     gboolean appointment_changed;   /* has this app been modified now */
     gboolean appointment_new;       /* is this new = no uid yet */

Modified: xfcalendar/trunk/src/day-view.c
===================================================================
--- xfcalendar/trunk/src/day-view.c     2008-02-07 20:51:01 UTC (rev 26600)
+++ xfcalendar/trunk/src/day-view.c     2008-02-07 21:49:38 UTC (rev 26601)
@@ -40,8 +40,18 @@
 #include "event-list.h"
 #include "appointment.h"
 
+static void do_appt_win(char *mode, char *uid, day_win *dw)
+{
+    appt_win *apptw;
 
-static void refresh_day_view_table(day_win *dw);
+    apptw = create_appt_win(mode, uid);
+    if (apptw) {
+        /* we started this, so keep track of it */
+        dw->apptw_list = g_list_prepend(dw->apptw_list, apptw);
+        /* inform the appointment that we are interested in it */
+        apptw->dw = dw;
+    }
+};
 
 static void set_scroll_position(day_win *dw)
 {
@@ -114,6 +124,23 @@
 
 static void close_window(day_win *dw)
 {
+    appt_win *apptw;
+    GList *apptw_list;
+
+    /* need to clean the appointment list and inform all appointments that
+     * we are not interested anymore (= should not get updated) */
+    apptw_list = dw->apptw_list;
+    for (apptw_list = g_list_first(apptw_list);
+         apptw_list != NULL;
+         apptw_list = g_list_next(apptw_list)) {
+        apptw = (appt_win *)apptw_list->data;
+        if (apptw) /* appointment window is still alive */
+            apptw->dw = NULL; /* not interested anymore */
+        else
+            orage_message(110, "close_window: not null appt window");
+    }
+    g_list_free(dw->apptw_list);
+
     gtk_widget_destroy(dw->Window);
     gtk_object_destroy(GTK_OBJECT(dw->Tooltips));
     g_free(dw);
@@ -144,7 +171,7 @@
     s_date = (char *)gtk_button_get_label(GTK_BUTTON(dw->StartDate_button));
     strcpy(a_day, orage_i18_date_to_icaltime(s_date));
 
-    create_appt_win("NEW", a_day);
+    do_appt_win("NEW", a_day, dw);
 }
 
 static void on_File_newApp_activate_cb(GtkMenuItem *mi, gpointer user_data)
@@ -159,12 +186,12 @@
 
 static void on_View_refresh_activate_cb(GtkMenuItem *mi, gpointer user_data)
 {
-    refresh_day_view_table((day_win *)user_data);
+    refresh_day_win((day_win *)user_data);
 }
 
 static void on_Refresh_clicked(GtkButton *b, gpointer user_data)
 {
-    refresh_day_view_table((day_win *)user_data);
+    refresh_day_win((day_win *)user_data);
 }
 
 static void changeSelectedDate(day_win *dw, gint day)
@@ -176,14 +203,14 @@
     orage_move_day(&tm_date, day);
     gtk_button_set_label(GTK_BUTTON(dw->StartDate_button)
             , orage_tm_date_to_i18_date(&tm_date));
-    refresh_day_view_table(dw);
+    refresh_day_win(dw);
 }
 
 static void go_to_today(day_win *dw)
 {
     gtk_button_set_label(GTK_BUTTON(dw->StartDate_button)
             , orage_localdate_i18());
-    refresh_day_view_table(dw);
+    refresh_day_win(dw);
 }
 
 static void on_Today_clicked(GtkButton *b, gpointer user_data)
@@ -334,7 +361,7 @@
      * to show only the last one, which is visible */
     day_cnt_n = 
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dw->day_spin));
     if (day_cnt != day_cnt_n) { /* need really do it */
-        refresh_day_view_table(dw);
+        refresh_day_win(dw);
         day_cnt = day_cnt_n;
     }
     dw->upd_timer = 0;
@@ -345,7 +372,7 @@
 {
     day_win *dw = (day_win *)user_data;
 
-    /* refresh_day_view_table is rather heavy (=slow), so doing it here 
+    /* refresh_day_win is rather heavy (=slow), so doing it here 
      * is not a good idea. We can't keep up with repeated quick presses 
      * if we do the whole thing here. So let's throw it to background 
      * and do it later. */
@@ -360,7 +387,7 @@
     day_win *dw = (day_win *)user_data;
 
     if (orage_date_button_clicked(button, dw->Window))
-        refresh_day_view_table(dw);
+        refresh_day_win(dw);
 }
 
 static void header_button_clicked_cb(GtkWidget *button, gpointer *user_data)
@@ -374,11 +401,12 @@
 static void on_button_press_event_cb(GtkWidget *widget
         , GdkEventButton *event, gpointer *user_data)
 {
+    day_win *dw = (day_win *)user_data;
     gchar *uid;
 
     if (event->type==GDK_2BUTTON_PRESS) {
         uid = g_object_get_data(G_OBJECT(widget), "UID");
-        create_appt_win("UPDATE", uid);
+        do_appt_win("UPDATE", uid, dw);
     }
 }
 
@@ -833,7 +861,7 @@
     fill_days(dw, days);
 }
 
-static void refresh_day_view_table(day_win *dw)
+void refresh_day_win(day_win *dw)
 {
     get_scroll_position(dw);
     gtk_widget_destroy(dw->scroll_win_h);

Modified: xfcalendar/trunk/src/event-list.c
===================================================================
--- xfcalendar/trunk/src/event-list.c   2008-02-07 20:51:01 UTC (rev 26600)
+++ xfcalendar/trunk/src/event-list.c   2008-02-07 21:49:38 UTC (rev 26601)
@@ -712,7 +712,7 @@
             , &g_par.el_size_x, &g_par.el_size_y);
     write_parameters();
 
-    /* need to clean the apointment list and inform all appointments that
+    /* need to clean the appointment list and inform all appointments that
      * we are not interested anymore (= should not get updated) */
     apptw_list = el->apptw_list;
     for (apptw_list = g_list_first(apptw_list);
@@ -722,7 +722,7 @@
         if (apptw) /* appointment window is still alive */
             apptw->el = NULL; /* not interested anymore */
         else
-            orage_message(10, "close_window: not null appt window");
+            orage_message(110, "close_window: not null appt window");
     }
     g_list_free(el->apptw_list);
 

Modified: xfcalendar/trunk/src/parameters.c
===================================================================
--- xfcalendar/trunk/src/parameters.c   2008-02-07 20:51:01 UTC (rev 26600)
+++ xfcalendar/trunk/src/parameters.c   2008-02-07 21:49:38 UTC (rev 26601)
@@ -826,6 +826,7 @@
     xfce_rc_write_int_entry(rc, "Ical 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 */
     for (i = 0; i < g_par.foreign_count;  i++) {
         g_sprintf(f_par, "Foreign file %02d name", i);
         xfce_rc_write_entry(rc, f_par, g_par.foreign_data[i].file);

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

Reply via email to