Author: juha
Date: 2007-11-24 23:03:43 +0000 (Sat, 24 Nov 2007)
New Revision: 26390

Modified:
   xfcalendar/trunk/src/appointment.c
   xfcalendar/trunk/src/appointment.h
   xfcalendar/trunk/src/ical-code.c
   xfcalendar/trunk/src/ical-code.h
   xfcalendar/trunk/src/reminder.c
   xfcalendar/trunk/src/reminder.h
Log:
1) fix alarms based on end time of event
2) fix core dump with libnotify type alarms
3) start persistent alarm enhancement


Modified: xfcalendar/trunk/src/appointment.c
===================================================================
--- xfcalendar/trunk/src/appointment.c  2007-11-21 16:21:16 UTC (rev 26389)
+++ xfcalendar/trunk/src/appointment.c  2007-11-24 23:03:43 UTC (rev 26390)
@@ -2056,12 +2056,26 @@
     gtk_container_add(GTK_CONTAINER(event), apptw->Alarm_when_cb);
     gtk_box_pack_start(GTK_BOX(apptw->Alarm_hbox)
             , event, FALSE, FALSE, 0);
+
     orage_table_add_row(apptw->TableAlarm
             , apptw->Alarm_label, apptw->Alarm_hbox
             , row = 0, (GTK_FILL), (GTK_FILL));
     gtk_tooltips_set_tip(apptw->Tooltips, event
             , _("Often you want to get alarm:\n 1) before Event start\n 2) 
before Todo end\n 3) after Todo start"), NULL);
 
+    /***** Persistent Alarm *****/
+    apptw->Per_hbox = gtk_hbox_new(FALSE, 6);
+    apptw->Per_checkbutton = 
+            gtk_check_button_new_with_mnemonic(_("Persistent alarm"));
+    gtk_tooltips_set_tip(apptw->Tooltips, apptw->Per_checkbutton
+            , _("Select this if you want Orage to remind you even if it has 
not been active when the alarm happened."), NULL);
+    gtk_box_pack_start(GTK_BOX(apptw->Per_hbox), apptw->Per_checkbutton
+            , FALSE, TRUE, 0);
+
+    orage_table_add_row(apptw->TableAlarm
+            , NULL, apptw->Per_hbox
+            , ++row, (GTK_FILL), (GTK_FILL));
+
     /***** Audio Alarm *****/
     apptw->Sound_label = gtk_label_new(_("Sound"));
 

Modified: xfcalendar/trunk/src/appointment.h
===================================================================
--- xfcalendar/trunk/src/appointment.h  2007-11-21 16:21:16 UTC (rev 26389)
+++ xfcalendar/trunk/src/appointment.h  2007-11-24 23:03:43 UTC (rev 26390)
@@ -136,6 +136,8 @@
     GtkWidget *Proc_hbox;
     GtkWidget *Proc_checkbutton;
     GtkWidget *Proc_entry;
+    GtkWidget *Per_hbox;
+    GtkWidget *Per_checkbutton;
 
     GtkWidget *Recur_notebook_page;
     GtkWidget *Recur_tab_label;

Modified: xfcalendar/trunk/src/ical-code.c
===================================================================
--- xfcalendar/trunk/src/ical-code.c    2007-11-21 16:21:16 UTC (rev 26389)
+++ xfcalendar/trunk/src/ical-code.c    2007-11-24 23:03:43 UTC (rev 26390)
@@ -2750,13 +2750,24 @@
     if (icaltime_is_date(per.stime)) { 
 /* HACK: convert to local time so that we can use time arithmetic
  * when counting alarm time. */
-        per.stime.is_date       = 0;
-        per.stime.is_utc        = cur_time.is_utc;
-        per.stime.is_daylight   = cur_time.is_daylight;
-        per.stime.zone          = cur_time.zone;
-        per.stime.hour          = 0;
-        per.stime.minute        = 0;
-        per.stime.second        = 0;
+        if (rel == ICAL_RELATED_START) {
+            per.stime.is_date       = 0;
+            per.stime.is_utc        = cur_time.is_utc;
+            per.stime.is_daylight   = cur_time.is_daylight;
+            per.stime.zone          = cur_time.zone;
+            per.stime.hour          = 0;
+            per.stime.minute        = 0;
+            per.stime.second        = 0;
+        }
+        else {
+            per.etime.is_date       = 0;
+            per.etime.is_utc        = cur_time.is_utc;
+            per.etime.is_daylight   = cur_time.is_daylight;
+            per.etime.zone          = cur_time.zone;
+            per.etime.hour          = 0;
+            per.etime.minute        = 0;
+            per.etime.second        = 0;
+        }
     }
     if (rel == ICAL_RELATED_END)
         alarm_time = icaltime_add(per.etime, trg.duration);
@@ -2796,7 +2807,7 @@
 #define P_N "process_alarm_data: "
     xfical_appt *appt;
     /*
-    icalproperty *p;
+    icalproperty *p;:
     enum icalproperty_action act;
     icalattach *attach = NULL;
     struct icaldurationtype duration;

Modified: xfcalendar/trunk/src/ical-code.h
===================================================================
--- xfcalendar/trunk/src/ical-code.h    2007-11-21 16:21:16 UTC (rev 26389)
+++ xfcalendar/trunk/src/ical-code.h    2007-11-24 23:03:43 UTC (rev 26390)
@@ -83,6 +83,7 @@
     gboolean alarm_before; /* TRUE = before FALSE = after */
         /* TRUE = related to start FALSE= related to end */
     gboolean alarm_related_start; 
+    gboolean alarm_persistent;  /* do this alarm even if orage has been down */
 
     gboolean sound_alarm;
     gchar *sound;

Modified: xfcalendar/trunk/src/reminder.c
===================================================================
--- xfcalendar/trunk/src/reminder.c     2007-11-21 16:21:16 UTC (rev 26389)
+++ xfcalendar/trunk/src/reminder.c     2007-11-24 23:03:43 UTC (rev 26390)
@@ -61,6 +61,9 @@
 
 static void alarm_free_memory(alarm_struct *alarm)
 {
+    /*
+    g_print("alarm_free_memory: start %d %d\n",  alarm->audio, 
alarm->display_notify);
+    */
     if (!alarm->display_orage && !alarm->display_notify)
         /* if both visuals are gone we can't stop audio anymore, so stop it 
          * now before it is too late */
@@ -76,9 +79,27 @@
             g_string_free(alarm->sound, TRUE);
         g_free(alarm->active_alarm);
         g_free(alarm);
+        /*
+    g_print("alarm_free_memory: freed %d %d\n",  alarm->audio, 
alarm->display_notify);
+    */
     }
 }
 
+static void notify_action_open(NotifyNotification *n, const char *action
+        , gpointer par)
+{
+    alarm_struct *alarm = (alarm_struct *)par;
+
+    /* 
+     * These two lines wuold keep notify window active and make it possible
+     * to start several times the appointment or start it and still be 
+     * able to control sound. Not sure if they should be there or not.
+    alarm->notify_refresh = TRUE;
+    create_notify_reminder(alarm);
+    */
+    create_appt_win("UPDATE", alarm->uid->str, NULL);
+}
+
 static gboolean sound_alarm(gpointer data)
 {
     alarm_struct *alarm = (alarm_struct *)data;
@@ -106,10 +127,12 @@
             gtk_widget_set_sensitive(GTK_WIDGET(stop), FALSE);
         }
 #ifdef HAVE_NOTIFY
-        if (alarm->display_notify) {
+        if (alarm->display_notify
+        &&  alarm->active_alarm->notify_stop_noise_action) {
             /* We need to remove the silence button from notify window.
              * This is not nice method, but it is not possible to access
              * the timeout so we just need to start it from all over */
+            alarm->notify_refresh = TRUE;
             notify_notification_close(alarm->active_alarm->active_notify, 
NULL);
             create_notify_reminder(alarm);
         }
@@ -142,26 +165,18 @@
 {
     alarm_struct *alarm = (alarm_struct *)par;
 
-    alarm->display_notify = FALSE; /* I am gone */
-    alarm_free_memory(alarm);
-}
-
-static void notify_action_open(NotifyNotification *n, const char *action
-        , gpointer par)
-{
-    alarm_struct *alarm = (alarm_struct *)par;
-
-    /* This causes core if notify is the last alarm, because libnotify
-     * closes the notification and hence raises notify_closed, which
-     * frees the memory. If we want to keep notification visible, we
-     * need to handle this somehow. For example let notify_closed know
-     * that there will be new notification and memory must not be freed.
-     * Or by allocating memory here again, which must not be done if there
-     * are more alarms active. Fro now just remove the line and let notify
-     * window go away like libnotify wants.
-    create_notify_reminder(alarm);
+    /*
+    g_print("notify_closed: start %d %d\n",  alarm->audio, 
alarm->display_notify);
     */
-    create_appt_win("UPDATE", alarm->uid->str, NULL);
+    if (alarm->notify_refresh) {
+        /* this is not really closing notify, but only a refresh, so
+         * we do not clean the memory now */
+        alarm->notify_refresh = FALSE;
+    }
+    else {
+        alarm->display_notify = FALSE; /* I am gone */
+        alarm_free_memory(alarm);
+    }
 }
 
 static void notify_action_silence(NotifyNotification *n, const char *action
@@ -169,8 +184,15 @@
 {
     alarm_struct *alarm = (alarm_struct *)par;
 
+    /*
+    g_print("notify_action_silence: start %d %d\n",  alarm->audio, 
alarm->display_notify);
+    */
+    alarm->notify_refresh = TRUE;
     alarm->repeat_cnt = 0;
     create_notify_reminder(alarm);
+    /*
+    g_print("notify_action_silence: end %d %d\n",  alarm->audio, 
alarm->display_notify);
+    */
 }
 #endif
 
@@ -206,6 +228,7 @@
         notify_notification_add_action(n, "stop", "Silence"
                 , (NotifyActionCallback)notify_action_silence
                 , alarm, NULL);
+        alarm->active_alarm->notify_stop_noise_action = TRUE;
     }
     (void)g_signal_connect(G_OBJECT(n), "closed"
            , G_CALLBACK(notify_closed), alarm);

Modified: xfcalendar/trunk/src/reminder.h
===================================================================
--- xfcalendar/trunk/src/reminder.h     2007-11-21 16:21:16 UTC (rev 26389)
+++ xfcalendar/trunk/src/reminder.h     2007-11-24 23:03:43 UTC (rev 26390)
@@ -30,6 +30,7 @@
     GtkWidget *stop_noise_reminder;
     gpointer active_notify; /* this is NotifyNotification, but it may not be
                                linked in, so need to be done like this */
+    gboolean notify_stop_noise_action;
 } active_alarm_struct;
 
 typedef struct _alarm_struct
@@ -38,9 +39,11 @@
     GString *uid;
     GString *title;
     GString *description;
+    gboolean persistent;
 
     gboolean display_orage;
     gboolean display_notify;
+    gboolean notify_refresh;
     gint     notify_timeout;
 
     gboolean audio;

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

Reply via email to