From: <mgo...@us...> - 2016-11-13 01:03:08
|
Revision: 1103 http://sourceforge.net/p/osmo-pim/code/1103 Author: mgordienko Date: 2016-11-13 01:03:06 +0000 (Sun, 13 Nov 2016) Log Message: ----------- Clean up the notification text preparation Modified Paths: -------------- trunk/src/check_events.c Modified: trunk/src/check_events.c =================================================================== --- trunk/src/check_events.c 2016-11-13 01:03:00 UTC (rev 1102) +++ trunk/src/check_events.c 2016-11-13 01:03:06 UTC (rev 1103) @@ -397,97 +397,91 @@ static TASK_NTF * create_task_notification(TASK_ITEM *item, GUI *appGUI) { TASK_NTF * notification = g_malloc(sizeof (TASK_NTF)); - gchar *datestr, *text, *textdesc = NULL; + gchar *date, *date_formatted; - datestr = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); - text = g_strdup_printf("<i>%s</i>", datestr); - g_free(datestr); - - textdesc = NULL; - if (item->desc != NULL && strlen(item->desc)) - textdesc = g_strdup_printf("%s\n%.100s", text, item->desc); - notification->id = item->id; notification->type = NOTIFY_ALARM; notification->time = -1; notification->date = 0; - if (textdesc != NULL) { - notification->notify = create_notify_notification(item, item->summary, textdesc, appGUI); + date = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); + date_formatted = g_strdup_printf("<i>%s</i>", date); + + if (item->desc != NULL && strlen(item->desc)) { + gchar *text = g_strdup_printf("%s\n%.100s", date_formatted, item->desc); + notification->notify = create_notify_notification(item, item->summary, text, appGUI); + g_free(text); } else { - gchar *datestr, *text; - datestr = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); - text = g_strdup_printf("<i>%s</i>", datestr); - g_free(datestr); - notification->notify = create_notify_notification(item, item->summary, text, appGUI); + notification->notify = create_notify_notification(item, item->summary, date_formatted, appGUI); } - g_free(textdesc); - g_free(text); + g_free(date); + g_free(date_formatted); return notification; } static TASK_NTF * create_task_warning(TASK_ITEM *item, GUI *appGUI) { TASK_NTF * notification = g_malloc(sizeof (TASK_NTF)); - gchar *datestr, *text, *textdesc = NULL; - datestr = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); - text = g_strdup_printf("<b>%s</b>\n<i>%s</i>", item->summary, datestr); - g_free(datestr); + gchar *date, *summary; - if (item->desc != NULL && strlen(item->desc)) - textdesc = g_strdup_printf("%s\n%.100s", text, item->desc); - - notification->id = item->id; notification->type = NOTIFY_WARNING; notification->time = -1; notification->date = 0; - if (textdesc != NULL) + + date = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); + summary = g_strdup_printf("<b>%s</b>\n<i>%s</i>", item->summary, date); + + if (item->desc != NULL && strlen(item->desc)) { + gchar *text = g_strdup_printf("%s\n%.100s", summary, item->desc); #ifdef HAVE_LIBNOTIFY7 - notification->notify = notify_notification_new(_("Alarm warning!"), textdesc, "dialog-information"); + notification->notify = notify_notification_new(_("Alarm warning!"), text, "dialog-information"); #else notification->notify = notify_notification_new(_("Alarm warning!"), textdesc, "dialog-information", NULL); #endif /* HAVE_LIBNOTIFY7 */ - else + g_free(text); + } else { #ifdef HAVE_LIBNOTIFY7 - notification->notify = notify_notification_new(_("Alarm warning!"), text, "dialog-information"); + notification->notify = notify_notification_new(_("Alarm warning!"), summary, "dialog-information"); #else notification->notify = notify_notification_new(_("Alarm warning!"), text, "dialog-information", NULL); #endif /* HAVE_LIBNOTIFY7 */ + } notify_notification_set_timeout(notification->notify, NOTIFY_EXPIRES_NEVER); notify_notification_set_urgency(notification->notify, NOTIFY_URGENCY_NORMAL); if (tsk_get_category_state(item->category, STATE_TASKS, appGUI) == TRUE) notify_notification_add_action(notification->notify, "show_task", _("Show task"), (NotifyActionCallback) tsk_show_task_cb, appGUI, NULL); + + g_free(date); + g_free(summary); return notification; } static void update_postponed_notification(TASK_NTF *a, TASK_ITEM *item, GUI *appGUI) { - gchar *datestr, *datestri, *title, *text = NULL; + gchar *date, *date_formatted, *title; a->date = 0; a->time = -1; - datestr = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); - datestri = g_strdup_printf("<i>%s</i>", datestr); - g_free(datestr); - - if (item->desc != NULL && strlen(item->desc)) - text = g_strdup_printf("%s\n%.100s", datestri, item->desc); - + date = utl_date_time_print_default(item->due_date_julian, item->due_time, FALSE); + date_formatted = g_strdup_printf("<i>%s</i>", date); title = g_strdup_printf("%s (%s)", item->summary, _("postponed")); - if (text != NULL) + if (item->desc != NULL && strlen(item->desc)) { + gchar *text = g_strdup_printf("%s\n%.100s", date_formatted, item->desc); a->notify = create_notify_notification(item, title, text, appGUI); - else - a->notify = create_notify_notification(item, title, datestri, appGUI); + g_free(text); + } else { + a->notify = create_notify_notification(item, title, date_formatted, appGUI); + } g_free(title); - g_free(text); - g_free(datestri); + g_free(date); + g_free(date_formatted); } #endif /* HAVE_LIBNOTIFY */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |