Author: juha Date: 2007-12-13 23:24:18 +0000 (Thu, 13 Dec 2007) New Revision: 26472
Modified: xfcalendar/trunk/src/about-xfcalendar.c xfcalendar/trunk/src/appointment.c xfcalendar/trunk/src/event-list.c xfcalendar/trunk/src/functions.c xfcalendar/trunk/src/functions.h xfcalendar/trunk/src/ical-code.c xfcalendar/trunk/src/interface.c xfcalendar/trunk/src/main.c xfcalendar/trunk/src/mainbox.c xfcalendar/trunk/src/parameters.c xfcalendar/trunk/src/reminder.c xfcalendar/trunk/src/reminder.h xfcalendar/trunk/src/tray_icon.c Log: fixing few core dumps and tuning memory leaks and cpu usage. Also making initial startup faster. Cleaning and formatting base code: event_list, appointment, main window Modified: xfcalendar/trunk/src/about-xfcalendar.c =================================================================== --- xfcalendar/trunk/src/about-xfcalendar.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/about-xfcalendar.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -42,7 +42,6 @@ , _("Manage your time with Xfce4") , XFCE_COPYRIGHT_TEXT("2003-2007", " Juha Kautto") , XFCE_LICENSE_GPL); - /* orage_logo = xfce_themed_icon_load("xfcalendar", 48); */ orage_logo = orage_create_icon(xfcal, FALSE, 48, 48); xfce_about_info_set_homepage(about, "http://www.xfce.org"); Modified: xfcalendar/trunk/src/appointment.c =================================================================== --- xfcalendar/trunk/src/appointment.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/appointment.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -43,8 +43,6 @@ #include <gdk/gdk.h> #include <glib/gprintf.h> -#include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/netk-trayicon.h> #include <libxfcegui4/libxfcegui4.h> #include "functions.h" @@ -54,8 +52,6 @@ #include "appointment.h" #include "parameters.h" -#define AVAILABILITY_ARRAY_DIM 2 -#define RECUR_ARRAY_DIM 5 #define BORDER_SIZE 20 #define FILETYPE_SIZE 38 @@ -67,16 +63,6 @@ */ -static void combo_box_append_array(GtkWidget *combo_box, char *text[], int size) -{ - register int i; - - for (i = 0; i < size; i++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box) - , (const gchar *)text[i]); - } -} - static GtkWidget *datetime_hbox_new(GtkWidget *date_button , GtkWidget *spin_hh, GtkWidget *spin_mm , GtkWidget *timezone_button) @@ -106,7 +92,7 @@ gtk_box_pack_start(GTK_BOX(hbox), timezone_button, TRUE, TRUE, 0); - return hbox; + return(hbox); } static GtkWidget *period_hbox_new(gboolean head_space, gboolean tail_space @@ -261,7 +247,7 @@ { gint freq, i; - freq = gtk_combo_box_get_active((GtkComboBox *)apptw->Recur_freq_cb); + freq = gtk_combo_box_get_active(GTK_COMBO_BOX(apptw->Recur_freq_cb)); if (freq == XFICAL_FREQ_NONE) { gtk_widget_set_sensitive(apptw->Recur_limit_rb, FALSE); gtk_widget_set_sensitive(apptw->Recur_count_rb, FALSE); @@ -516,38 +502,38 @@ static void app_recur_checkbutton_clicked_cb(GtkCheckButton *checkbutton , gpointer user_data) { - mark_appointment_changed((appt_win *)user_data); set_repeat_sensitivity((appt_win *)user_data); + mark_appointment_changed((appt_win *)user_data); } static void app_recur_feature_checkbutton_clicked_cb(GtkCheckButton *cb , gpointer user_data) { - mark_appointment_changed((appt_win *)user_data); recur_hide_show((appt_win *)user_data); + mark_appointment_changed((appt_win *)user_data); } static void app_sound_checkbutton_clicked_cb(GtkCheckButton *cb , gpointer user_data) { - mark_appointment_changed((appt_win *)user_data); set_sound_sensitivity((appt_win *)user_data); + mark_appointment_changed((appt_win *)user_data); } #ifdef HAVE_NOTIFY static void app_notify_checkbutton_clicked_cb(GtkCheckButton *cb , gpointer user_data) { - mark_appointment_changed((appt_win *)user_data); set_notify_sensitivity((appt_win *)user_data); + mark_appointment_changed((appt_win *)user_data); } #endif static void app_proc_checkbutton_clicked_cb(GtkCheckButton *cb , gpointer user_data) { - mark_appointment_changed((appt_win *)user_data); set_proc_sensitivity((appt_win *)user_data); + mark_appointment_changed((appt_win *)user_data); } static void app_checkbutton_clicked_cb(GtkCheckButton *cb, gpointer user_data) @@ -611,8 +597,7 @@ mark_appointment_changed((appt_win *)user_data); } -static void on_app_spin_button_changed_cb(GtkSpinButton *sb - , gpointer user_data) +static void on_app_spin_button_changed_cb(GtkSpinButton *sb, gpointer user_data) { mark_appointment_changed((appt_win *)user_data); } @@ -698,40 +683,29 @@ gint result; if (apptw->appointment_changed == TRUE) { - result = xfce_message_dialog(GTK_WINDOW(apptw->Window), - _("Warning"), - GTK_STOCK_DIALOG_WARNING, - _("The appointment information has been modified."), - _("Do you want to continue?"), - GTK_STOCK_YES, GTK_RESPONSE_ACCEPT, - GTK_STOCK_NO, GTK_RESPONSE_CANCEL, - NULL); + result = xfce_message_dialog(GTK_WINDOW(apptw->Window) + , _("Warning") + , GTK_STOCK_DIALOG_WARNING + , _("The appointment information has been modified.") + , _("Do you want to continue?") + , GTK_STOCK_YES, GTK_RESPONSE_ACCEPT + , GTK_STOCK_NO, GTK_RESPONSE_CANCEL + , NULL); if (result == GTK_RESPONSE_ACCEPT) { app_free_memory(apptw); - /* - gtk_widget_destroy(apptw->Window); - gtk_object_destroy(GTK_OBJECT(apptw->Tooltips)); - g_free(apptw); - */ } } else { app_free_memory(apptw); - /* - gtk_widget_destroy(apptw->Window); - gtk_object_destroy(GTK_OBJECT(apptw->Tooltips)); - xfical_appt_free(apptw->appt); - g_free(apptw); - */ } - return TRUE; + return(TRUE); } static gboolean on_appWindow_delete_event_cb(GtkWidget *widget, GdkEvent *event , gpointer user_data) { - return appWindow_check_and_close((appt_win *)user_data); + return(appWindow_check_and_close((appt_win *)user_data)); } static gboolean orage_validate_datetime(appt_win *apptw, xfical_appt *appt) @@ -742,14 +716,13 @@ if (appt->type == XFICAL_TYPE_JOURNAL) return(TRUE); if (xfical_compare_times(appt) > 0) { - result = xfce_message_dialog(GTK_WINDOW(apptw->Window), - _("Warning"), - GTK_STOCK_DIALOG_WARNING, - _("The end of this appointment is earlier than the beginning."), - NULL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - NULL); + result = xfce_message_dialog(GTK_WINDOW(apptw->Window) + , _("Error") + , GTK_STOCK_DIALOG_ERROR + , _("The end of this appointment is earlier than the beginning.") + , NULL + , GTK_STOCK_OK, GTK_RESPONSE_ACCEPT + , NULL); return(FALSE); } else { @@ -758,8 +731,7 @@ } /* - * fill_appt_from_apptw - * This function fills an appointment with the contents of an appointment + * Function fills an appointment with the contents of an appointment * window */ static gboolean fill_appt_from_apptw(xfical_appt *appt, appt_win *apptw) @@ -880,9 +852,6 @@ /* notes */ gtk_text_buffer_get_bounds(apptw->Note_buffer, &start, &end); - /* - gtk_text_view_get_buffer((GtkTextView *)apptw->Note_textview) - */ appt->note = gtk_text_iter_get_text(&start, &end); /*********** ALARM TAB ***********/ @@ -969,14 +938,15 @@ #endif /* Do we use procedure alarm */ - appt->procedure_alarm = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(apptw->Proc_checkbutton)); + appt->procedure_alarm = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(apptw->Proc_checkbutton)); /* The actual command. * Note that we need to split this into cmd and the parameters * since that is how libical stores it */ appt->procedure_cmd = NULL; appt->procedure_params = NULL; - tmp = (char*)gtk_entry_get_text(GTK_ENTRY(apptw->Proc_entry)); + tmp = (char *)gtk_entry_get_text(GTK_ENTRY(apptw->Proc_entry)); j = strlen(tmp); for (i = 0; i < j && g_ascii_isspace(tmp[i]); i++) ; /* skip blanks */ @@ -1074,7 +1044,7 @@ if (ok) { apptw->appointment_new = FALSE; mark_appointment_unchanged(apptw); - /* FIXME: This fails if event_list window has been removed. + /* FIXME: Removed since it fails if event_list window has been removed. * We should check that it really still exists, before calling this. if (apptw->el != NULL) refresh_el_win((el_win *)apptw->el); @@ -1082,7 +1052,7 @@ orage_mark_appointments(); } } - return (ok); + return(ok); } static void on_appFileSave_menu_activate_cb(GtkMenuItem *mi, gpointer user_data) @@ -1099,12 +1069,6 @@ { if (save_xfical_from_appt_win(apptw)) { app_free_memory(apptw); - /* - gtk_widget_destroy(apptw->Window); - gtk_object_destroy(GTK_OBJECT(apptw->Tooltips)); - xfical_appt_free(apptw->appt); - g_free(apptw); - */ } } @@ -1152,14 +1116,6 @@ orage_mark_appointments(); app_free_memory(apptw); - /* - gtk_widget_destroy(apptw->Window); - gtk_object_destroy(GTK_OBJECT(apptw->Tooltips)); - g_free(apptw->xf_uid); - g_free(apptw->par); - xfical_appt_free(apptw->appt); - g_free(apptw); - */ } } @@ -1171,7 +1127,7 @@ static void on_appFileDelete_menu_activate_cb(GtkMenuItem *mi , gpointer user_data) { - delete_xfical_from_appt_win((appt_win *) user_data); + delete_xfical_from_appt_win((appt_win *)user_data); } static void duplicate_xfical_from_appt_win(appt_win *apptw) @@ -1205,7 +1161,8 @@ } } -static void on_appFileRevert_menu_activate_cb(GtkMenuItem *mi, gpointer user_data) +static void on_appFileRevert_menu_activate_cb(GtkMenuItem *mi + , gpointer user_data) { revert_xfical_to_last_saved((appt_win *)user_data); } @@ -1333,12 +1290,10 @@ completeddate_to_display = orage_tm_date_to_i18_date(&tm_date); gtk_button_set_label(GTK_BUTTON(apptw->CompletedDate_button) , (const gchar *)completeddate_to_display); - gtk_spin_button_set_value( - GTK_SPIN_BUTTON(apptw->CompletedTime_spin_hh) - , (gdouble)tm_date.tm_hour); - gtk_spin_button_set_value( - GTK_SPIN_BUTTON(apptw->CompletedTime_spin_mm) - , (gdouble)tm_date.tm_min); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(apptw->CompletedTime_spin_hh) + , (gdouble)tm_date.tm_hour); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(apptw->CompletedTime_spin_mm) + , (gdouble)tm_date.tm_min); if (appt->completed_tz_loc) { gtk_button_set_label(GTK_BUTTON(apptw->CompletedTimezone_button) , _(appt->completed_tz_loc)); @@ -1350,7 +1305,8 @@ g_warning("fill_appt_window_times: completedtime wrong %s", appt->uid); } -static xfical_appt *fill_appt_window_get_appt(char *action, char *par) +static xfical_appt *fill_appt_window_get_appt(appt_win *apptw + , char *action, char *par) { xfical_appt *appt=NULL; struct tm *t; @@ -1405,26 +1361,30 @@ /* default alarm type is orage window */ appt->display_alarm_orage = TRUE; } - else if ((strcmp(action, "UPDATE") == 0) - || (strcmp(action, "COPY") == 0)) { + else if ((strcmp(action, "UPDATE") == 0) || (strcmp(action, "COPY") == 0)) { /* par contains ical uid */ if (!xfical_file_open(TRUE)) return(NULL); if ((appt = xfical_appt_get(par)) == NULL) { - orage_message("appointment not found"); - xfical_file_close(TRUE); - return(NULL); + orage_message("appointment not found: %s", par); + xfce_message_dialog(GTK_WINDOW(apptw->Window) + , _("Info") + , GTK_STOCK_DIALOG_INFO + , _("This appointment does not exist.") + , _("It was probably removed, please refresh your screen.") + , GTK_STOCK_OK, GTK_RESPONSE_ACCEPT + , NULL); } xfical_file_close(TRUE); } else { g_error("unknown parameter\n"); - return(NULL); } return(appt); } +/* Fill appointment window with data */ static void fill_appt_window(appt_win *apptw, char *action, char *par) { int day, hours, minutes; @@ -1434,7 +1394,7 @@ int i; orage_message("%s appointment: %s", action, par); - if ((appt = fill_appt_window_get_appt(action, par)) == NULL) { + if ((appt = fill_appt_window_get_appt(apptw, action, par)) == NULL) { apptw->appt = NULL; return; } @@ -1503,10 +1463,6 @@ gtk_editable_insert_text(GTK_EDITABLE(apptw->Title_entry) , _(" *** COPY ***"), strlen(_(" *** COPY ***")), &i); } - /* - gtk_entry_append_text(GTK_ENTRY(apptw->Title_entry) - , _(" *** COPY ***")); - */ /* location */ gtk_entry_set_text(GTK_ENTRY(apptw->Location_entry) @@ -1555,13 +1511,11 @@ /* persistent */ gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(apptw->Per_checkbutton) - , appt->alarm_persistent); + GTK_TOGGLE_BUTTON(apptw->Per_checkbutton), appt->alarm_persistent); /* sound */ gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(apptw->Sound_checkbutton) - , appt->sound_alarm); + GTK_TOGGLE_BUTTON(apptw->Sound_checkbutton), appt->sound_alarm); gtk_entry_set_text(GTK_ENTRY(apptw->Sound_entry) , (appt->sound ? appt->sound : PACKAGE_DATA_DIR "/orage/sounds/Spo.wav")); @@ -1584,8 +1538,8 @@ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(apptw->Display_checkbutton_notify) , appt->display_alarm_notify); - if (!appt->display_alarm_notify - || appt->display_notify_timeout == -1) { /* no timeout */ + if (!appt->display_alarm_notify || appt->display_notify_timeout == -1) { + /* no timeout */ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(apptw->Display_checkbutton_expire_notify) , FALSE); @@ -1605,8 +1559,7 @@ /* procedure */ gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(apptw->Proc_checkbutton) - , appt->procedure_alarm); + GTK_TOGGLE_BUTTON(apptw->Proc_checkbutton), appt->procedure_alarm); tmp = g_strconcat(appt->procedure_cmd, " ", appt->procedure_params, NULL); gtk_entry_set_text(GTK_ENTRY(apptw->Proc_entry), tmp ? tmp : ""); g_free(tmp); @@ -1621,10 +1574,6 @@ GTK_TOGGLE_BUTTON(apptw->Recur_limit_rb), TRUE); gtk_spin_button_set_value( GTK_SPIN_BUTTON(apptw->Recur_count_spin), (gdouble)1); - /* - t = orage_localtime(); - untildate_to_display = orage_tm_date_to_i18_date(t); - */ untildate_to_display = orage_localdate_i18(); gtk_button_set_label(GTK_BUTTON(apptw->Recur_until_button) , (const gchar *)untildate_to_display); @@ -1635,10 +1584,6 @@ gtk_spin_button_set_value( GTK_SPIN_BUTTON(apptw->Recur_count_spin) , (gdouble)appt->recur_count); - /* - t = orage_localtime(); - untildate_to_display = orage_tm_date_to_i18_date(t); - */ untildate_to_display = orage_localdate_i18(); gtk_button_set_label(GTK_BUTTON(apptw->Recur_until_button) , (const gchar *)untildate_to_display); @@ -1685,9 +1630,6 @@ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(apptw->Recur_feature_normal_rb), TRUE); } - /* - xfical_appt_free(appt); - */ set_time_sensitivity(apptw); set_repeat_sensitivity(apptw); @@ -1794,23 +1736,11 @@ , G_CALLBACK(on_appDelete_clicked_cb), apptw); } -/* -static void oc_set_height_changed(GtkSpinButton *sb, appt_win *apptw) -{ - gint test; - - test = gtk_spin_button_get_value_as_int(sb); - g_print("oc_set_height_changed: %d\n", test); -} -*/ - - static void build_general_page(appt_win *apptw) { gint row; GtkWidget *label, *event, *hbox; - char *availability_array[AVAILABILITY_ARRAY_DIM] = { - _("Free"), _("Busy")}; + char *availability_array[2] = {_("Free"), _("Busy")}; apptw->TableGeneral = orage_table_new(10, BORDER_SIZE); apptw->General_notebook_page = apptw->TableGeneral; @@ -1879,10 +1809,6 @@ orage_table_add_row(apptw->TableGeneral , apptw->Start_label, apptw->StartTime_hbox , ++row, (GTK_SHRINK | GTK_FILL), (GTK_SHRINK | GTK_FILL)); - /* -g_signal_connect((gpointer) apptw->StartTime_spin_hh, "value-changed", - G_CALLBACK(oc_set_height_changed), NULL); -*/ /* end time */ apptw->End_label = gtk_label_new(_("End")); @@ -1923,9 +1849,8 @@ /* Availability (only for EVENT) */ apptw->Availability_label = gtk_label_new(_("Availability")); - apptw->Availability_cb = gtk_combo_box_new_text(); - combo_box_append_array(apptw->Availability_cb - , availability_array, AVAILABILITY_ARRAY_DIM); + apptw->Availability_cb = orage_create_combo_box_with_content( + availability_array, 2); orage_table_add_row(apptw->TableGeneral , apptw->Availability_label, apptw->Availability_cb , ++row, (GTK_FILL), (GTK_FILL)); @@ -2062,9 +1987,7 @@ , apptw->Alarm_spin_mm, apptw->Alarm_spin_mm_label); gtk_box_pack_start(GTK_BOX(apptw->Alarm_hbox), apptw->Alarm_time_hbox , FALSE, FALSE, 0); - apptw->Alarm_when_cb = gtk_combo_box_new_text(); - combo_box_append_array(apptw->Alarm_when_cb - , when_array, 4); + apptw->Alarm_when_cb = orage_create_combo_box_with_content(when_array, 4); event = gtk_event_box_new(); /* only needed for tooltips */ gtk_container_add(GTK_CONTAINER(event), apptw->Alarm_when_cb); gtk_box_pack_start(GTK_BOX(apptw->Alarm_hbox) @@ -2275,7 +2198,7 @@ static void build_recurrence_page(appt_win *apptw) { gint row, i; - char *recur_freq_array[RECUR_ARRAY_DIM] = { + char *recur_freq_array[5] = { _("None"), _("Daily"), _("Weekly"), _("Monthly"), _("Yearly")}; char *weekday_array[7] = { _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")}; @@ -2296,7 +2219,7 @@ apptw->Recur_feature_advanced_rb = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON(apptw->Recur_feature_normal_rb) - , _("Advanced")); + , _("Advanced")); gtk_box_pack_start(GTK_BOX(apptw->Recur_feature_hbox) , apptw->Recur_feature_advanced_rb, FALSE, FALSE, 15); orage_table_add_row(apptw->TableRecur @@ -2310,9 +2233,8 @@ apptw->Recur_freq_label = gtk_label_new(_("Frequency")); apptw->Recur_freq_hbox = gtk_hbox_new(FALSE, 0); - apptw->Recur_freq_cb = gtk_combo_box_new_text(); - combo_box_append_array(apptw->Recur_freq_cb - , recur_freq_array, RECUR_ARRAY_DIM); + apptw->Recur_freq_cb = orage_create_combo_box_with_content( + recur_freq_array, 5); gtk_box_pack_start(GTK_BOX(apptw->Recur_freq_hbox) , apptw->Recur_freq_cb, FALSE, FALSE, 15); apptw->Recur_int_spin_label1 = gtk_label_new(_("Each")); @@ -2473,12 +2395,7 @@ } else { /* failed to get data */ app_free_memory(apptw); - /* - gtk_widget_destroy(apptw->Window); - gtk_object_destroy(GTK_OBJECT(apptw->Tooltips)); - g_free(apptw); - */ } - return apptw; + return(apptw); } Modified: xfcalendar/trunk/src/event-list.c =================================================================== --- xfcalendar/trunk/src/event-list.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/event-list.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -46,7 +46,6 @@ #include <unistd.h> #include <time.h> -#include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> #include <gdk/gdkkeysyms.h> #include <gdk/gdk.h> @@ -61,11 +60,10 @@ #include "event-list.h" #include "appointment.h" #include "parameters.h" +#include "tray_icon.h" #include "day-view.h" -void refresh_el_win(el_win *el); - /* Direction for changing day to look at */ enum { PREVIOUS, @@ -94,7 +92,6 @@ , GtkTreeModel *model, GtkTreeIter *iter, GtkTreePath *path) { gchar *uid = NULL, *flags = NULL; - appt_win *apptw; if (gtk_tree_model_get_iter(model, iter, path)) { gtk_tree_model_get(model, iter, COL_UID, &uid, -1); @@ -108,7 +105,7 @@ } g_free(flags); #endif - apptw = create_appt_win(mode, uid, el); + create_appt_win(mode, uid, el); g_free(uid); } } @@ -119,30 +116,9 @@ el_win *el = (el_win *)user_data; GtkTreeModel *model; GtkTreeIter iter; - /* - gchar *uid = NULL, *flags = NULL; - appt_win *apptw; - */ model = gtk_tree_view_get_model(view); start_appt_win("UPDATE", el, model, &iter, path); - /* - if (gtk_tree_model_get_iter(model, &iter, path)) { - gtk_tree_model_get(model, &iter, COL_UID, &uid, -1); -#ifdef HAVE_ARCHIVE - gtk_tree_model_get(model, &iter, COL_FLAGS, &flags, -1); - if (flags && flags[3] == 'A') { - xfical_unarchive_uid(uid); - / * note that file id changes after archive * / - uid[0]='O'; - refresh_el_win(el); - } -#endif - apptw = create_appt_win("UPDATE", uid, el); - g_free(uid); - g_free(flags); - } -*/ } static gint sortEvent_comp(GtkTreeModel *model @@ -571,7 +547,6 @@ char a_day[9]; /* yyyymmdd */ struct tm *t; - /* el->days = 10*365; *//* long enough time to get everything from future */ el->days = 0; /* not used */ t = orage_localtime(); s_time = orage_tm_time_to_icaltime(t); @@ -583,18 +558,9 @@ void journal_data(el_win *el) { - /* char *s_time; */ char a_day[9]; /* yyyymmdd */ - /* struct tm t; */ el->days = 10*365; /* long enough time to get everything from future */ - /* - t = orage_i18_date_to_tm_date(gtk_button_get_label( - GTK_BUTTON(el->journal_start_button))); - s_time = orage_tm_time_to_icaltime(&t); - strncpy(a_day, s_time, 8); - a_day[8] = '\0'; - */ strcpy(a_day, orage_i18_date_to_icaltime(gtk_button_get_label( GTK_BUTTON(el->journal_start_button)))); @@ -695,10 +661,6 @@ GtkTreeIter iter; GList *list; gint list_len; - /* - gchar *uid = NULL, *flags = NULL; - appt_win *apptw; - */ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(el->TreeView)); list = gtk_tree_selection_get_selected_rows(sel, &model); @@ -708,25 +670,17 @@ g_warning("Copy: too many rows selected\n"); path = (GtkTreePath *)g_list_nth_data(list, 0); start_appt_win("COPY", el, model, &iter, path); - /* - if (gtk_tree_model_get_iter(model, &iter, path)) { - gtk_tree_model_get(model, &iter, COL_UID, &uid, -1); -#ifdef HAVE_ARCHIVE - gtk_tree_model_get(model, &iter, COL_FLAGS, &flags, -1); - if (flags && flags[3] == 'A') { - xfical_unarchive_uid(uid); - / * note that file id changes after archive * / - uid[0]='O'; - refresh_el_win(el); - } -#endif - apptw = create_appt_win("COPY", uid, el); - g_free(uid); - } - */ } - else + else { g_warning("Copy: No row selected\n"); + xfce_message_dialog(GTK_WINDOW(el->Window) + , _("Info") + , GTK_STOCK_DIALOG_INFO + , _("No rows has been selected.") + , _("Click a row to select it and after that you can copy it.") + , GTK_STOCK_OK, GTK_RESPONSE_ACCEPT + , NULL); + } g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); g_list_free(list); } @@ -833,12 +787,12 @@ static void on_Previous_clicked(GtkButton *b, gpointer user_data) { - changeSelectedDate((el_win *)user_data, PREVIOUS); + changeSelectedDate((el_win *)user_data, PREVIOUS); } static void on_Go_previous_activate_cb(GtkMenuItem *mi, gpointer user_data) { - changeSelectedDate((el_win *)user_data, PREVIOUS); + changeSelectedDate((el_win *)user_data, PREVIOUS); } static void go_to_today(el_win *el) @@ -859,24 +813,22 @@ static void on_Next_clicked(GtkButton *b, gpointer user_data) { - changeSelectedDate((el_win *)user_data, NEXT); + changeSelectedDate((el_win *)user_data, NEXT); } static void on_Go_next_activate_cb(GtkMenuItem *mi, gpointer user_data) { - changeSelectedDate((el_win *)user_data, NEXT); + changeSelectedDate((el_win *)user_data, NEXT); } static void create_new_appointment(el_win *el) { - appt_win *apptw; char *title, a_day[10]; title = (char *)gtk_window_get_title(GTK_WINDOW(el->Window)); strcpy(a_day, orage_i18_date_to_icaltime(title)); - apptw = create_appt_win("NEW", a_day, el); - /* gtk_widget_show(apptw->Window); */ + create_appt_win("NEW", a_day, el); } static void on_File_newApp_activate_cb(GtkMenuItem *mi, gpointer user_data) @@ -905,14 +857,14 @@ gint list_len, i; gchar *uid = NULL; - result = xfce_message_dialog(GTK_WINDOW(el->Window), - _("Warning"), - GTK_STOCK_DIALOG_WARNING, - _("You will permanently remove all\nselected appointments."), - _("Do you want to continue?"), - GTK_STOCK_YES, GTK_RESPONSE_ACCEPT, - GTK_STOCK_NO, GTK_RESPONSE_CANCEL, - NULL); + result = xfce_message_dialog(GTK_WINDOW(el->Window) + , _("Warning") + , GTK_STOCK_DIALOG_WARNING + , _("You will permanently remove all\nselected appointments.") + , _("Do you want to continue?") + , GTK_STOCK_YES, GTK_RESPONSE_ACCEPT + , GTK_STOCK_NO, GTK_RESPONSE_CANCEL + , NULL); if (result == GTK_RESPONSE_ACCEPT) { if (!xfical_file_open(TRUE)) @@ -1212,7 +1164,7 @@ GtkWidget *label; el->search_tab_label = gtk_label_new(_("Search")); - el->search_notebook_page = orage_table_new(2, 10); + el->search_notebook_page = orage_table_new(1, 10); label = gtk_label_new(_("Search text ")); el->search_entry = gtk_entry_new(); @@ -1348,7 +1300,7 @@ gtk_drag_source_set(el->TreeView, GDK_BUTTON1_MASK , drag_targets, DRAG_TARGET_COUNT, GDK_ACTION_COPY); - pixbuf = xfce_themed_icon_load("xfcalendar", 16); + pixbuf = orage_create_icon(g_par.xfcal, TRUE, 16, 16); gtk_drag_source_set_icon_pixbuf(el->TreeView, pixbuf); g_object_unref(pixbuf); g_signal_connect(el->TreeView, "drag_data_get" Modified: xfcalendar/trunk/src/functions.c =================================================================== --- xfcalendar/trunk/src/functions.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/functions.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #define _XOPEN_SOURCE /* glibc2 needs this */ #include <time.h> #include <string.h> @@ -44,6 +45,43 @@ * General purpose helper functions * **************************************/ +/* this is for testing only. it can be used to see where time is spent. + * Add call program_log("dbus started") in the code and run orage like: + * strace -ttt -f -o /tmp/logfile.strace ./orage + * And then you can check results: + * grep MARK /tmp/logfile.strace + * grep MARK /tmp/logfile.strace|sed s/", F_OK) = -1 ENOENT (No such file or directory)"// + * */ +void program_log (const char *format, ...) +{ + va_list args; + char *formatted, *str; + + va_start (args, format); + formatted = g_strdup_vprintf (format, args); + va_end (args); + + str = g_strdup_printf ("MARK: %s: %s", g_get_prgname(), formatted); + g_free (formatted); + + access (str, F_OK); + g_free (str); +} + + +GtkWidget *orage_create_combo_box_with_content(char *text[], int size) +{ + register int i; + GtkWidget *combo_box; + + combo_box = gtk_combo_box_new_text(); + for (i = 0; i < size; i++) { + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box) + , (const gchar *)text[i]); + } + return(combo_box); +} + gboolean orage_date_button_clicked(GtkWidget *button, GtkWidget *win) { GtkWidget *selDate_dialog; @@ -125,10 +163,10 @@ GPid pid; if (!g_shell_parse_argv(cmd, NULL, &argv, error)) - return FALSE; + return(FALSE); if (!argv || !argv[0]) - return FALSE; + return(FALSE); success = g_spawn_async(NULL, argv, NULL, spawn_flags , child_setup_async, NULL, &pid, error); Modified: xfcalendar/trunk/src/functions.h =================================================================== --- xfcalendar/trunk/src/functions.h 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/functions.h 2007-12-13 23:24:18 UTC (rev 26472) @@ -33,6 +33,8 @@ void orage_message(const char *format, ...); +GtkWidget *orage_create_combo_box_with_content(char *text[], int size); + gboolean orage_date_button_clicked(GtkWidget *button, GtkWidget *win); gboolean orage_exec(const char *cmd, gboolean *cmd_active, GError **error); Modified: xfcalendar/trunk/src/ical-code.c =================================================================== --- xfcalendar/trunk/src/ical-code.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/ical-code.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -2518,6 +2518,8 @@ #ifdef ORAGE_DEBUG g_print(P_N "\n"); #endif + if (!appt) + return; g_free(appt->uid); g_free(appt->title); g_free(appt->location); Modified: xfcalendar/trunk/src/interface.c =================================================================== --- xfcalendar/trunk/src/interface.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/interface.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -47,18 +47,7 @@ #include "parameters.h" -/* enum { - TARGET_STRING, - TARGET_ROOTWIN -}; -static GtkTargetEntry target_table[] = { - { "STRING", 0, TARGET_STRING }, - { "text/plain", 0, TARGET_STRING }, - { "application/x-rootwindow-drop", 0, TARGET_ROOTWIN } -}; -*/ -enum { DRAG_TARGET_URILIST = 0 ,DRAG_TARGET_STRING }; Modified: xfcalendar/trunk/src/main.c =================================================================== --- xfcalendar/trunk/src/main.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/main.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -41,7 +41,6 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> -#include <libxfcegui4/netk-trayicon.h> #include <glib.h> #include <gtk/gtk.h> @@ -64,23 +63,7 @@ static SessionClient *session_client = NULL; static GdkAtom atom_alive; -void program_log (const char *format, ...) -{ - va_list args; - char *formatted, *str; - va_start (args, format); - formatted = g_strdup_vprintf (format, args); - va_end (args); - - str = g_strdup_printf ("MARK: %s: %s", g_get_prgname(), formatted); - g_free (formatted); - - access (str, F_OK); - g_free (str); -} - - static void send_event(char *event) { GdkEventClient gev; @@ -221,6 +204,11 @@ #else g_print(_("\tNot using libnotify.\n")); #endif +#ifdef HAVE_ARCHIVE + g_print(_("\tUsing automatic archving.\n")); +#else + g_print(_("\tNot using archiving.\n")); +#endif g_print("\n"); } @@ -428,9 +416,6 @@ { gboolean running, initialized = FALSE; - /* - xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); - */ /* init i18n = nls to use gettext */ bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET @@ -475,10 +460,6 @@ */ read_parameters(); build_mainWin(); - /* let's do this later when the alarm timer fires first time. - * Saves 1-2 seconds in startup time - g_par.trayIcon = create_TrayIcon(g_par.xfcal); - */ set_parameters(); if (g_par.start_visible) { gtk_widget_show(g_par.xfcal->mWindow); @@ -491,14 +472,9 @@ gtk_widget_realize(g_par.xfcal->mWindow); gtk_widget_hide(g_par.xfcal->mWindow); } - /* mCalendar_month_changed_cb calls orage_mark_appointments but - * delayed using timer, so that we save another 1-2 secs in startup - orage_mark_appointments(); - */ - mCalendar_month_changed_cb((GtkCalendar *)g_par.xfcal->mCalendar, NULL); - g_par.day_timer = 0; + reset_orage_day_change(FALSE); /* first day change after we start */ alarm_read(); - orage_day_change(NULL); /* first day change after we start */ + mCalendar_month_changed_cb((GtkCalendar *)g_par.xfcal->mCalendar, NULL); /* start monitoring foreign file updates if we have foreign files */ if (g_par.foreign_count) Modified: xfcalendar/trunk/src/mainbox.c =================================================================== --- xfcalendar/trunk/src/mainbox.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/mainbox.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -63,14 +63,13 @@ static void mFile_newApp_activate_cb(GtkMenuItem *menuitem, gpointer user_data) { - appt_win *app; struct tm *t; char cur_date[9]; t = orage_localtime(); g_snprintf(cur_date, 9, "%04d%02d%02d", t->tm_year+1900 , t->tm_mon+1, t->tm_mday); - app = create_appt_win("NEW", cur_date, NULL); + create_appt_win("NEW", cur_date, NULL); } static void mFile_interface_activate_cb(GtkMenuItem *menuitem @@ -131,10 +130,6 @@ , G_DIR_SEPARATOR_S, "C" , G_DIR_SEPARATOR_S, "orage.html", NULL); orage_exec(helpdoc, NULL, NULL); - /* - xfce_exec(helpdoc, FALSE, FALSE, NULL); - xfce_exec("xfhelp4 xfce4-user-guide.html", FALSE, FALSE, NULL); - */ } static void mHelp_about_activate_cb(GtkMenuItem *menuitem, gpointer user_data) @@ -373,6 +368,20 @@ xfical_appt_free(appt); } +void create_mainbox_info(void) +{ + CalWin *cal = g_par.xfcal; + + cal->mInfo_scrolledWin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cal->mInfo_scrolledWin) + , GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_box_pack_start(GTK_BOX(cal->mVbox), cal->mInfo_scrolledWin + , FALSE, FALSE, 0); + cal->mInfo_vbox = gtk_vbox_new(FALSE, 0); + gtk_scrolled_window_add_with_viewport( + GTK_SCROLLED_WINDOW(cal->mInfo_scrolledWin), cal->mInfo_vbox); +} + void build_mainbox_info(void) { CalWin *cal = g_par.xfcal; @@ -385,14 +394,7 @@ GList *todo_list=NULL; gtk_widget_destroy(cal->mInfo_scrolledWin); - cal->mInfo_scrolledWin = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cal->mInfo_scrolledWin) - , GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(cal->mVbox), cal->mInfo_scrolledWin - , FALSE, FALSE, 0); - cal->mInfo_vbox = gtk_vbox_new(FALSE, 0); - gtk_scrolled_window_add_with_viewport( - GTK_SCROLLED_WINDOW(cal->mInfo_scrolledWin), cal->mInfo_vbox); + create_mainbox_info(); t = orage_localtime(); s_time = orage_tm_time_to_icaltime(t); @@ -417,7 +419,6 @@ g_list_free(todo_list); todo_list = NULL; } - gtk_widget_show_all(cal->mInfo_scrolledWin); } @@ -468,9 +469,8 @@ gtk_widget_show(cal->mCalendar); /* Build the Info box */ - /* build_mainbox_info always deletes scrolled window, so we create one here */ - cal->mInfo_scrolledWin = gtk_scrolled_window_new(NULL, NULL); - build_mainbox_info(); + create_mainbox_info(); + gtk_widget_show_all(cal->mInfo_scrolledWin); /* Signals */ g_signal_connect((gpointer) cal->mCalendar, "scroll_event" Modified: xfcalendar/trunk/src/parameters.c =================================================================== --- xfcalendar/trunk/src/parameters.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/parameters.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -127,13 +127,14 @@ gchar *helpdoc; if (response_id == GTK_RESPONSE_HELP) { - helpdoc = g_strconcat("xfbrowser4 ", PACKAGE_DATA_DIR + /* Needs to be in " to keep # */ + helpdoc = g_strconcat("xfbrowser4 \"", PACKAGE_DATA_DIR , G_DIR_SEPARATOR_S, "orage" , G_DIR_SEPARATOR_S, "doc" , G_DIR_SEPARATOR_S, "C" - , G_DIR_SEPARATOR_S, "orage.html#orage-preferences-window" + , G_DIR_SEPARATOR_S, "orage.html#orage-preferences-window\"" , NULL); - xfce_exec(helpdoc, FALSE, FALSE, NULL); + orage_exec(helpdoc, NULL, NULL); } else { write_parameters(); @@ -593,7 +594,6 @@ static void create_parameter_dialog_extra_setup_tab(Itf *dialog) { GtkWidget *hbox, *vbox, *label; - gint i; gchar *weekday_array[7] = { _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday") , _("Friday"), _("Saturday"), _("Sunday")}; @@ -628,12 +628,8 @@ gtk_box_pack_start(GTK_BOX(dialog->extra_vbox) , dialog->ical_weekstartday_frame, FALSE, FALSE, 5); - dialog->ical_weekstartday_combobox = gtk_combo_box_new_text(); - for (i = 0; i < 7; i++) { - gtk_combo_box_append_text( - GTK_COMBO_BOX(dialog->ical_weekstartday_combobox) - , (const gchar *)weekday_array[i]); - } + dialog->ical_weekstartday_combobox = orage_create_combo_box_with_content( + weekday_array, 7); gtk_box_pack_start(GTK_BOX(hbox) , dialog->ical_weekstartday_combobox, FALSE, FALSE, 5); gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->ical_weekstartday_combobox) Modified: xfcalendar/trunk/src/reminder.c =================================================================== --- xfcalendar/trunk/src/reminder.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/reminder.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -60,9 +60,8 @@ #define ORAGE_PERSISTENT_ALARMS "orage_persistent_alarms.txt" static void create_notify_reminder(alarm_struct *alarm); -gboolean orage_alarm_clock(gpointer user_data); -gboolean orage_tooltip_update(gpointer user_data); -void create_reminders(alarm_struct *alarm); +static void create_reminders(alarm_struct *alarm); +static void reset_orage_alarm_clock(); /* this is almost the same than in ical-code.c. * Perhaps these can be combined */ @@ -100,9 +99,6 @@ 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 && !alarm->audio) /* all gone, need to clean memory */ alarm_free(alarm, NULL); @@ -110,9 +106,6 @@ /* if both visuals are gone we can't stop audio anymore, so stop it * now before it is too late */ alarm->repeat_cnt = 0; - /* - g_print("alarm_free_memory: freed %d %d\n", alarm->audio, alarm->display_notify); - */ } static int orage_persistent_file_open(gboolean write) @@ -120,10 +113,6 @@ int p_file; char *file_name; - /* - file_name = xfce_resource_save_location(XFCE_RESOURCE_DATA - , ORAGE_DIR ORAGE_PERSISTENT_ALARMS, TRUE); - */ file_name = orage_resource_file_location(ORAGE_DIR ORAGE_PERSISTENT_ALARMS); if (!file_name) { g_warning("orage_persistent_file_open: Persistent alarms filename build failed, alarms not saved (%s)\n", file_name); @@ -152,14 +141,11 @@ if (read(p_file, buf, 3) == 0) return(FALSE); buf[3] = '\0'; -/* g_print(P_N "read cnt %s\n", buf); */ len = atoi(buf); -/* g_print(P_N "read len %d\n", len); */ for (read(p_file, buf, 1); buf[0] != '='; read(p_file, buf, 1)) ; /* skip until =, which starts the value */ read(p_file, buf, len); buf[len] = '\0'; -/* g_print(P_N "read data %s\n", buf); */ lseek(p_file, 1, SEEK_CUR); /* skip new line */ return(TRUE); } @@ -258,8 +244,8 @@ new_alarm = alarm_read_next_alarm(p_file, buf)) { if (strcmp(time_now, new_alarm->alarm_time) > 0) { create_reminders(new_alarm); - alarm_free(new_alarm, NULL); } + alarm_free(new_alarm, NULL); } close(p_file); } @@ -298,12 +284,6 @@ g_sprintf(buf, "%03dPERSISTENT=%s\n", strlen("TRUE"), "TRUE"); write(file, buf, strlen(buf)); - /* - * if (alarm->display_orage) - * s_boolean="TRUE"; - * else - * s_boolean="FALSE"; - * */ s_boolean = alarm->display_orage ? "TRUE" : "FALSE"; g_sprintf(buf, "%03dDISPLAY_ORAGE=%s\n", strlen(s_boolean), s_boolean); write(file, buf, strlen(buf)); @@ -375,7 +355,7 @@ alarm_struct *alarm = (alarm_struct *)par; /* - * These two lines wuold keep notify window active and make it possible + * These two lines would 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; @@ -472,15 +452,9 @@ { 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 @@ -639,7 +613,7 @@ g_warning("create_procedure_reminder: cmd failed(%s)", alarm->cmd); } -void create_reminders(alarm_struct *alarm) +static void create_reminders(alarm_struct *alarm) { alarm_struct *n_alarm; @@ -679,39 +653,10 @@ create_procedure_reminder(n_alarm); } -gboolean reset_orage_day_change(gboolean changed) -{ - struct tm *t; - gint secs_left; - - if (changed) { /* date was change, need to count next change time */ - t = orage_localtime(); - /* t format is 23:59:59 -> 00:00:00 so we can use - * 24:00:00 to represent next day. - * Let's find out how much time we have until it happens */ - secs_left = 60*60*(24 - t->tm_hour) - 60*t->tm_min - t->tm_sec; - /* - if (g_par.day_timer) { / * first time it is not active yet * / - g_source_remove(g_par.day_timer); - } - */ - g_par.day_timer = g_timeout_add(secs_left * 1000 - , (GtkFunction) orage_day_change, NULL); - } - else { /* the change did not happen. Need to try again asap. */ - /* - g_source_remove(g_par.day_timer); - */ - g_par.day_timer = g_timeout_add(1 * 1000 - , (GtkFunction) orage_day_change, NULL); - } - return(TRUE); -} - /* fire after the date has changed and setup the icon * and change the date in the mainwindow */ -gboolean orage_day_change(gpointer user_data) +static gboolean orage_day_change(gpointer user_data) { CalWin *xfcal; struct tm *t; @@ -764,53 +709,36 @@ return(FALSE); /* we started new timer, so we end here */ } -static gboolean reset_orage_alarm_clock() +void reset_orage_day_change(gboolean changed) { - struct tm *t, t_alarm; - GList *alarm_l; - alarm_struct *cur_alarm; - gchar *next_alarm; - gint secs_to_alarm; - /* - GDate *g_now, *g_alarm; - */ - gint dd; + struct tm *t; + gint secs_left; - if (g_par.alarm_timer) /* need to stop it if running */ - g_source_remove(g_par.alarm_timer); - if (g_par.alarm_list == NULL) { /* we do not have alarms */ - return(FALSE); + if (changed) { /* date was change, need to count next change time */ + t = orage_localtime(); + /* t format is 23:59:59 -> 00:00:00 so we can use + * 24:00:00 to represent next day. + * Let's find out how much time we have until it happens */ + secs_left = 60*60*(24 - t->tm_hour) - 60*t->tm_min - t->tm_sec; + /* + if (g_par.day_timer) { / * first time it is not active yet * / + g_source_remove(g_par.day_timer); + } + */ + g_par.day_timer = g_timeout_add(secs_left * 1000 + , (GtkFunction) orage_day_change, NULL); } - t = orage_localtime(); - t->tm_mon++; - t->tm_year = t->tm_year + 1900; - alarm_l = g_list_first(g_par.alarm_list); - cur_alarm = (alarm_struct *)alarm_l->data; - next_alarm = cur_alarm->alarm_time; - t_alarm = orage_icaltime_to_tm_time(next_alarm, FALSE); - /* let's find out how much time we have until alarm happens */ - /* - g_now = g_date_new_dmy(t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); - g_alarm = g_date_new_dmy(t_alarm.tm_mday, t_alarm.tm_mon, t_alarm.tm_year); - dd = g_date_days_between(g_now, g_alarm); - g_date_free(g_now); - g_date_free(g_alarm); - */ - dd = orage_days_between(t, &t_alarm); - secs_to_alarm = t_alarm.tm_sec - t->tm_sec - + 60*(t_alarm.tm_min - t->tm_min) - + 60*60*(t_alarm.tm_hour - t->tm_hour) - + 24*60*60*dd; - secs_to_alarm += 1; /* alarm needs to come a bit later */ - if (secs_to_alarm < 1) /* were rare, but possible */ - secs_to_alarm = 1; - g_par.alarm_timer = g_timeout_add(secs_to_alarm * 1000 - , (GtkFunction) orage_alarm_clock, NULL); - return(TRUE); + else { /* the change did not happen. Need to try again asap. */ + /* + g_source_remove(g_par.day_timer); + */ + g_par.day_timer = g_timeout_add(1 * 1000 + , (GtkFunction) orage_day_change, NULL); + } } /* check and raise alarms if there are any */ -gboolean orage_alarm_clock(gpointer user_data) +static gboolean orage_alarm_clock(gpointer user_data) { struct tm *t; GList *alarm_l; @@ -842,39 +770,39 @@ return(FALSE); /* only once */ } -/* start timer to fire every minute to keep tooltip accurate */ -gboolean start_orage_tooltip_update(gpointer user_data) +static void reset_orage_alarm_clock() { - if (g_par.tooltip_timer) { /* need to stop it if running */ - g_source_remove(g_par.tooltip_timer); - } + struct tm *t, t_alarm; + GList *alarm_l; + alarm_struct *cur_alarm; + gchar *next_alarm; + gint secs_to_alarm; + gint dd; - orage_tooltip_update(NULL); - g_par.tooltip_timer = g_timeout_add(60*1000 - , (GtkFunction) orage_tooltip_update, NULL); - return(FALSE); + if (g_par.alarm_timer) /* need to stop it if running */ + g_source_remove(g_par.alarm_timer); + if (g_par.alarm_list) { /* we have alarms */ + t = orage_localtime(); + t->tm_mon++; + t->tm_year = t->tm_year + 1900; + alarm_l = g_list_first(g_par.alarm_list); + cur_alarm = (alarm_struct *)alarm_l->data; + next_alarm = cur_alarm->alarm_time; + t_alarm = orage_icaltime_to_tm_time(next_alarm, FALSE); + /* let's find out how much time we have until alarm happens */ + dd = orage_days_between(t, &t_alarm); + secs_to_alarm = t_alarm.tm_sec - t->tm_sec + + 60*(t_alarm.tm_min - t->tm_min) + + 60*60*(t_alarm.tm_hour - t->tm_hour) + + 24*60*60*dd; + secs_to_alarm += 1; /* alarm needs to come a bit later */ + if (secs_to_alarm < 1) /* were rare, but possible */ + secs_to_alarm = 1; + g_par.alarm_timer = g_timeout_add(secs_to_alarm * 1000 + , (GtkFunction) orage_alarm_clock, NULL); + } } -/* adjust the call to happen when minute changes */ -gboolean reset_orage_tooltip_update() -{ - struct tm *t; - gint secs_left; - - t = orage_localtime(); - secs_left = 60 - t->tm_sec; - if (secs_left > 10) - orage_tooltip_update(NULL); - /* FIXME: do not start this, if it is already in progress. - * Minor thing and does not cause any real trouble and happens - * only when appoinments are updated in less than 1 minute apart. - * Perhaps not worth fixing. - * Should add another timer or static time to keep track of this */ - g_timeout_add(secs_left*1000 - , (GtkFunction) start_orage_tooltip_update, NULL); - return(FALSE); -} - /* refresh trayicon tooltip once per minute */ gboolean orage_tooltip_update(gpointer user_data) { @@ -888,7 +816,6 @@ gint year, month, day, hour, minute, second; gint dd, hh, min; GDate *g_now, *g_alarm; - if (!(g_par.trayIcon && NETK_IS_TRAY_ICON(g_par.trayIcon->tray))) { /* no trayicon => no need to update the tooltip */ @@ -937,12 +864,44 @@ return(TRUE); } -gboolean setup_orage_alarm_clock() +/* start timer to fire every minute to keep tooltip accurate */ +gboolean start_orage_tooltip_update(gpointer user_data) { + if (g_par.tooltip_timer) { /* need to stop it if running */ + g_source_remove(g_par.tooltip_timer); + } + + orage_tooltip_update(NULL); + g_par.tooltip_timer = g_timeout_add(60*1000 + , (GtkFunction) orage_tooltip_update, NULL); + return(FALSE); +} + +/* adjust the call to happen when minute changes */ +gboolean reset_orage_tooltip_update() +{ + struct tm *t; + gint secs_left; + + t = orage_localtime(); + secs_left = 60 - t->tm_sec; + if (secs_left > 10) + orage_tooltip_update(NULL); + /* FIXME: do not start this, if it is already in progress. + * Minor thing and does not cause any real trouble and happens + * only when appoinments are updated in less than 1 minute apart. + * Perhaps not worth fixing. + * Should add another timer or static time to keep track of this */ + g_timeout_add(secs_left*1000 + , (GtkFunction) start_orage_tooltip_update, NULL); + return(FALSE); +} + +void setup_orage_alarm_clock() +{ reset_orage_alarm_clock(); store_persistent_alarms(); /* keep track of alarms when orage is down */ /* We need to use timer since for some reason it does not work if we * do it here directly. Ugly, I know, but it works. */ g_timeout_add(1*1000, (GtkFunction) reset_orage_tooltip_update, NULL); - return(TRUE); } Modified: xfcalendar/trunk/src/reminder.h =================================================================== --- xfcalendar/trunk/src/reminder.h 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/reminder.h 2007-12-13 23:24:18 UTC (rev 26472) @@ -60,8 +60,8 @@ active_alarm_struct *active_alarm; } alarm_struct; -gboolean orage_day_change(gpointer user_data); -gboolean setup_orage_alarm_clock(void); +void reset_orage_day_change(gboolean changed); +void setup_orage_alarm_clock(void); void alarm_read(); void alarm_list_free(); Modified: xfcalendar/trunk/src/tray_icon.c =================================================================== --- xfcalendar/trunk/src/tray_icon.c 2007-12-13 10:58:18 UTC (rev 26471) +++ xfcalendar/trunk/src/tray_icon.c 2007-12-13 23:24:18 UTC (rev 26472) @@ -69,14 +69,13 @@ void on_new_appointment_activate(GtkMenuItem *menuitem, gpointer user_data) { - appt_win *app; struct tm *t; char cur_date[9]; t = orage_localtime(); g_snprintf(cur_date, 9, "%04d%02d%02d", t->tm_year+1900 , t->tm_mon+1, t->tm_mday); - app = create_appt_win("NEW", cur_date, NULL); + create_appt_win("NEW", cur_date, NULL); } void on_about_activate(GtkMenuItem *menuitem, gpointer user_data) @@ -114,31 +113,23 @@ gchar *day_sizes[] = {"xx-large", "x-large", "large", "medium" , "small", "x-small", "xx-small", "END"}; + icon_theme = gtk_icon_theme_get_default(); if (static_icon) { - icon_theme = gtk_icon_theme_get_default(); pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", x , GTK_ICON_LOOKUP_USE_BUILTIN, NULL); return(pixbuf); } if (x <= 12 || y <= 12) { orage_message("Too small icon size, using static icon\n"); - icon_theme = gtk_icon_theme_get_default(); pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", 16 , GTK_ICON_LOOKUP_USE_BUILTIN, NULL); - /* - pixbuf = xfce_themed_icon_load("xfcalendar", 16); - */ return(pixbuf); } if (g_par.icon_size_x == 0 || g_par.icon_size_y == 0) { /* signal to use static icon */ orage_message("Icon size set to zero, using static icon\n"); - icon_theme = gtk_icon_theme_get_default(); pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", x , GTK_ICON_LOOKUP_USE_BUILTIN, NULL); - /* - pixbuf = xfce_themed_icon_load("xfcalendar", x); - */ return(pixbuf); } @@ -275,8 +266,10 @@ pixbuf = gdk_pixbuf_get_from_drawable(NULL, pic1, pic1_cmap , 0, 0, 0, 0, width, height); } - else - pixbuf = xfce_themed_icon_load("xfcalendar", 16); + else { + pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", x + , GTK_ICON_LOOKUP_USE_BUILTIN, NULL); + } if (pixbuf == NULL) g_warning("orage_create_icon: load failed\n"); @@ -368,7 +361,6 @@ * Create the tray icon */ - /* pixbuf = xfce_themed_icon_load ("xfcalendar", 16); */ pixbuf = orage_create_icon(xfcal, FALSE , g_par.icon_size_x, g_par.icon_size_y); trayIcon = xfce_tray_icon_new_with_menu_from_pixbuf(trayMenu, pixbuf); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits