From juha at xfce.org Sat Mar 1 14:16:37 2008 From: juha at xfce.org (Juha Kautto) Date: Sat, 1 Mar 2008 13:16:37 +0000 (UTC) Subject: [Xfce4-commits] r26653 - in xfcalendar/trunk: . libical/zoneinfo/America po src Message-ID: <20080301131637.523F6F29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-01 13:16:37 +0000 (Sat, 01 Mar 2008) New Revision: 26653 Modified: xfcalendar/trunk/configure.in.in xfcalendar/trunk/libical/zoneinfo/America/Buenos_Aires.ics xfcalendar/trunk/libical/zoneinfo/America/Catamarca.ics xfcalendar/trunk/libical/zoneinfo/America/Cordoba.ics xfcalendar/trunk/libical/zoneinfo/America/Jujuy.ics xfcalendar/trunk/libical/zoneinfo/America/Mendoza.ics xfcalendar/trunk/po/fi.po 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/functions.c xfcalendar/trunk/src/functions.h xfcalendar/trunk/src/ical-code.c xfcalendar/trunk/src/ical-code.h xfcalendar/trunk/src/interface.c xfcalendar/trunk/src/parameters.c xfcalendar/trunk/src/parameters.h xfcalendar/trunk/src/reminder.c Log: 1) Added categories and made it possible to associate a colour to them. Event list and Day list views show categories with the colour. 2) timezone fixes 3) combine some code: - alarm list handling in libical and reminder - data file handling: reminder, interface, parameters and functions 4) fixed small memory leak in event-list Modified: xfcalendar/trunk/configure.in.in =================================================================== --- xfcalendar/trunk/configure.in.in 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/configure.in.in 2008-03-01 13:16:37 UTC (rev 26653) @@ -9,7 +9,7 @@ dnl dnl Version information -m4_define([orage_version], [4.5.12.10-svn]) +m4_define([orage_version], [4.5.13.0-svn]) m4_define([gtk_minimum_version], [2.6.0]) m4_define([xfce_minimum_version], [4.4.0]) Modified: xfcalendar/trunk/libical/zoneinfo/America/Buenos_Aires.ics =================================================================== --- xfcalendar/trunk/libical/zoneinfo/America/Buenos_Aires.ics 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/libical/zoneinfo/America/Buenos_Aires.ics 2008-03-01 13:16:37 UTC (rev 26653) @@ -5,8 +5,8 @@ TZID:/softwarestudio.org/Olson_20011030_5/America/Buenos_Aires X-LIC-LOCATION:America/Buenos_Aires BEGIN:STANDARD -TZOFFSETFROM:-0300 -TZOFFSETTO:-0300 +TZOFFSETFROM:-0200 +TZOFFSETTO:-0200 TZNAME:ART DTSTART:19700101T000000 END:STANDARD Modified: xfcalendar/trunk/libical/zoneinfo/America/Catamarca.ics =================================================================== --- xfcalendar/trunk/libical/zoneinfo/America/Catamarca.ics 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/libical/zoneinfo/America/Catamarca.ics 2008-03-01 13:16:37 UTC (rev 26653) @@ -5,8 +5,8 @@ TZID:/softwarestudio.org/Olson_20011030_5/America/Catamarca X-LIC-LOCATION:America/Catamarca BEGIN:STANDARD -TZOFFSETFROM:-0300 -TZOFFSETTO:-0300 +TZOFFSETFROM:-0200 +TZOFFSETTO:-0200 TZNAME:ART DTSTART:19700101T000000 END:STANDARD Modified: xfcalendar/trunk/libical/zoneinfo/America/Cordoba.ics =================================================================== --- xfcalendar/trunk/libical/zoneinfo/America/Cordoba.ics 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/libical/zoneinfo/America/Cordoba.ics 2008-03-01 13:16:37 UTC (rev 26653) @@ -5,8 +5,8 @@ TZID:/softwarestudio.org/Olson_20011030_5/America/Cordoba X-LIC-LOCATION:America/Cordoba BEGIN:STANDARD -TZOFFSETFROM:-0300 -TZOFFSETTO:-0300 +TZOFFSETFROM:-0200 +TZOFFSETTO:-0200 TZNAME:ART DTSTART:19700101T000000 END:STANDARD Modified: xfcalendar/trunk/libical/zoneinfo/America/Jujuy.ics =================================================================== --- xfcalendar/trunk/libical/zoneinfo/America/Jujuy.ics 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/libical/zoneinfo/America/Jujuy.ics 2008-03-01 13:16:37 UTC (rev 26653) @@ -5,8 +5,8 @@ TZID:/softwarestudio.org/Olson_20011030_5/America/Jujuy X-LIC-LOCATION:America/Jujuy BEGIN:STANDARD -TZOFFSETFROM:-0300 -TZOFFSETTO:-0300 +TZOFFSETFROM:-0200 +TZOFFSETTO:-0200 TZNAME:ART DTSTART:19700101T000000 END:STANDARD Modified: xfcalendar/trunk/libical/zoneinfo/America/Mendoza.ics =================================================================== --- xfcalendar/trunk/libical/zoneinfo/America/Mendoza.ics 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/libical/zoneinfo/America/Mendoza.ics 2008-03-01 13:16:37 UTC (rev 26653) @@ -5,8 +5,8 @@ TZID:/softwarestudio.org/Olson_20011030_5/America/Mendoza X-LIC-LOCATION:America/Mendoza BEGIN:STANDARD -TZOFFSETFROM:-0300 -TZOFFSETTO:-0300 +TZOFFSETFROM:-0200 +TZOFFSETTO:-0200 TZNAME:ART DTSTART:19700101T000000 END:STANDARD Modified: xfcalendar/trunk/po/fi.po =================================================================== --- xfcalendar/trunk/po/fi.po 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/po/fi.po 2008-03-01 13:16:37 UTC (rev 26653) @@ -1066,7 +1066,8 @@ "\t\tW=viikoittain, M=kuukausittain, Y=vuosittain\n" "\t 3. Tyyppi: f=vapaa, B=varattu\n" "\t 4. Tiedostossa: O=Orage\n" -"\t\t A=Arkisto F=Vieras\t 5. Tapahtuman tyyppi:\n" +"\t\t A=Arkisto F=Vieras\n" +"\t 5. Tapahtuman tyyppi:\n" "\t\tE=Tapahtuma T=Teht?v? J=Muistiinpano" #: ../src/functions.c:145 Modified: xfcalendar/trunk/src/appointment.c =================================================================== --- xfcalendar/trunk/src/appointment.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/appointment.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -41,9 +42,12 @@ #include #include #include +#include #include +#include #include +#include #include "functions.h" #include "mainbox.h" @@ -57,6 +61,27 @@ #define FILETYPE_SIZE 38 +typedef struct _orage_category_win +{ + GtkWidget *window; + GtkWidget *vbox; + + GtkWidget *new_frame; + GtkWidget *new_entry; + GtkWidget *new_color_button; + GtkWidget *new_add_button; + + GtkWidget *cur_frame; + GtkWidget *cur_frame_vbox; + + GtkTooltips *tooltips; + GtkAccelGroup *accelgroup; + + gpointer *apptw; +} category_win_struct; + +static void refresh_categories(category_win_struct *catw); + static void fill_appt_window(appt_win *apptw, char *action, char *par); /* * the previous and the following are the main functions in this file @@ -750,7 +775,7 @@ struct tm current_t; gchar starttime[6], endtime[6], completedtime[6]; gint i, j, k; - gchar *tmp; + gchar *tmp, *tmp2; /* Next line is fix for bug 2811. * We need to make sure spin buttons do not have values which are not @@ -859,6 +884,21 @@ appt->availability = gtk_combo_box_get_active( GTK_COMBO_BOX(apptw->Availability_cb)); + /* categories */ + tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(apptw->Categories_entry))); + tmp2 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(apptw->Categories_cb)); + if (!strcmp(tmp2, _("Not set"))) { + g_free(tmp2); + tmp2 = NULL; + } + if (tmp) { + appt->categories = g_strjoin(",", tmp, tmp2, NULL); + g_free(tmp); + g_free(tmp2); + } + else + appt->categories = tmp2; + /* notes */ gtk_text_buffer_get_bounds(apptw->Note_buffer, &start, &end); appt->note = gtk_text_iter_get_text(&start, &end); @@ -1370,7 +1410,7 @@ /* default alarm type is orage window and sound */ appt->display_alarm_orage = TRUE; - appt->sound_alarm = TRUE; + appt->sound_alarm = TRUE; /* default sound file is set in fill_appt_window */ } else if ((strcmp(action, "UPDATE") == 0) || (strcmp(action, "COPY") == 0)) { @@ -1396,6 +1436,379 @@ return(appt); } +/************************************************************/ +/* categories start. this will go to functions.c when ready */ +/************************************************************/ + +#define ORAGE_CATEGORIES "orage_categories.txt" +#define ORAGE_COLOR_FORMAT "%uR %uG %uB" + +XfceRc *orage_category_file_open(gboolean read_only) +{ + gchar *fpath; + XfceRc *rc; + + fpath = orage_data_file_location(ORAGE_CATEGORIES); + if (!fpath) { + g_warning("orage_category_file_open: category filename build failed (%s)\n", fpath); + return(NULL); + } + if ((rc = xfce_rc_simple_open(fpath, read_only)) == NULL) { + g_warning("Unable to open RC file."); + /* let's try to build it if we opened in read mode */ + if (read_only && (rc = xfce_rc_simple_open(fpath, FALSE)) == NULL) { + /* still failed, can't do more */ + g_warning("Unable to open (write) RC file."); + return(NULL); + } + } + + g_free(fpath); + return(rc); +} + +void orage_category_file_close(XfceRc *rc) +{ + xfce_rc_close(rc); +} + +typedef struct _orage_category +{ + gchar *category; + GdkColor color; +} orage_category_struct; + + +GList *orage_category_list = NULL; + +GdkColor *orage_category_list_contains(char *categories) +{ + GList *cat_l; + orage_category_struct *cat; + + if (categories == NULL) + return(NULL); + cat_l = orage_category_list; + for (cat_l = g_list_first(cat_l); + cat_l != NULL; + cat_l = g_list_next(cat_l)) { + cat = (orage_category_struct *)cat_l->data; + if (g_str_has_suffix(categories, cat->category)) { + return(&cat->color); + } + } + /* not found */ + return(NULL); +} + +void orage_category_free(gpointer gcat, gpointer dummy) +{ + orage_category_struct *cat = (orage_category_struct *)gcat; + + g_free(cat->category); + g_free(cat); +} + +void orage_category_free_list() +{ + g_list_foreach(orage_category_list, orage_category_free, NULL); + g_list_free(orage_category_list); + orage_category_list = NULL; +} + +void orage_category_get_list() +{ + XfceRc *rc; + gchar **cat_groups, *color; + gint i; + orage_category_struct *cat; + GdkColormap *pic1_cmap; + + if (orage_category_list != NULL) + orage_category_free_list(); + pic1_cmap = gdk_colormap_get_system(); + rc = orage_category_file_open(TRUE); + cat_groups = xfce_rc_get_groups(rc); + for (i=1; cat_groups[i] != NULL; i++) { + xfce_rc_set_group(rc, cat_groups[i]); + color = (char *)xfce_rc_read_entry(rc, "Color", NULL); + if (color) { + cat= g_new(orage_category_struct, 1); + cat->category = g_strdup(cat_groups[i]); + sscanf(color, ORAGE_COLOR_FORMAT, &(cat->color.red) + , &(cat->color.green), &(cat->color.blue)); + gdk_colormap_alloc_color(pic1_cmap, &cat->color, FALSE, TRUE); + orage_category_list = g_list_prepend(orage_category_list, cat); + } + } + g_strfreev(cat_groups); + orage_category_file_close(rc); +} + +gboolean category_fill_cb(GtkComboBox *cb, char *select) +{ + XfceRc *rc; + gchar **cat_gourps; + gint i; + gboolean found=FALSE; + + rc = orage_category_file_open(TRUE); + cat_gourps = xfce_rc_get_groups(rc); + /* cat_gourps[0] is special [NULL] entry always */ + gtk_combo_box_append_text(cb, _("Not set")); + gtk_combo_box_set_active(cb, 0); + for (i=1; cat_gourps[i] != NULL; i++) { + gtk_combo_box_append_text(cb, (const gchar *)cat_gourps[i]); + if (!found && select && !strcmp(select, cat_gourps[i])) { + gtk_combo_box_set_active(cb, i); + found = TRUE; + } + } + g_strfreev(cat_gourps); + orage_category_file_close(rc); + return(found); +} + +void orage_category_refill_cb(appt_win *apptw) +{ + gchar *tmp; + + /* first remember the currently selected value */ + tmp = gtk_combo_box_get_active_text(GTK_COMBO_BOX(apptw->Categories_cb)); + + /* then clear the values by removing the widget and putting it back */ + gtk_widget_destroy(apptw->Categories_cb); + apptw->Categories_cb = gtk_combo_box_new_text(); + gtk_container_add(GTK_CONTAINER(apptw->Categories_cb_event) + , apptw->Categories_cb); + + /* and finally fill it with new values */ + category_fill_cb(GTK_COMBO_BOX(apptw->Categories_cb), tmp); + + g_free(tmp); + gtk_widget_show(apptw->Categories_cb); +} + +void fill_category_data(appt_win *apptw, xfical_appt *appt) +{ + gchar *tmp = NULL; + + /* first search the last entry. which is the special color value */ + if (appt->categories) { + tmp = g_strrstr(appt->categories, ","); + if (!tmp) /* , not found, let's take the whole string */ + tmp = appt->categories; + while (*(tmp) == ' ' || *(tmp) == ',') /* skip blanks and , */ + tmp++; + } + if (category_fill_cb(GTK_COMBO_BOX(apptw->Categories_cb), tmp)) { + /* we found match. Let's try to hide that from the entry text */ + while (tmp != appt->categories + && (*(tmp-1) == ' ' || *(tmp-1) == ',')) + tmp--; + *tmp = '\0'; /* note that this goes to appt->categories */ + } + gtk_entry_set_text(GTK_ENTRY(apptw->Categories_entry) + , (appt->categories ? appt->categories : "")); +} + +void orage_category_write_entry(gchar *category, GdkColor *color) +{ + XfceRc *rc; + char *color_str; + + if (!ORAGE_STR_EXISTS(category)) { + orage_message(50, "orage_category_write_entry: empty category. Not written"); + return; + } + color_str = g_strdup_printf(ORAGE_COLOR_FORMAT + , color->red, color->green, color->blue); + rc = orage_category_file_open(FALSE); + xfce_rc_set_group(rc, category); + xfce_rc_write_entry(rc, "Color", color_str); + g_free(color_str); + orage_category_file_close(rc); +} + +static void orage_category_remove_entry(gchar *category) +{ + XfceRc *rc; + + if (!ORAGE_STR_EXISTS(category)) { + orage_message(50, "orage_category_write_entry: empty category. Not removed"); + return; + } + rc = orage_category_file_open(FALSE); + xfce_rc_delete_group(rc, category, FALSE); + orage_category_file_close(rc); +} + +static void close_cat_window(gpointer user_data) +{ + category_win_struct *catw = (category_win_struct *)user_data; + + orage_category_refill_cb((appt_win *)catw->apptw); + gtk_widget_destroy(catw->window); + gtk_object_destroy(GTK_OBJECT(catw->tooltips)); + g_free(catw); +} + +static gboolean on_cat_window_delete_event(GtkWidget *w, GdkEvent *e + , gpointer user_data) +{ + close_cat_window(user_data); + return(FALSE); +} + +static void cat_add_button_clicked(GtkButton *button, gpointer user_data) +{ + category_win_struct *catw = (category_win_struct *)user_data; + gchar *entry_category; + GdkColor color; + + entry_category = g_strdup(gtk_entry_get_text((GtkEntry *)catw->new_entry)); + g_strstrip(entry_category); + gtk_color_button_get_color((GtkColorButton *)catw->new_color_button + , &color); + orage_category_write_entry(entry_category, &color); + g_free(entry_category); + refresh_categories(catw); +} + +static void cat_color_button_changed(GtkColorButton *color_button + , gpointer user_data) +{ + category_win_struct *catw = (category_win_struct *)user_data; + gchar *category; + GdkColor color; + + category = g_object_get_data(G_OBJECT(color_button), "CATEGORY"); + gtk_color_button_get_color(color_button, &color); + orage_category_write_entry(category, &color); +} + +static void cat_del_button_clicked(GtkButton *button, gpointer user_data) +{ + category_win_struct *catw = (category_win_struct *)user_data; + gchar *category; + + category = g_object_get_data(G_OBJECT(button), "CATEGORY"); + orage_category_remove_entry(category); + refresh_categories(catw); +} + +static void show_category(gpointer elem, gpointer user_data) +{ + orage_category_struct *cat = (orage_category_struct *)elem; + category_win_struct *catw = (category_win_struct *)user_data; + GtkWidget *label, *hbox, *button, *color_button; + + hbox = gtk_hbox_new(FALSE, 0); + label = gtk_label_new(cat->category); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5); + + color_button = gtk_color_button_new_with_color(&cat->color); + gtk_box_pack_start(GTK_BOX(hbox), color_button, FALSE, FALSE, 5); + g_object_set_data_full(G_OBJECT(color_button), "CATEGORY" + , g_strdup(cat->category), g_free); + g_signal_connect((gpointer)color_button, "color-set" + , G_CALLBACK(cat_color_button_changed), catw); + + button = gtk_button_new_from_stock("gtk-remove"); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); + g_object_set_data_full(G_OBJECT(button), "CATEGORY" + , g_strdup(cat->category), g_free); + g_signal_connect((gpointer)button, "clicked" + , G_CALLBACK(cat_del_button_clicked), catw); + + gtk_box_pack_start(GTK_BOX(catw->cur_frame_vbox), hbox, FALSE, FALSE, 5); +} + +static void refresh_categories(category_win_struct *catw) +{ + GtkWidget *swin; + + gtk_widget_destroy(catw->cur_frame); + + catw->cur_frame_vbox = gtk_vbox_new(FALSE, 0); + swin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin) + , GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin) + , catw->cur_frame_vbox); + catw->cur_frame = xfce_create_framebox_with_content( + _("Current categories"), swin); + gtk_box_pack_start(GTK_BOX(catw->vbox), catw->cur_frame, TRUE, TRUE, 5); + + orage_category_get_list(); + g_list_foreach(orage_category_list, show_category, catw); + gtk_widget_show_all(catw->cur_frame); +} + +static void create_cat_win(category_win_struct *catw) +{ + GtkWidget *label, *hbox, *vbox; + + /***** New category *****/ + vbox = gtk_vbox_new(FALSE, 0); + catw->new_frame = xfce_create_framebox_with_content( + _("Add new category with color"), vbox); + gtk_box_pack_start(GTK_BOX(catw->vbox), catw->new_frame, FALSE, FALSE, 5); + + hbox = gtk_hbox_new(FALSE, 0); + label = gtk_label_new(_("Category:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + catw->new_entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(hbox), catw->new_entry, TRUE, TRUE, 0); + catw->new_color_button = gtk_color_button_new(); + gtk_box_pack_start(GTK_BOX(hbox), catw->new_color_button, FALSE, FALSE, 5); + catw->new_add_button = gtk_button_new_from_stock("gtk-add"); + gtk_box_pack_start(GTK_BOX(hbox), catw->new_add_button, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); + g_signal_connect((gpointer)catw->new_add_button, "clicked" + , G_CALLBACK(cat_add_button_clicked), catw); + + /***** Current categories *****/ + /* refresh_categories always destroys frame first, so let's create + * a dummy for it for the first time */ + vbox = gtk_vbox_new(FALSE, 0); + catw->cur_frame = xfce_create_framebox_with_content(("dummy"), vbox); + refresh_categories(catw); +} + +static void on_categories_button_clicked_cb(GtkWidget *button + , gpointer *user_data) +{ + appt_win *apptw = (appt_win *)user_data; + category_win_struct *catw; + + catw = g_new(category_win_struct, 1); + catw->apptw = (gpointer)apptw; /* remember the caller */ + catw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_modal(GTK_WINDOW(catw->window), TRUE); + gtk_window_set_title(GTK_WINDOW(catw->window) + , _("Colors of categories - Orage")); + gtk_window_set_default_size(GTK_WINDOW(catw->window), 390, 360); + + catw->tooltips = gtk_tooltips_new(); + catw->accelgroup = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(catw->window), catw->accelgroup); + + catw->vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(catw->window), catw->vbox); + + create_cat_win(catw); + + g_signal_connect((gpointer)catw->window, "delete_event", + G_CALLBACK(on_cat_window_delete_event), catw); + gtk_widget_show_all(catw->window); +} + +/**********************************************************/ +/* categories end. */ +/**********************************************************/ + /* Fill appointment window with data */ static void fill_appt_window(appt_win *apptw, char *action, char *par) { @@ -1404,6 +1817,7 @@ struct tm *t, tm_date; char *untildate_to_display, *tmp; int i; + GdkColor color; orage_message(30, "%s appointment: %s", action, par); if ((appt = fill_appt_window_get_appt(apptw, action, par)) == NULL) { @@ -1470,10 +1884,10 @@ , (appt->title ? appt->title : "")); if (strcmp(action, "COPY") == 0) { - gtk_editable_set_position(GTK_EDITABLE(apptw->Title_entry), -1); - i = gtk_editable_get_position(GTK_EDITABLE(apptw->Title_entry)); - gtk_editable_insert_text(GTK_EDITABLE(apptw->Title_entry) - , _(" *** COPY ***"), strlen(_(" *** COPY ***")), &i); + gtk_editable_set_position(GTK_EDITABLE(apptw->Title_entry), -1); + i = gtk_editable_get_position(GTK_EDITABLE(apptw->Title_entry)); + gtk_editable_insert_text(GTK_EDITABLE(apptw->Title_entry) + , _(" *** COPY ***"), strlen(_(" *** COPY ***")), &i); } /* location */ @@ -1489,6 +1903,9 @@ , appt->availability); } + /* categories */ + fill_category_data(apptw, appt); + /* note */ gtk_text_buffer_set_text(apptw->Note_buffer , (appt->note ? (const gchar *) appt->note : ""), -1); @@ -1754,7 +2171,7 @@ GtkWidget *label, *event, *hbox; char *availability_array[2] = {_("Free"), _("Busy")}; - apptw->TableGeneral = orage_table_new(10, BORDER_SIZE); + apptw->TableGeneral = orage_table_new(11, BORDER_SIZE); apptw->General_notebook_page = apptw->TableGeneral; apptw->General_tab_label = gtk_label_new(_("General")); @@ -1891,6 +2308,29 @@ , apptw->Completed_label, apptw->Completed_hbox , ++row, (GTK_FILL), (GTK_FILL)); + /* categories */ + apptw->Categories_label = gtk_label_new(_("Categories")); + apptw->Categories_hbox = gtk_hbox_new(FALSE, 0); + apptw->Categories_entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(apptw->Categories_hbox), apptw->Categories_entry + , TRUE, TRUE, 0); + apptw->Categories_cb = gtk_combo_box_new_text(); + apptw->Categories_cb_event = gtk_event_box_new(); /* needed for tooltips */ + gtk_container_add(GTK_CONTAINER(apptw->Categories_cb_event) + , apptw->Categories_cb); + gtk_box_pack_start(GTK_BOX(apptw->Categories_hbox) + , apptw->Categories_cb_event, FALSE, FALSE, 4); + gtk_tooltips_set_tip(apptw->Tooltips, apptw->Categories_cb_event + , _("This is special category, which can be used to color this appointment in list views."), NULL); + apptw->Categories_button =gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR); + gtk_box_pack_start(GTK_BOX(apptw->Categories_hbox), apptw->Categories_button + , FALSE, FALSE, 0); + gtk_tooltips_set_tip(apptw->Tooltips, apptw->Categories_button + , _("update colors for categories."), NULL); + orage_table_add_row(apptw->TableGeneral + , apptw->Categories_label, apptw->Categories_hbox + , ++row, (GTK_EXPAND | GTK_FILL), (0)); + /* note */ apptw->Note = gtk_label_new(_("Note")); apptw->Note_Scrolledwindow = gtk_scrolled_window_new(NULL, NULL); @@ -1955,14 +2395,17 @@ , G_CALLBACK(on_app_spin_button_changed_cb), apptw); g_signal_connect((gpointer)apptw->CompletedTimezone_button, "clicked" , G_CALLBACK(on_appCompletedTimezone_clicked_cb), apptw); - /* Take care of the title entry to build the appointment window title - * Beware: we are not using apptw->Title_entry as a GtkEntry here - * but as an interface GtkEditable instead. - */ + /* Take care of the title entry to build the appointment window title */ g_signal_connect((gpointer)apptw->Title_entry, "changed" , G_CALLBACK(on_appTitle_entry_changed_cb), apptw); g_signal_connect((gpointer)apptw->Location_entry, "changed" , G_CALLBACK(on_app_entry_changed_cb), apptw); + g_signal_connect((gpointer)apptw->Categories_entry, "changed" + , G_CALLBACK(on_app_entry_changed_cb), apptw); + g_signal_connect((gpointer)apptw->Categories_cb, "changed" + , G_CALLBACK(on_app_combobox_changed_cb), apptw); + g_signal_connect((gpointer)apptw->Categories_button, "clicked" + , G_CALLBACK(on_categories_button_clicked_cb), apptw); g_signal_connect((gpointer)apptw->Availability_cb, "changed" , G_CALLBACK(on_app_combobox_changed_cb), apptw); g_signal_connect((gpointer)apptw->Note_buffer, "changed" Modified: xfcalendar/trunk/src/appointment.h =================================================================== --- xfcalendar/trunk/src/appointment.h 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/appointment.h 2008-03-01 13:16:37 UTC (rev 26653) @@ -94,6 +94,12 @@ GtkWidget *CompletedTimezone_button; GtkWidget *Availability_label; GtkWidget *Availability_cb; + GtkWidget *Categories_label; + GtkWidget *Categories_hbox; + GtkWidget *Categories_entry; + GtkWidget *Categories_cb; + GtkWidget *Categories_cb_event; + GtkWidget *Categories_button; GtkWidget *Note; GtkWidget *Note_Scrolledwindow; GtkWidget *Note_textview; @@ -183,4 +189,7 @@ appt_win *create_appt_win(char *action, char *par); +GdkColor *orage_category_list_contains(char *categories); +void orage_category_get_list(); + #endif /* !__APPOINTMENT_H__ */ Modified: xfcalendar/trunk/src/day-view.c =================================================================== --- xfcalendar/trunk/src/day-view.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/day-view.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -418,6 +418,7 @@ gchar *text, *tip, *start_date, *end_date; GtkWidget *ev, *lab, *hb; struct tm tm_start, tm_end, tm_first; + GdkColor *color; /* First clarify timings */ tm_start = orage_icaltime_to_tm_time(appt->starttimecur, FALSE); @@ -443,30 +444,39 @@ if (appt->starttimecur[8] != 'T') { /* whole day event */ gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg2); - if (dw->header[col] == NULL) - hb = gtk_hbox_new(TRUE, 1); - else + if (dw->header[col] == NULL) { /* first data */ + hb = gtk_hbox_new(TRUE, 3); + dw->header[col] = hb; + } + else { hb = dw->header[col]; + /* FIXME: set some real bar here to make it visible that we + * have more than 1 appointment here + */ + } tip = g_strdup_printf("%s\n%s - %s\n%s" - , appt->title - , appt->starttimecur - , appt->endtimecur + , appt->title, appt->starttimecur, appt->endtimecur , appt->note); - dw->header[col] = hb; } else { - if ((row % 2) == 1) + if ((color = orage_category_list_contains(appt->categories)) != NULL) + gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, color); + else if ((row % 2) == 1) gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg1); - if (dw->element[row][col] == NULL) - hb = gtk_hbox_new(TRUE, 1); - else + if (dw->element[row][col] == NULL) { + hb = gtk_hbox_new(TRUE, 3); + dw->element[row][col] = hb; + } + else { hb = dw->element[row][col]; + /* FIXME: set some real bar here to make it visible that we + * have more than 1 appointment here + */ + } if (orage_days_between(&tm_start, &tm_end) == 0) tip = g_strdup_printf("%s\n%02d:%02d-%02d:%02d\n%s" - , appt->title - , tm_start.tm_hour, tm_start.tm_min - , tm_end.tm_hour, tm_end.tm_min - , appt->note); + , appt->title, tm_start.tm_hour, tm_start.tm_min + , tm_end.tm_hour, tm_end.tm_min, appt->note); else { /* we took the date in unnormalized format, so we need to do that now */ tm_start.tm_year -= 1900; @@ -483,7 +493,6 @@ g_free(start_date); g_free(end_date); } - dw->element[row][col] = hb; } gtk_tooltips_set_tip(dw->Tooltips, ev, tip, NULL); /* @@ -774,6 +783,7 @@ guint monthdays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; GtkWidget *vp; + orage_category_get_list(); days = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dw->day_spin)); tm_date = orage_i18_date_to_tm_date( gtk_button_get_label(GTK_BUTTON(dw->StartDate_button))); Modified: xfcalendar/trunk/src/event-list.c =================================================================== --- xfcalendar/trunk/src/event-list.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/event-list.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -63,6 +63,7 @@ #include "tray_icon.h" #include "day-view.h" +#define BORDER_SIZE 10 enum { COL_TIME = 0 @@ -70,6 +71,7 @@ ,COL_HEAD ,COL_UID ,COL_SORT + ,CAL_CATEGORIES ,NUM_COLS }; @@ -215,6 +217,24 @@ return(result); } +static void flags_data_func(GtkTreeViewColumn *col, GtkCellRenderer *rend + , GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) +{ + gchar *categories; + GdkColor *color; + + gtk_tree_model_get(model, iter, CAL_CATEGORIES, &categories, -1); + if ((color = orage_category_list_contains(categories)) == NULL) + g_object_set(rend + , "background-set", FALSE + , NULL); + else + g_object_set(rend + , "background-gdk", color + , "background-set", TRUE + , NULL); +} + static void start_time_data_func(GtkTreeViewColumn *col, GtkCellRenderer *rend , GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { @@ -272,6 +292,7 @@ , "weight-set", TRUE , NULL); } + g_free(stime); } else if (el->page == TODO_PAGE) { gtk_tree_model_get(model, iter, COL_SORT, &stime, -1); @@ -310,6 +331,7 @@ , "weight-set", TRUE , NULL); } + g_free(stime); } else { g_object_set(rend @@ -393,6 +415,7 @@ , COL_HEAD, title , COL_UID, appt->uid , COL_SORT, s_sort1 + , CAL_CATEGORIES, appt->categories , -1); g_free(title); g_free(s_sort1); @@ -577,6 +600,7 @@ void refresh_el_win(el_win *el) { + orage_category_get_list(); if (el->Window && el->ListStore && el->TreeView) { gtk_list_store_clear(el->ListStore); el->page = gtk_notebook_get_current_page(GTK_NOTEBOOK(el->Notebook)); @@ -1096,7 +1120,8 @@ GtkWidget *label, *hbox; el->event_tab_label = gtk_label_new(_("Event")); - el->event_notebook_page = orage_table_new(2, 10); + /* FIXME: remove these tables, which are not needed anymore */ + el->event_notebook_page = orage_table_new(1, BORDER_SIZE); label = gtk_label_new(_("Extra days to show ")); hbox = gtk_hbox_new(FALSE, 0); @@ -1116,7 +1141,8 @@ static void build_todo_tab(el_win *el) { el->todo_tab_label = gtk_label_new(_("Todo")); - el->todo_notebook_page = orage_table_new(2, 10); + /* FIXME: remove these tables, which are not needed anymore */ + el->todo_notebook_page = orage_table_new(1, BORDER_SIZE); gtk_notebook_append_page(GTK_NOTEBOOK(el->Notebook) , el->todo_notebook_page, el->todo_tab_label); @@ -1130,7 +1156,8 @@ gchar *sdate; el->journal_tab_label = gtk_label_new(_("Journal")); - el->journal_notebook_page = orage_table_new(2, 10); + /* FIXME: remove these tables, which are not needed anymore */ + el->journal_notebook_page = orage_table_new(1, BORDER_SIZE); label = gtk_label_new(_("Journal entries starting from:")); hbox = gtk_hbox_new(FALSE, 0); @@ -1158,7 +1185,8 @@ GtkWidget *label; el->search_tab_label = gtk_label_new(_("Search")); - el->search_notebook_page = orage_table_new(1, 10); + /* FIXME: remove these tables, which are not needed anymore */ + el->search_notebook_page = orage_table_new(1, BORDER_SIZE); label = gtk_label_new(_("Search text ")); el->search_entry = gtk_entry_new(); @@ -1199,7 +1227,7 @@ /* Tree view */ el->ListStore = gtk_list_store_new(NUM_COLS , G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING - , G_TYPE_STRING); + , G_TYPE_STRING, G_TYPE_STRING); el->TreeView = gtk_tree_view_new(); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(el->TreeView), TRUE); @@ -1229,6 +1257,8 @@ col = gtk_tree_view_column_new_with_attributes( _("Flags"), rend , "text", COL_FLAGS , NULL); + gtk_tree_view_column_set_cell_data_func(col, rend, flags_data_func + , el, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(el->TreeView), col); rend = gtk_cell_renderer_text_new(); @@ -1251,6 +1281,13 @@ gtk_tree_view_append_column(GTK_TREE_VIEW(el->TreeView), col); gtk_tree_view_column_set_visible(col, FALSE); + rend = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new_with_attributes("cat", rend + , "text", CAL_CATEGORIES + , NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(el->TreeView), col); + gtk_tree_view_column_set_visible(col, FALSE); + gtk_tooltips_set_tip(el->Tooltips, el->TreeView, _("Double click line to edit it.\n\nFlags in order:\n\t 1. Alarm: n=no alarm\n\t\t A=visual Alarm S=also Sound alarm\n\t 2. Recurrence: n=no recurrence\n\t\t D=Daily W=Weekly M=Monthly Y=Yearly\n\t 3. Type: f=free B=Busy\n\t 4. Located in file:\n\t\tO=Orage A=Archive F=Foreign\n\t 5. Appointment type:\n\t\tE=Event T=Todo J=Journal"), NULL); g_signal_connect(el->TreeView, "row-activated", Modified: xfcalendar/trunk/src/functions.c =================================================================== --- xfcalendar/trunk/src/functions.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/functions.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -36,9 +36,7 @@ #include #include -/* #include -*/ #include "orage-i18n.h" #include "functions.h" @@ -106,21 +104,6 @@ g_free(formatted); } -/* -void orage_message(const char *format, ...) -{ - va_list args; - char *formatted, *str; - - va_start(args, format); - formatted = g_strdup_vprintf(format, args); - va_end(args); - - g_message("Orage **: %s", formatted); - g_free(formatted); -} -*/ - GtkWidget *orage_create_combo_box_with_content(char *text[], int size) { register int i; @@ -504,3 +487,13 @@ t = orage_localtime(); orage_select_date(cal, t->tm_year+1900, t->tm_mon, t->tm_mday); } + +gchar *orage_data_file_location(char *name) +{ + char *file_name, *dir_name; + + dir_name = g_strconcat(ORAGE_DIR, name, NULL); + file_name = xfce_resource_save_location(XFCE_RESOURCE_DATA, dir_name, TRUE); + g_free(dir_name); + return(file_name); +} Modified: xfcalendar/trunk/src/functions.h =================================================================== --- xfcalendar/trunk/src/functions.h 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/functions.h 2008-03-01 13:16:37 UTC (rev 26653) @@ -29,6 +29,11 @@ #define XFICAL_APPT_DATE_FORMAT "%04d%02d%02d" #define XFICAL_APPT_DATE_FORMAT_LEN 9 +#define ORAGE_DIR "orage" G_DIR_SEPARATOR_S +#define ORAGE_PARFILE "oragerc" +#define ORAGE_APPFILE "orage.ics" +#define ORAGE_ARCFILE "orage_archive.ics" + #define ORAGE_STR_EXISTS(str) ((str != NULL) && (str[0] != 0)) void orage_message(gint level, const char *format, ...); @@ -72,4 +77,6 @@ void orage_select_date(GtkCalendar *cal, guint year, guint month, guint day); void orage_select_today(GtkCalendar *cal); +gchar *orage_data_file_location(char *name); + #endif /* !__ORAGE_FUNCTIONS_H__ */ Modified: xfcalendar/trunk/src/ical-code.c =================================================================== --- xfcalendar/trunk/src/ical-code.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/ical-code.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -909,9 +909,24 @@ #endif itime_tz = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER); if (itime_tz) { - tz_loc = (char *) icalparameter_get_tzid(itime_tz); - l_icaltimezone = icaltimezone_get_builtin_timezone(tz_loc); - if (!l_icaltimezone) { + tz_loc = (char *)icalparameter_get_tzid(itime_tz); + if (tz_loc[0] == '/') { + /* FIXME: this should be in import and in get data + * This probably is evolution format, + * which has /xxx/xxx/timezone and we should remove the + * extra /xxx/xxx/ from it */ + char **new_str; + + orage_message(-20, P_N "evolution timezone fix %s", tz_loc); + new_str = g_strsplit(tz_loc, "/", 4); + if (new_str[0] != NULL && new_str[1] != NULL && new_str[2] != NULL + && new_str[3] != NULL) + l_icaltimezone = icaltimezone_get_builtin_timezone(new_str[3]); + g_strfreev(new_str); + } + else + l_icaltimezone = icaltimezone_get_builtin_timezone(tz_loc); + if (!l_icaltimezone) { orage_message(250, P_N "builtin timezone %s not found, conversion failed.", tz_loc); } tz = icaltime_convert_to_zone(t, l_icaltimezone); @@ -919,7 +934,7 @@ else tz = t; - return (tz); + return(tz); } static struct icaltimetype convert_to_local_timezone(struct icaltimetype t @@ -1597,6 +1612,7 @@ struct icaltimetype dtstamp, create_time, wtime; gboolean end_time_done; gchar *int_uid, *ext_uid; + gchar **tmp_cat; struct icaldurationtype duration; int i; icalcomponent_kind ikind = ICAL_VEVENT_COMPONENT; @@ -1632,7 +1648,7 @@ icmp = icalcomponent_vanew(ikind , icalproperty_new_uid(int_uid) - , icalproperty_new_categories("ORAGENOTE") + /* , icalproperty_new_categories("ORAGENOTE") */ , icalproperty_new_class(ICAL_CLASS_PUBLIC) , icalproperty_new_dtstamp(dtstamp) , icalproperty_new_created(create_time) @@ -1651,6 +1667,14 @@ icalcomponent_add_property(icmp , icalproperty_new_location(appt->location)); } + if (appt->categories) { /* need to split it if more than one */ + tmp_cat = g_strsplit(appt->categories, ",", 0); + for (i=0; tmp_cat[i] != NULL; i++) { + icalcomponent_add_property(icmp + , icalproperty_new_categories(tmp_cat[i])); + } + g_strfreev(tmp_cat); + } if (appt->allDay) { /* cut the string after Date: yyyymmdd */ appt->starttime[8] = '\0'; appt->endtime[8] = '\0'; @@ -2255,6 +2279,7 @@ appt.completed_tz_loc = NULL; appt.availability = -1; appt.priority = 0; + appt.categories = NULL; appt.note = NULL; appt.alarmtime = 0; appt.alarm_before = TRUE; @@ -2358,6 +2383,16 @@ appt.priority = icalproperty_get_priority(p); break; case ICAL_CATEGORIES_PROPERTY: + if (appt.categories == NULL) + appt.categories = g_strdup(icalproperty_get_categories(p)); + else { + text = appt.categories; + appt.categories = g_strjoin("," + , appt.categories + , icalproperty_get_categories(p), NULL); + g_free((char *)text); + } + break; case ICAL_CLASS_PROPERTY: case ICAL_DTSTAMP_PROPERTY: case ICAL_CREATED_PROPERTY: Modified: xfcalendar/trunk/src/ical-code.h =================================================================== --- xfcalendar/trunk/src/ical-code.h 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/ical-code.h 2008-03-01 13:16:37 UTC (rev 26653) @@ -48,9 +48,10 @@ /* note that version 4.5.9 changed uid format. * new format starts with 3 char source id (plus separator '.'), * which tells the file where the id is found: - * "O01." = Orage file (normal file) - * "A01." = Archive file + * "O00." = Orage file (normal file) + * "A00." = Archive file * "F10." = Foreign file number 10 + * "H08." = Holiday file number 08 */ gchar *uid; gchar *title; @@ -75,6 +76,7 @@ gint availability; gint priority; + gchar *categories; gchar *note; /* alarm */ Modified: xfcalendar/trunk/src/interface.c =================================================================== --- xfcalendar/trunk/src/interface.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/interface.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -321,9 +321,9 @@ gchar *rcfile; gchar *s; - rcfile = orage_resource_file_location(ORAGE_DIR); + rcfile = orage_data_file_location(NULL); f_chooser = orage_file_chooser(intf_w->main_window, TRUE - , g_par.orage_file, rcfile, APPFILE); + , g_par.orage_file, rcfile, ORAGE_APPFILE); g_free(rcfile); if (gtk_dialog_run(GTK_DIALOG(f_chooser)) == GTK_RESPONSE_ACCEPT) { @@ -348,9 +348,9 @@ gchar *rcfile; gchar *s; - rcfile = orage_resource_file_location(ORAGE_DIR); + rcfile = orage_data_file_location(NULL); f_chooser = orage_file_chooser(intf_w->main_window, TRUE - , g_par.archive_file, rcfile, ARCFILE); + , g_par.archive_file, rcfile, ORAGE_ARCFILE); g_free(rcfile); if (gtk_dialog_run(GTK_DIALOG(f_chooser)) == GTK_RESPONSE_ACCEPT) { @@ -1319,8 +1319,8 @@ create_orage_file_tab(intf_w); create_foreign_file_tab(intf_w); - g_signal_connect((gpointer)intf_w->main_window, "delete_event", - G_CALLBACK(on_Window_delete_event), intf_w); + g_signal_connect((gpointer)intf_w->main_window, "delete_event", + G_CALLBACK(on_Window_delete_event), intf_w); gtk_widget_show_all(intf_w->main_window); drag_and_drop_init(intf_w); Modified: xfcalendar/trunk/src/parameters.c =================================================================== --- xfcalendar/trunk/src/parameters.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/parameters.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -115,15 +115,6 @@ } Itf; -gchar *orage_resource_file_location(char *name) -{ - char *file_name; - - file_name = xfce_resource_save_location(XFCE_RESOURCE_DATA - , name, TRUE); - return(file_name); -} - static void dialog_response(GtkWidget *dialog, gint response_id , gpointer user_data) { @@ -792,7 +783,7 @@ gchar f_par[50]; fpath = xfce_resource_save_location(XFCE_RESOURCE_CONFIG - , ORAGE_DIR PARFILE, TRUE); + , ORAGE_DIR ORAGE_PARFILE, TRUE); if ((rc = xfce_rc_simple_open(fpath, FALSE)) == NULL) { g_warning("Unable to open RC file."); return; @@ -855,7 +846,7 @@ gchar f_par[100]; fpath = xfce_resource_save_location(XFCE_RESOURCE_CONFIG - , ORAGE_DIR PARFILE, TRUE); + , ORAGE_DIR ORAGE_PARFILE, TRUE); if ((rc = xfce_rc_simple_open(fpath, TRUE)) == NULL) { g_warning("Unable to open (read) RC file."); @@ -870,12 +861,12 @@ g_strdup(xfce_rc_read_entry(rc, "Timezone", "floating")); #ifdef HAVE_ARCHIVE g_par.archive_limit = xfce_rc_read_int_entry(rc, "Archive limit", 0); - fpath2 = orage_resource_file_location(ORAGE_DIR ARCFILE); + fpath2 = orage_data_file_location(ORAGE_ARCFILE); g_par.archive_file = g_strdup(xfce_rc_read_entry(rc, "Archive file", fpath2)); g_free(fpath2); #endif - fpath2 = orage_resource_file_location(ORAGE_DIR APPFILE); + fpath2 = orage_data_file_location(ORAGE_APPFILE); g_par.orage_file = g_strdup(xfce_rc_read_entry(rc, "Orage file", fpath2)); g_free(fpath2); g_par.sound_application = Modified: xfcalendar/trunk/src/parameters.h =================================================================== --- xfcalendar/trunk/src/parameters.h 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/parameters.h 2008-03-01 13:16:37 UTC (rev 26653) @@ -26,11 +26,6 @@ #include "xfce_trayicon.h" #include "mainbox.h" -#define ORAGE_DIR "orage" G_DIR_SEPARATOR_S -#define PARFILE "oragerc" -#define APPFILE "orage.ics" -#define ARCFILE "orage_archive.ics" - #define BORDER 5 typedef struct _foreign_file { @@ -104,7 +99,6 @@ extern global_parameters g_par; /* refer to existing global parameters */ #endif -gchar *orage_resource_file_location(char *name); void show_parameters(void); void write_parameters(void); void read_parameters(void); Modified: xfcalendar/trunk/src/reminder.c =================================================================== --- xfcalendar/trunk/src/reminder.c 2008-02-28 13:37:25 UTC (rev 26652) +++ xfcalendar/trunk/src/reminder.c 2008-03-01 13:16:37 UTC (rev 26653) @@ -63,8 +63,6 @@ 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 */ static void alarm_free(gpointer galarm, gpointer dummy) { #undef P_N @@ -113,7 +111,7 @@ int p_file; char *file_name; - file_name = orage_resource_file_location(ORAGE_DIR ORAGE_PERSISTENT_ALARMS); + file_name = orage_data_file_location(ORAGE_PERSISTENT_ALARMS); if (!file_name) { g_warning("orage_persistent_file_open: Persistent alarms filename build failed, alarms not saved (%s)\n", file_name); return(-1); From peter at xfce.org Sat Mar 1 15:41:50 2008 From: peter at xfce.org (Peter de Ridder) Date: Sat, 1 Mar 2008 14:41:50 +0000 (UTC) Subject: [Xfce4-commits] r26654 - in squeeze/trunk: data libsqueeze src Message-ID: <20080301144150.7BDA8F29D8@mocha.foo-projects.org> Author: peter Date: 2008-03-01 14:41:50 +0000 (Sat, 01 Mar 2008) New Revision: 26654 Modified: squeeze/trunk/data/gnu-tar.squeeze squeeze/trunk/libsqueeze/archive-tempfs.h squeeze/trunk/libsqueeze/command-queue.c squeeze/trunk/libsqueeze/command-queue.h squeeze/trunk/libsqueeze/support-reader.c squeeze/trunk/libsqueeze/support-template.h squeeze/trunk/src/application.c squeeze/trunk/src/main_window.c squeeze/trunk/src/notebook.c Log: command queue near finnished, but untested Modified: squeeze/trunk/data/gnu-tar.squeeze =================================================================== --- squeeze/trunk/data/gnu-tar.squeeze 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/data/gnu-tar.squeeze 2008-03-01 14:41:50 UTC (rev 26654) @@ -16,32 +16,32 @@ [application/x-compressed-tar] X-Squeeze-Requires=tar;gzip;gunzip X-Squeeze-New=tar -zcf %a %F -X-Squeeze-Add=gunzip -c %a >> %t;tar -rf %a %F;gzip -c %t >> %a -X-Squeeze-Remove=gunzip -c %a >> %t;tar -f %t --delete %F; gzip -c %t >> %a +X-Squeeze-Add=gunzip -c %a > %t;tar -rf %a %F;gzip -c %t > %a +X-Squeeze-Remove=gunzip -c %a > %t;tar -f %t --delete %F; gzip -c %t > %a X-Squeeze-Extract=tar -C %d -xf %a %F X-Squeeze-Refresh=tar -tvvf %a [application/x-bzip-compressed-tar] X-Squeeze-Requires=tar;bzip2;bunzip2 X-Squeeze-New=tar -jcf %a %F -X-Squeeze-Add=bunzip2 -c %a >> %t;tar -rf %t %F;bzip2 -c %t >> %a -X-Squeeze-Remove=bunzip2 -c %a >> %t;tar -f %t --delete %F; bzip2 -c %t >> %a +X-Squeeze-Add=bunzip2 -c %a > %t;tar -rf %t %F;bzip2 -c %t > %a +X-Squeeze-Remove=bunzip2 -c %a > %t;tar -f %t --delete %F; bzip2 -c %t > %a X-Squeeze-Extract=tar -C %d -xf %a %F X-Squeeze-Refresh=tar -tvvf %a [application/x-tarz] X-Squeeze-Requires=tar;compress;uncompress X-Squeeze-New=tar -Zcf %a %F -X-Squeeze-Add=lzop -dc %a >> %t;tar -rf %t %F;lzop -c %t >> %a -X-Squeeze-Remove=uncompress -c %a >> %t;tar -f %t --delete %F; compress -c %t >> %a +X-Squeeze-Add=lzop -dc %a > %t;tar -rf %t %F;lzop -c %t > %a +X-Squeeze-Remove=uncompress -c %a > %t;tar -f %t --delete %F; compress -c %t > %a X-Squeeze-Extract=tar -C %d -xf %a %F X-Squeeze-Refresh=tar -tvvf %a [application/x-tzo] X-Squeeze-Requires=tar;lzop X-Squeeze-New=tar -cf --use-compress-program=lzop %a %F -X-Squeeze-Add=uncompress -c %a >> %t;tar -rf %t %F;compress -c %t >> %a -X-Squeeze-Remove=lzop -dc %a >> %t;tar -f %t --delete %F; lzop -c %t >> %a +X-Squeeze-Add=uncompress -c %a > %t;tar -rf %t %F;compress -c %t > %a +X-Squeeze-Remove=lzop -dc %a > %t;tar -f %t --delete %F; lzop -c %t > %a X-Squeeze-Extract=tar -C %d -xf %a %F X-Squeeze-Refresh=tar -tvvf %a Modified: squeeze/trunk/libsqueeze/archive-tempfs.h =================================================================== --- squeeze/trunk/libsqueeze/archive-tempfs.h 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/libsqueeze/archive-tempfs.h 2008-03-01 14:41:50 UTC (rev 26654) @@ -38,3 +38,5 @@ gboolean lsq_tempfs_changed_file(LSQArchive *archive, const gchar *path) G_GNUC_INTERNAL; +gchar *lsq_archive_request_temp_file(LSQArchive *archive, const gchar *suffix); + Modified: squeeze/trunk/libsqueeze/command-queue.c =================================================================== --- squeeze/trunk/libsqueeze/command-queue.c 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/libsqueeze/command-queue.c 2008-03-01 14:41:50 UTC (rev 26654) @@ -21,6 +21,9 @@ #include #include "libsqueeze.h" +#include "archive-tempfs.h" +#include "parser-context.h" +#include "parser.h" #include "command-queue.h" @@ -47,6 +50,20 @@ GObjectClass parent; }; +struct _LSQExecuteContext +{ + LSQCommandEntry *queue; + LSQParser *parser; + LSQArchive *archive; + gchar **files; + gchar *tempfile; + LSQParserContext *ctx; + enum { + LSQ_EXEC_CTX_STATE_RUNNING = 1<<0, + LSQ_EXEC_CTX_STATE_PARSING = 1<<1 + } state; +}; + static void build_queue(LSQCommandQueue *queue, const gchar *commant_string); G_DEFINE_TYPE(LSQCommandQueue, lsq_command_queue, G_TYPE_OBJECT); @@ -65,6 +82,8 @@ { LSQCommandQueue *queue; + g_return_val_if_fail(command_string, NULL); + queue = g_object_new(LSQ_TYPE_COMMAND_QUEUE, NULL); build_queue(queue, command_string); @@ -72,6 +91,247 @@ return LSQ_COMMAND_QUEUE(queue); } +static const gchar *lsq_execute_context_get_temp_file(LSQExecuteContext *ctx) +{ + if(!ctx->tempfile) + { + ctx->tempfile = lsq_archive_request_temp_file(ctx->archive, NULL); + } + + return ctx->tempfile; +} + +static gchar *format_get_filename(const gchar *format, LSQExecuteContext *ctx) +{ + if((format[0] == '%') && (format[2] == '\0')) + { + switch(format[1]) + { + case 'a': + return lsq_archive_get_path(ctx->archive); + case 't': + return g_strdup(lsq_execute_context_get_temp_file(ctx)); + } + } + return NULL; +} + +static gchar **lsq_command_entry_to_argv(LSQCommandEntry *entry, LSQExecuteContext *ctx) +{ + gchar **argv, **argi; + guint size; + GSList *iter; + gchar **filei; + + size = 2; + + for(iter = entry->args; iter; iter = iter->next) + { + if(0==strcmp((const gchar*)iter->data, "%F")) + { + size += g_strv_length(ctx->files); + } + else + size++; + } + + argv = g_new(gchar *, size); + + argi = argv; + + *argi++ = g_strdup(entry->command); + + for(iter = entry->args; iter; iter = iter->next) + { + const gchar *arg = (const gchar*)iter->data; + if((arg[0] == '%') && (arg[2] == '\0')) + { + switch(arg[1]) + { + case 'F': + for(filei = ctx->files; *filei; filei++) + { + *argi++ = g_strdup(*filei); + } + break; + case 'a': + *argi++ = lsq_archive_get_path(ctx->archive); + break; + case 't': + *argi++ = g_strdup(lsq_execute_context_get_temp_file(ctx)); + break; + default: + //... + break; + } + } + else + *argi++ = g_strdup(arg); + } + + *argi = NULL; + + return argv; +} + +static void lsq_command_entry_start(LSQCommandEntry *entry, LSQExecuteContext *ctx); + +static void child_exit(GPid pid, gint status, LSQExecuteContext *ctx) +{ + g_spawn_close_pid(pid); + ctx->state &= ~LSQ_EXEC_CTX_STATE_RUNNING; + if(!ctx->state) + { + if((ctx->queue = ctx->queue->next)) + lsq_command_entry_start(ctx->queue, ctx); + //else + //...//done + } +} + +static void in_channel(GIOChannel *source, GIOCondition condition, GIOChannel *dest) +{ + GIOStatus stat = G_IO_STATUS_NORMAL; + static gchar buffer[1024]; + + if(condition & G_IO_IN) + { + gsize n; + stat = g_io_channel_read_chars(source, buffer, 1024, &n, NULL); + if(stat == G_IO_STATUS_NORMAL) + g_io_channel_write_chars(dest, buffer, n, NULL, NULL); + } + + if(condition & G_IO_HUP || (stat != G_IO_STATUS_NORMAL && stat != G_IO_STATUS_AGAIN)) + { + g_io_channel_unref(source); + g_io_channel_flush(dest, NULL); + g_io_channel_unref(dest); + } +} + +static void out_channel(GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx) +{ + GIOStatus stat = G_IO_STATUS_NORMAL; + static gchar buffer[1024]; + + if(condition & G_IO_IN) + { + gsize n; + stat = g_io_channel_read_chars(source, buffer, 1024, &n, NULL); + //if(stat == G_IO_STATUS_NORMAL) + //g_io_channel_write_chars(dest, buffer, n, NULL, NULL); + } + + if(condition & G_IO_HUP || (stat != G_IO_STATUS_NORMAL && stat != G_IO_STATUS_AGAIN)) + { + g_io_channel_unref(source); + //g_io_channel_flush(dest); + //g_io_channel_unref(dest); + ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING; + if(!ctx->state) + { + if((ctx->queue = ctx->queue->next)) + lsq_command_entry_start(ctx->queue, ctx); + //else + //...//done + } + } +} + +static void parse_channel(GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx) +{ + if(condition & G_IO_IN) + lsq_parser_parse(ctx->parser, ctx->ctx); + if(condition & G_IO_HUP || !lsq_parser_context_is_good(ctx->ctx)) + { + lsq_parser_context_set_channel(ctx->ctx, NULL); + g_io_channel_unref(source); + ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING; + if(!ctx->state) + { + if((ctx->queue = ctx->queue->next)) + lsq_command_entry_start(ctx->queue, ctx); + //else + //...//done + } + } +} + +static void lsq_command_entry_start(LSQCommandEntry *entry, LSQExecuteContext *ctx) +{ + gint fd_in = FALSE; + gint fd_out = TRUE; + GIOChannel *redir_in; + GIOChannel *chan_in; + GIOChannel *redir_out; + GIOChannel *chan_out; + gchar **argv; + GPid pid; + GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL; + if(entry->redirect_out) + { + gchar *file = format_get_filename(entry->redirect_out, ctx); + redir_in = g_io_channel_new_file(file, "w", NULL); + g_free(file); + } + else if(!ctx->ctx) + { + flags |= G_SPAWN_STDOUT_TO_DEV_NULL; + fd_out = FALSE; + } + if(entry->redirect_in) + { + gchar *file = format_get_filename(entry->redirect_in, ctx); + redir_in = g_io_channel_new_file(file, "r", NULL); + g_free(file); + fd_in = TRUE; + } + + argv = lsq_command_entry_to_argv(entry, ctx); + + g_spawn_async_with_pipes(NULL, argv, NULL, flags, NULL, NULL, &pid, fd_in?&fd_in:NULL, fd_out?&fd_out:NULL, NULL, NULL); + + g_child_watch_add(pid, (GChildWatchFunc)child_exit, ctx); + ctx->state |= LSQ_EXEC_CTX_STATE_RUNNING; + + if(entry->redirect_in) + { + chan_in = g_io_channel_unix_new(fd_in); + g_io_add_watch(redir_in, G_IO_IN|G_IO_HUP, (GIOFunc)in_channel, chan_in); + } + if(entry->redirect_out) + { + chan_out = g_io_channel_unix_new(fd_out); + g_io_add_watch(chan_out, G_IO_IN|G_IO_HUP, (GIOFunc)out_channel, ctx); + ctx->state |= LSQ_EXEC_CTX_STATE_PARSING; + } + else if(ctx->ctx) + { + chan_out = g_io_channel_unix_new(fd_out); + lsq_parser_context_set_channel(ctx->ctx, chan_out); + g_io_add_watch(chan_out, G_IO_IN|G_IO_HUP, (GIOFunc)parse_channel, ctx); + ctx->state |= LSQ_EXEC_CTX_STATE_PARSING; + } +} + +LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, LSQParser *parser) +{ + LSQExecuteContext *ctx; + + ctx = g_new(LSQExecuteContext, 1); + + ctx->queue = queue->queue; + ctx->archive = archive; + ctx->files = g_strdupv((gchar**)files); + ctx->parser = parser; + ctx->ctx = parser?lsq_parser_get_context(parser, archive):NULL; + + lsq_command_entry_start(ctx->queue, ctx); + + return ctx; +} + static gchar* strdup_escaped(const gchar *str, guint lng)/*{{{*/ { guint i; Modified: squeeze/trunk/libsqueeze/command-queue.h =================================================================== --- squeeze/trunk/libsqueeze/command-queue.h 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/libsqueeze/command-queue.h 2008-03-01 14:41:50 UTC (rev 26654) @@ -43,16 +43,22 @@ LSQ_TYPE_COMMAND_QUEUE, \ LSQCommandQueueClass)) - +#if 0 typedef struct _LSQCommandQueue LSQCommandQueue; +#endif - typedef struct _LSQCommandQueueClass LSQCommandQueueClass; +typedef struct _LSQExecuteContext LSQExecuteContext; + GType lsq_command_queue_get_type(void); +LSQCommandQueue *lsq_command_queue_new(const gchar *command_string); +LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, LSQParser *parser); + + G_END_DECLS #endif /* __LIBSQUEEZE_COMMAND_QUEUE_H__ */ Modified: squeeze/trunk/libsqueeze/support-reader.c =================================================================== --- squeeze/trunk/libsqueeze/support-reader.c 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/libsqueeze/support-reader.c 2008-03-01 14:41:50 UTC (rev 26654) @@ -32,6 +32,7 @@ #include "parser-context.h" #include "parser.h" #include "scanf-parser.h" +#include "command-queue.h" #include "support-reader.h" #include "internals.h" @@ -182,11 +183,11 @@ s_template->mime_info = thunar_vfs_mime_database_get_info(lsq_mime_database, _mime_types[i]); s_template->id = (const gchar *)factory->id; - s_template->new_cmd_queue = xfce_rc_read_list_entry(rc, "X-Squeeze-New", ";"); - s_template->add_cmd_queue = xfce_rc_read_list_entry(rc, "X-Squeeze-Add", ";"); - s_template->remove_cmd_queue = xfce_rc_read_list_entry(rc, "X-Squeeze-Remove", ";"); - s_template->extract_cmd_queue = xfce_rc_read_list_entry(rc, "X-Squeeze-Extract", ";"); - s_template->refresh_cmd_queue = xfce_rc_read_list_entry(rc, "X-Squeeze-Refresh", ";"); + s_template->new_cmd_queue = lsq_command_queue_new(xfce_rc_read_entry(rc, "X-Squeeze-New", NULL)); + s_template->add_cmd_queue = lsq_command_queue_new(xfce_rc_read_entry(rc, "X-Squeeze-Add", NULL)); + s_template->remove_cmd_queue = lsq_command_queue_new(xfce_rc_read_entry(rc, "X-Squeeze-Remove", NULL)); + s_template->extract_cmd_queue = lsq_command_queue_new(xfce_rc_read_entry(rc, "X-Squeeze-Extract", NULL)); + s_template->refresh_cmd_queue = lsq_command_queue_new(xfce_rc_read_entry(rc, "X-Squeeze-Refresh", NULL)); s_template->n_properties = g_strv_length(column_names); s_template->property_names = column_names; Modified: squeeze/trunk/libsqueeze/support-template.h =================================================================== --- squeeze/trunk/libsqueeze/support-template.h 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/libsqueeze/support-template.h 2008-03-01 14:41:50 UTC (rev 26654) @@ -37,6 +37,9 @@ #ifndef LSQParser typedef struct _LSQParser LSQParser; #endif +#ifndef LSQCommandQueue +typedef struct _LSQCommandQueue LSQCommandQueue; +#endif typedef struct _LSQSupportTemplate LSQSupportTemplate; @@ -51,11 +54,11 @@ gchar **property_names; LSQParser *parser; - gchar **new_cmd_queue; - gchar **add_cmd_queue; - gchar **remove_cmd_queue; - gchar **extract_cmd_queue; - gchar **refresh_cmd_queue; + LSQCommandQueue *new_cmd_queue; + LSQCommandQueue *add_cmd_queue; + LSQCommandQueue *remove_cmd_queue; + LSQCommandQueue *extract_cmd_queue; + LSQCommandQueue *refresh_cmd_queue; LSQSupportType support_mask; }; Modified: squeeze/trunk/src/application.c =================================================================== --- squeeze/trunk/src/application.c 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/src/application.c 2008-03-01 14:41:50 UTC (rev 26654) @@ -178,7 +178,7 @@ } GtkWidget *message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive); gtk_widget_show(message_dialog); - if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT)) + if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, @@ -253,7 +253,7 @@ GtkWidget *message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive); gtk_widget_show(message_dialog); - if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD)) + if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL)) { /* FIXME: show warning dialog */ GtkWidget *warning_dialog = gtk_message_dialog_new(NULL, Modified: squeeze/trunk/src/main_window.c =================================================================== --- squeeze/trunk/src/main_window.c 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/src/main_window.c 2008-03-01 14:41:50 UTC (rev 26654) @@ -821,7 +821,7 @@ lsq_iter_slist_free(filenames); filenames = NULL; } - if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT)) + if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -869,7 +869,7 @@ filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); if(filenames) { - if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD)) + if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -911,7 +911,7 @@ filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); if(filenames) { - if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD)) + if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -945,7 +945,7 @@ gtk_widget_hide(dialog); sq_notebook_get_active_archive(SQ_NOTEBOOK(window->notebook), &lp_archive); /* gtk_tree_view_set_model(sq_notebook_get_active_tree_view(SQ_NOTEBOOK(window->notebook)), NULL); */ - if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_REMOVE)) + if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_REMOVE, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -982,7 +982,7 @@ SQMainWindow *window = SQ_MAIN_WINDOW(userdata); SQArchiveStore *store = sq_notebook_get_active_store(SQ_NOTEBOOK(window->notebook)); LSQArchive *archive = sq_archive_store_get_archive(store); - lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH); + lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL); } static void @@ -1232,7 +1232,7 @@ { case GTK_RESPONSE_OK: /* VIEW */ sq_notebook_get_active_archive(SQ_NOTEBOOK(notebook), &lp_archive); - if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_OPEN)) + if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_OPEN, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, _("Squeeze cannot view this file.\nthe application to support this is missing.")); if(warning_dialog) @@ -1255,7 +1255,7 @@ g_slist_free(files); files = NULL; } - if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT)) + if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL)) { GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, Modified: squeeze/trunk/src/notebook.c =================================================================== --- squeeze/trunk/src/notebook.c 2008-03-01 13:16:37 UTC (rev 26653) +++ squeeze/trunk/src/notebook.c 2008-03-01 14:41:50 UTC (rev 26654) @@ -574,7 +574,7 @@ if(new_archive == FALSE) { - lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH); + lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL); } } From juha at xfce.org Sun Mar 2 11:37:59 2008 From: juha at xfce.org (Juha Kautto) Date: Sun, 2 Mar 2008 10:37:59 +0000 (UTC) Subject: [Xfce4-commits] r26655 - xfcalendar/trunk/po Message-ID: <20080302103759.67591F29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-02 10:37:59 +0000 (Sun, 02 Mar 2008) New Revision: 26655 Modified: xfcalendar/trunk/po/de.po Log: 1) fixed bug 3894 - typo in orage de translation There were more similar errors; I fixed them all. Modified: xfcalendar/trunk/po/de.po =================================================================== --- xfcalendar/trunk/po/de.po 2008-03-01 14:41:50 UTC (rev 26654) +++ xfcalendar/trunk/po/de.po 2008-03-02 10:37:59 UTC (rev 26655) @@ -431,7 +431,7 @@ #. the button label in the xfce-mcs-manager dialog #: ../plugin/xfcalendar_plugin.c:47 msgid "Orage - Calendar" -msgstr "Orange-Kalender" +msgstr "Orage-Kalender" #: ../src/about-xfcalendar.c:42 msgid "Manage your time with Xfce4" @@ -987,7 +987,7 @@ #: ../src/day-view.c:853 msgid "Orage - day view" -msgstr "Orange - Tagesansicht" +msgstr "Orage - Tagesansicht" #. date only appointment #: ../src/event-list.c:175 @@ -2799,7 +2799,7 @@ #: ../src/interface.c:1063 msgid "Orage appointment UIDs separated by commas." -msgstr "Orange-Termin-UIDs durch Kommas getrennt." +msgstr "Orage-Termin-UIDs durch Kommas getrennt." #: ../src/interface.c:1069 msgid "Archive" @@ -2825,7 +2825,7 @@ "appointments to another system." msgstr "" "Alle archivierten Termine in die Haupt-Oragedatei kopieren und das Archiv\n" -"entfernen. Dies ist n?tzlich, wenn z. B. Orange-Termine auf ein anderes\n" +"entfernen. Dies ist n?tzlich, wenn z. B. Orage-Termine auf ein anderes\n" "System kopiert werden sollen." #: ../src/interface.c:1110 From nick at xfce.org Sun Mar 2 14:51:40 2008 From: nick at xfce.org (Nick Schermer) Date: Sun, 2 Mar 2008 13:51:40 +0000 (UTC) Subject: [Xfce4-commits] r26656 - in mousepad/branches/nick_0_3: . mousepad Message-ID: <20080302135140.C9F73F29D8@mocha.foo-projects.org> Author: nick Date: 2008-03-02 13:51:40 +0000 (Sun, 02 Mar 2008) New Revision: 26656 Modified: mousepad/branches/nick_0_3/ChangeLog mousepad/branches/nick_0_3/mousepad/mousepad-document.c mousepad/branches/nick_0_3/mousepad/mousepad-file.c Log: * mousepad/mousepad-file.c: Don't set an error and return false on externally modified when the file does not exist. This fixes an error when saving a new file. * mousepad/mousepad-file.c: Emit signal when the readonly status changes. * mousepad/mousepad-document.c: Use the readonly signal to update the label color. This fixes a readonly-colored label when saving a new file. Modified: mousepad/branches/nick_0_3/ChangeLog =================================================================== --- mousepad/branches/nick_0_3/ChangeLog 2008-03-02 10:37:59 UTC (rev 26655) +++ mousepad/branches/nick_0_3/ChangeLog 2008-03-02 13:51:40 UTC (rev 26656) @@ -1,3 +1,15 @@ +2008-03-02 Nick Schermer + + * mousepad/mousepad-file.c: Don't set an error and return false on + externally modified when the file does not exist. This fixes + an error when saving a new file. + * mousepad/mousepad-file.c: Emit signal when the readonly status + changes. + * mousepad/mousepad-document.c: Use the readonly signal to update + the label color. This fixes a readonly-colored label when saving + a new file. + + 2008-02-17 Nick Schermer * mousepad/mousepad-search-bar.c: Select the text in the search Modified: mousepad/branches/nick_0_3/mousepad/mousepad-document.c =================================================================== --- mousepad/branches/nick_0_3/mousepad/mousepad-document.c 2008-03-02 10:37:59 UTC (rev 26655) +++ mousepad/branches/nick_0_3/mousepad/mousepad-document.c 2008-03-02 13:51:40 UTC (rev 26656) @@ -242,6 +242,7 @@ g_signal_connect (G_OBJECT (document->buffer), "notify::cursor-position", G_CALLBACK (mousepad_document_notify_cursor_position), document); g_signal_connect (G_OBJECT (document->buffer), "notify::has-selection", G_CALLBACK (mousepad_document_notify_has_selection), document); g_signal_connect_swapped (G_OBJECT (document->buffer), "modified-changed", G_CALLBACK (mousepad_document_label_color), document); + g_signal_connect_swapped (G_OBJECT (document->file), "readonly-changed", G_CALLBACK (mousepad_document_label_color), document); g_signal_connect (G_OBJECT (document->textview), "notify::overwrite", G_CALLBACK (mousepad_document_notify_overwrite), document); g_signal_connect (G_OBJECT (document->textview), "drag-data-received", G_CALLBACK (mousepad_document_drag_data_received), document); } @@ -415,9 +416,9 @@ static void mousepad_document_label_color (MousepadDocument *document) { - const GdkColor green = {0, 0x0000, 0x9999, 0x0000}; - const GdkColor red = {0, 0xffff, 0x0000, 0x0000}; - gboolean readonly, modified; + GdkColor green = {0, 0x0000, 0x9999, 0x0000}; + GdkColor red = {0, 0xffff, 0x0000, 0x0000}; + GdkColor *color; _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document)); _mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (document->buffer)); @@ -425,13 +426,17 @@ if (document->priv->label) { - /* get states */ - readonly = mousepad_file_get_read_only (document->file); - modified = gtk_text_buffer_get_modified (document->buffer); - + /* label color */ + if (gtk_text_buffer_get_modified (document->buffer)) + color = &green; + else if (mousepad_file_get_read_only (document->file)) + color = &red; + else + color = NULL; + /* update colors */ - gtk_widget_modify_fg (document->priv->label, GTK_STATE_NORMAL, modified ? &red : (readonly ? &green : NULL)); - gtk_widget_modify_fg (document->priv->label, GTK_STATE_ACTIVE, modified ? &red : (readonly ? &green : NULL)); + gtk_widget_modify_fg (document->priv->label, GTK_STATE_NORMAL, color); + gtk_widget_modify_fg (document->priv->label, GTK_STATE_ACTIVE, color); } } Modified: mousepad/branches/nick_0_3/mousepad/mousepad-file.c =================================================================== --- mousepad/branches/nick_0_3/mousepad/mousepad-file.c 2008-03-02 10:37:59 UTC (rev 26655) +++ mousepad/branches/nick_0_3/mousepad/mousepad-file.c 2008-03-02 13:51:40 UTC (rev 26656) @@ -25,6 +25,9 @@ #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_ERRNO_H +#include +#endif #include #include @@ -41,6 +44,7 @@ { /* EXTERNALLY_MODIFIED, */ FILENAME_CHANGED, + READONLY_CHANGED, LAST_SIGNAL }; @@ -77,6 +81,8 @@ static void mousepad_file_class_init (MousepadFileClass *klass); static void mousepad_file_init (MousepadFile *file); static void mousepad_file_finalize (GObject *object); +static void mousepad_file_set_readonly (MousepadFile *file, + gboolean readonly); @@ -107,6 +113,14 @@ G_TYPE_NONE, 1, G_TYPE_BOOLEAN); #endif + file_signals[READONLY_CHANGED] = + g_signal_new (I_("readonly-changed"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + file_signals[FILENAME_CHANGED] = g_signal_new (I_("filename-changed"), G_TYPE_FROM_CLASS (gobject_class), @@ -148,6 +162,24 @@ +static void +mousepad_file_set_readonly (MousepadFile *file, + gboolean readonly) +{ + _mousepad_return_if_fail (MOUSEPAD_IS_FILE (file)); + + if (G_LIKELY (file->readonly != readonly)) + { + /* store new value */ + file->readonly = readonly; + + /* emit signal */ + g_signal_emit (G_OBJECT (file), file_signals[READONLY_CHANGED], 0, readonly); + } +} + + + MousepadFile * mousepad_file_new (GtkTextBuffer *buffer) { @@ -280,7 +312,8 @@ /* check if the file exists, if not, it's a filename from the command line */ if (g_file_test (file->filename, G_FILE_TEST_EXISTS) == FALSE) { - file->readonly = FALSE; + /* update readonly status */ + mousepad_file_set_readonly (file, FALSE); return TRUE; } @@ -373,7 +406,7 @@ if (G_LIKELY (g_lstat (file->filename, &statb) == 0)); { /* store the readonly mode */ - file->readonly = !((statb.st_mode & S_IWUSR) != 0); + mousepad_file_set_readonly (file, !((statb.st_mode & S_IWUSR) != 0)); /* store the file modification time */ file->mtime = statb.st_mtime; @@ -494,7 +527,7 @@ gtk_text_buffer_set_modified (file->buffer, FALSE); /* we saved succesfully */ - file->readonly = FALSE; + mousepad_file_set_readonly (file, FALSE); failed: @@ -549,25 +582,28 @@ GError **error) { struct stat statb; - gboolean modified = TRUE; + GFileError error_code; - _mousepad_return_val_if_fail (MOUSEPAD_IS_FILE (file), FALSE); - _mousepad_return_val_if_fail (file->filename != NULL, FALSE); + _mousepad_return_val_if_fail (MOUSEPAD_IS_FILE (file), TRUE); + _mousepad_return_val_if_fail (file->filename != NULL, TRUE); _mousepad_return_val_if_fail (error == NULL || *error == NULL, FALSE); + /* check if our modification time differs from the current one */ if (G_LIKELY (g_lstat (file->filename, &statb) == 0)) - { - /* check if our modification time differs from the current one */ - modified = (file->mtime > 0 && statb.st_mtime != file->mtime); - } - else if (error != NULL) - { - /* failed to stat the file */ - g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, - _("Failed to read the status of \"%s\""), file->filename); - } + return (file->mtime > 0 && statb.st_mtime != file->mtime); + + /* get the error code */ + error_code = g_file_error_from_errno (errno); + + /* file does not exists, nothing wrong with that */ + if (G_LIKELY (error_code == G_FILE_ERROR_NOENT)) + return FALSE; - return modified; + /* set an error */ + if (error != NULL) + g_set_error (error, G_FILE_ERROR, error_code, _("Failed to read the status of \"%s\""), file->filename); + + return TRUE; } From juha at xfce.org Mon Mar 3 00:25:53 2008 From: juha at xfce.org (Juha Kautto) Date: Sun, 2 Mar 2008 23:25:53 +0000 (UTC) Subject: [Xfce4-commits] r26657 - in xfcalendar/trunk: . src Message-ID: <20080302232553.40925F29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-02 23:25:52 +0000 (Sun, 02 Mar 2008) New Revision: 26657 Modified: xfcalendar/trunk/configure.in.in xfcalendar/trunk/src/appointment.c xfcalendar/trunk/src/ical-code.c Log: 1) fixed Bug 3885 - add support for evolution ics files 2) Fixed categories handling issue when having only the special colour category. It caused an empty gategory added. version 4.5.13.1 Modified: xfcalendar/trunk/configure.in.in =================================================================== --- xfcalendar/trunk/configure.in.in 2008-03-02 13:51:40 UTC (rev 26656) +++ xfcalendar/trunk/configure.in.in 2008-03-02 23:25:52 UTC (rev 26657) @@ -9,7 +9,7 @@ dnl dnl Version information -m4_define([orage_version], [4.5.13.0-svn]) +m4_define([orage_version], [4.5.13.1-svn]) m4_define([gtk_minimum_version], [2.6.0]) m4_define([xfce_minimum_version], [4.4.0]) Modified: xfcalendar/trunk/src/appointment.c =================================================================== --- xfcalendar/trunk/src/appointment.c 2008-03-02 13:51:40 UTC (rev 26656) +++ xfcalendar/trunk/src/appointment.c 2008-03-02 23:25:52 UTC (rev 26657) @@ -891,12 +891,12 @@ g_free(tmp2); tmp2 = NULL; } - if (tmp) { + if (ORAGE_STR_EXISTS(tmp)) { appt->categories = g_strjoin(",", tmp, tmp2, NULL); g_free(tmp); g_free(tmp2); } - else + else appt->categories = tmp2; /* notes */ Modified: xfcalendar/trunk/src/ical-code.c =================================================================== --- xfcalendar/trunk/src/ical-code.c 2008-03-02 13:51:40 UTC (rev 26656) +++ xfcalendar/trunk/src/ical-code.c 2008-03-02 23:25:52 UTC (rev 26657) @@ -543,7 +543,7 @@ utc_icaltimezone = icaltimezone_get_utc_timezone(); if (!ORAGE_STR_EXISTS(g_par.local_timezone)) { - orage_message(150, P_N "empty timezone\n"); + orage_message(150, P_N "empty timezone"); g_par.local_timezone = g_strdup("floating"); } @@ -643,10 +643,10 @@ } if ((*p_fical = icalset_new_file(file_icalpath)) == NULL) { if (test) - orage_message(150, P_N "Could not open ical file (%s) %s\n" + orage_message(150, P_N "Could not open ical file (%s) %s" , file_icalpath, icalerror_strerror(icalerrno)); else - orage_message(350, P_N "Could not open ical file (%s) %s\n" + orage_message(350, P_N "Could not open ical file (%s) %s" , file_icalpath, icalerror_strerror(icalerrno)); return(FALSE); } @@ -894,6 +894,27 @@ return(ctime); } +static icaltimezone *get_builtin_timezone(gchar *tz_loc) +{ + /* This probably is evolution format, + * which has /xxx/xxx/timezone and we should remove the + * extra /xxx/xxx/ from it */ + char **new_str; + icaltimezone *l_icaltimezone = NULL; + + if (tz_loc[0] == '/') { + orage_message(-20, P_N "evolution timezone fix %s", tz_loc); + new_str = g_strsplit(tz_loc, "/", 4); + if (new_str[0] != NULL && new_str[1] != NULL && new_str[2] != NULL + && new_str[3] != NULL) + l_icaltimezone = icaltimezone_get_builtin_timezone(new_str[3]); + g_strfreev(new_str); + } + else + l_icaltimezone = icaltimezone_get_builtin_timezone(tz_loc); + return(l_icaltimezone); +} + static struct icaltimetype convert_to_timezone(struct icaltimetype t , icalproperty *p) { @@ -910,22 +931,9 @@ itime_tz = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER); if (itime_tz) { tz_loc = (char *)icalparameter_get_tzid(itime_tz); - if (tz_loc[0] == '/') { - /* FIXME: this should be in import and in get data - * This probably is evolution format, - * which has /xxx/xxx/timezone and we should remove the - * extra /xxx/xxx/ from it */ - char **new_str; - - orage_message(-20, P_N "evolution timezone fix %s", tz_loc); - new_str = g_strsplit(tz_loc, "/", 4); - if (new_str[0] != NULL && new_str[1] != NULL && new_str[2] != NULL - && new_str[3] != NULL) - l_icaltimezone = icaltimezone_get_builtin_timezone(new_str[3]); - g_strfreev(new_str); - } - else - l_icaltimezone = icaltimezone_get_builtin_timezone(tz_loc); + /* FIXME: could we now call convert_to_zone or is it a problem + * if we always move to zone format ? */ + l_icaltimezone = get_builtin_timezone(tz_loc); if (!l_icaltimezone) { orage_message(250, P_N "builtin timezone %s not found, conversion failed.", tz_loc); } @@ -986,8 +994,9 @@ p = icalcomponent_get_first_property(c, ICAL_DUE_PROPERTY); p2 = icalcomponent_get_first_property(c, ICAL_COMPLETED_PROPERTY); } - else if (per.ikind == ICAL_VJOURNAL_COMPONENT) - p = NULL; /* does not exist for journal */ + else if (per.ikind == ICAL_VJOURNAL_COMPONENT + || per.ikind == ICAL_VTIMEZONE_COMPONENT) + p = NULL; /* does not exist for journal and timezone */ else { orage_message(150, P_N "unknown component type (%s)", icalcomponent_get_uid(c)); p = NULL; @@ -1030,7 +1039,7 @@ else per.ctime = icaltime_null_time(); - return (per); + return(per); } /* basically copied from icaltime_compare, which can't be used @@ -1145,7 +1154,7 @@ wtime = icaltime_convert_to_zone(t, local_icaltimezone); } else { - l_icaltimezone = icaltimezone_get_builtin_timezone(tz); + l_icaltimezone = get_builtin_timezone(tz); if (!l_icaltimezone) orage_message(250, P_N "builtin timezone %s not found, conversion failed.", tz); else @@ -2397,6 +2406,7 @@ case ICAL_DTSTAMP_PROPERTY: case ICAL_CREATED_PROPERTY: case ICAL_LASTMODIFIED_PROPERTY: + case ICAL_SEQUENCE_PROPERTY: break; default: orage_message(55, P_N "unknown property %s" @@ -2620,7 +2630,7 @@ c != 0 && !key_found; c = icalcomponent_get_next_component(base, ICAL_ANY_COMPONENT)) { uid = (char *)icalcomponent_get_uid(c); - if (strcmp(uid, int_uid) == 0) { + if (ORAGE_STR_EXISTS(uid) && (strcmp(uid, int_uid) == 0)) { if ((p = icalcomponent_get_first_property(c, ICAL_CREATED_PROPERTY))) create_time = icalproperty_get_created(p); @@ -3787,7 +3797,7 @@ if ((uid = (char *)icalcomponent_get_uid(ca)) == NULL) { uid = generate_uid(); icalcomponent_add_property(ca, icalproperty_new_uid(uid)); - orage_message(15, "Generated UID %s\n", uid); + orage_message(15, "Generated UID %s", uid); g_free(uid); } @@ -3811,7 +3821,7 @@ #undef P_N #define P_N "pre_format: " gchar *text, *tmp, *tmp2, *tmp3; - gsize text_len; + gsize text_len, i; GError *error = NULL; #ifdef ORAGE_DEBUG @@ -3824,7 +3834,7 @@ g_error_free(error); return(FALSE); } - /* Then convert to utf8 if needed */ + /***** Check utf8 coformtability *****/ if (!g_utf8_validate(text, -1, NULL)) { orage_message(250, P_N "is not in utf8 format. Conversion needed.\n (Use iconv and convert it into UTF-8 and import it again.)\n"); return(FALSE); @@ -3836,10 +3846,10 @@ }*/ } - /* 1: change DCREATED to CREATED */ - for (tmp = g_strrstr(text, "DCREATED:"); + /***** 1: change DCREATED to CREATED *****/ + for (tmp = g_strstr_len(text, text_len, "DCREATED:"); tmp != NULL; - tmp = g_strrstr(text, "DCREATED:")) { + tmp = g_strstr_len(tmp, strlen(tmp), "DCREATED:")) { tmp2 = tmp+strlen("DCREATED:yyyymmddThhmmss"); if (*tmp2 == 'Z') { /* it is already in UTC, so just fix the parameter name */ @@ -3852,11 +3862,49 @@ } *(tmp3-1) = 'Z'; /* this is 'bad'...but who cares...it is fast */ } - tmp3 = g_strndup(tmp, tmp2-tmp); - orage_message(15, _("... Patched DCREATED to be CREATED (%s)"), tmp3); - g_free(tmp3); + orage_message(15, _("... Patched DCREATED to be CREATED.")); } - /* write file */ + + /***** 2: change absolute timezones into libical format *****/ + /* At least evolution uses absolute timezones. + * We assume format has /xxx/xxx/timezone and we should remove the + * extra /xxx/xxx/ from it */ + for (tmp = g_strstr_len(text, text_len, ";TZID=/"); + tmp != NULL; + tmp = g_strstr_len(tmp, strlen(tmp), ";TZID=/")) { + /* tmp = original TZID start + * tmp2 = end of line + * tmp3 = current search and eventually the real tzid */ + tmp = tmp+6; /* 6 = skip ";TZID=" */ + if (!(tmp2 = g_strstr_len(tmp, 100, "\n"))) { /* no end of line */ + orage_message(150, P_N "timezone patch failed 1. no end-of-line found: %s", tmp); + continue; + } + tmp3 = tmp; + + tmp3++; /* skip '/' */ + if (!(tmp3 = g_strstr_len(tmp3, tmp2-tmp3, "/"))) { /* no more '/' */ + orage_message(150, P_N "timezone patch failed 2. no / found: %s", tmp); + continue; + } + tmp3++; /* skip '/' */ + if (!(tmp3 = g_strstr_len(tmp3, tmp2-tmp3, "/"))) { /* no more '/' */ + orage_message(150, P_N "timezone patch failed 3. no / found: %s", tmp); + continue; + } + + /* we found the real tzid since we came here */ + tmp3++; /* skip '/' */ + /* move the real tzid (=tmp3) to the beginning (=tmp) */ + for (; tmp3 < tmp2; tmp3++, tmp++) + *tmp = *tmp3; + /* fill the end of the line with spaces */ + for (; tmp < tmp2; tmp++) + *tmp = ' '; + orage_message(15, _("... Patched timezone to Orage format.")); + } + + /***** All done: write file *****/ if (!g_file_set_contents(file_name_out, text, -1, NULL)) { orage_message(250, P_N "Could not write ical file (%s)", file_name_out); return(FALSE); @@ -3883,7 +3931,7 @@ return(FALSE); } if ((file_ical = icalset_new_file(ical_file_name)) == NULL) { - orage_message(250, P_N "Could not open ical file (%s) %s\n" + orage_message(250, P_N "Could not open ical file (%s) %s" , ical_file_name, icalerror_strerror(icalerrno)); return(FALSE); } @@ -3901,7 +3949,9 @@ cnt2++; add_event(c2); } - else + /* we ignore TIMEZONE component; Orage only uses internal + * timezones from libical */ + else if (icalcomponent_isa(c2) != ICAL_VTIMEZONE_COMPONENT) orage_message(140, P_N "unknown component %s %s" , icalcomponent_kind_to_string( icalcomponent_isa(c2)) @@ -4060,7 +4110,7 @@ } else { - orage_message(250, P_N "Unknown uid type %s\n", uid); + orage_message(250, P_N "Unknown uid type %s", uid); } if (uid_end != NULL) /* we have more uids */ From juha at xfce.org Mon Mar 3 00:36:26 2008 From: juha at xfce.org (Juha Kautto) Date: Sun, 2 Mar 2008 23:36:26 +0000 (UTC) Subject: [Xfce4-commits] r26658 - xfcalendar/trunk/src Message-ID: <20080302233626.A835FF29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-02 23:36:26 +0000 (Sun, 02 Mar 2008) New Revision: 26658 Modified: xfcalendar/trunk/src/appointment.c xfcalendar/trunk/src/event-list.c Log: 1) fixed Bug 3904 - Button layout in confirmation dialog swapped Modified: xfcalendar/trunk/src/appointment.c =================================================================== --- xfcalendar/trunk/src/appointment.c 2008-03-02 23:25:52 UTC (rev 26657) +++ xfcalendar/trunk/src/appointment.c 2008-03-02 23:36:26 UTC (rev 26658) @@ -722,8 +722,8 @@ , GTK_STOCK_DIALOG_WARNING , _("The appointment information has been modified.") , _("Do you want to continue?") + , GTK_STOCK_NO, GTK_RESPONSE_CANCEL , GTK_STOCK_YES, GTK_RESPONSE_ACCEPT - , GTK_STOCK_NO, GTK_RESPONSE_CANCEL , NULL); if (result == GTK_RESPONSE_ACCEPT) { @@ -1145,8 +1145,8 @@ , GTK_STOCK_DIALOG_WARNING , _("This appointment will be permanently removed.") , _("Do you want to continue?") + , GTK_STOCK_NO, GTK_RESPONSE_REJECT , GTK_STOCK_YES, GTK_RESPONSE_ACCEPT - , GTK_STOCK_NO, GTK_RESPONSE_REJECT , NULL); if (result == GTK_RESPONSE_ACCEPT) { Modified: xfcalendar/trunk/src/event-list.c =================================================================== --- xfcalendar/trunk/src/event-list.c 2008-03-02 23:25:52 UTC (rev 26657) +++ xfcalendar/trunk/src/event-list.c 2008-03-02 23:36:26 UTC (rev 26658) @@ -881,8 +881,8 @@ , GTK_STOCK_DIALOG_WARNING , _("You will permanently remove all\nselected appointments.") , _("Do you want to continue?") + , GTK_STOCK_NO, GTK_RESPONSE_CANCEL , GTK_STOCK_YES, GTK_RESPONSE_ACCEPT - , GTK_STOCK_NO, GTK_RESPONSE_CANCEL , NULL); if (result == GTK_RESPONSE_ACCEPT) { From juha at xfce.org Tue Mar 4 00:33:14 2008 From: juha at xfce.org (Juha Kautto) Date: Mon, 3 Mar 2008 23:33:14 +0000 (UTC) Subject: [Xfce4-commits] r26659 - in xfcalendar/trunk: . po src Message-ID: <20080303233314.EEDBEF29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-03 23:33:14 +0000 (Mon, 03 Mar 2008) New Revision: 26659 Modified: xfcalendar/trunk/configure.in.in xfcalendar/trunk/po/fi.po xfcalendar/trunk/src/mainbox.c xfcalendar/trunk/src/mainbox.h xfcalendar/trunk/src/parameters.c xfcalendar/trunk/src/parameters.h Log: 1) fixed typo in Finnish translation 2) implemented Enhancement Bug 3900 - Add list of today's events in the mainbox version 4.5.13.2 Modified: xfcalendar/trunk/configure.in.in =================================================================== --- xfcalendar/trunk/configure.in.in 2008-03-02 23:36:26 UTC (rev 26658) +++ xfcalendar/trunk/configure.in.in 2008-03-03 23:33:14 UTC (rev 26659) @@ -9,7 +9,7 @@ dnl dnl Version information -m4_define([orage_version], [4.5.13.1-svn]) +m4_define([orage_version], [4.5.13.2-svn]) m4_define([gtk_minimum_version], [2.6.0]) m4_define([xfce_minimum_version], [4.4.0]) Modified: xfcalendar/trunk/po/fi.po =================================================================== --- xfcalendar/trunk/po/fi.po 2008-03-02 23:36:26 UTC (rev 26658) +++ xfcalendar/trunk/po/fi.po 2008-03-03 23:33:14 UTC (rev 26659) @@ -3053,8 +3053,8 @@ "%s" msgstr "" "Otsikko: %s\n" -" Alkaa:\t%s\n" -" M?r?aika:\t%s\n" +" Alkaa:\t %s\n" +" M??r?aika:%s\n" " Tehty:\t%s\n" "Huomautukset:\n" "%s" Modified: xfcalendar/trunk/src/mainbox.c =================================================================== --- xfcalendar/trunk/src/mainbox.c 2008-03-02 23:36:26 UTC (rev 26658) +++ xfcalendar/trunk/src/mainbox.c 2008-03-03 23:33:14 UTC (rev 26659) @@ -210,6 +210,26 @@ create_el_win(NULL); } +void orage_show_events_for_selected_date(void) +{ + /* rebuild the info for the selected date */ + if (!xfical_file_open(TRUE)) + return; + build_mainbox_info(); + xfical_file_close(TRUE); +} + +static void mCalendar_day_selected_cb(GtkCalendar *calendar + , gpointer user_data) +{ +#undef P_N +#define P_N "mCalendar_day_selected_cb: " +#ifdef ORAGE_DEBUG + orage_message(-100, P_N); +#endif + orage_show_events_for_selected_date(); +} + static gboolean upd_calendar(GtkCalendar *calendar) { #undef P_N @@ -349,13 +369,13 @@ } } -static void add_info_row(xfical_appt *appt) +static void add_info_row(xfical_appt *appt, GtkBox *parentBox, gboolean todo) { #undef P_N #define P_N "add_info_row: " GtkWidget *ev, *label; CalWin *cal = g_par.xfcal; - gchar *tip; + gchar *tip, *tmp; struct tm *t; char *l_time, *s_time, *e_time, *c_time, *na; gint len; @@ -363,38 +383,54 @@ #ifdef ORAGE_DEBUG orage_message(-100, P_N); #endif + /***** add data into the vbox *****/ ev = gtk_event_box_new(); - label = gtk_label_new(appt->title); + tmp = g_strdup_printf(" %s", appt->title); + label = gtk_label_new(tmp); + g_free(tmp); gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END); - t = orage_localtime(); - l_time = orage_tm_time_to_icaltime(t); - if (appt->starttimecur[8] == 'T') /* date+time */ - len = 15; - else /* date only */ - len = 8; - if (strncmp(appt->endtimecur, l_time, len) < 0) /* gone */ - gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &cal->mRed); - else if (strncmp(appt->starttimecur, l_time, len) <= 0 - && strncmp(appt->endtimecur, l_time, len) >= 0) - gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &cal->mBlue); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_misc_set_padding(GTK_MISC(label), 5, 0); gtk_container_add(GTK_CONTAINER(ev), label); - gtk_box_pack_start(GTK_BOX(cal->mInfo_vbox), ev, FALSE, FALSE, 0); - na = _("Not defined"); + gtk_box_pack_start(parentBox, ev, FALSE, FALSE, 0); + g_object_set_data_full(G_OBJECT(ev), "UID", g_strdup(appt->uid), g_free); + g_signal_connect((gpointer)ev, "button-press-event" + , G_CALLBACK(todo_clicked), cal); + + /***** set color *****/ + if (todo) { + t = orage_localtime(); + l_time = orage_tm_time_to_icaltime(t); + if (appt->starttimecur[8] == 'T') /* date+time */ + len = 15; + else /* date only */ + len = 8; + if (strncmp(appt->endtimecur, l_time, len) < 0) /* gone */ + gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &cal->mRed); + else if (strncmp(appt->starttimecur, l_time, len) <= 0 + && strncmp(appt->endtimecur, l_time, len) >= 0) + gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &cal->mBlue); + } + + /***** set hint *****/ s_time = g_strdup(orage_icaltime_to_i18_time(appt->starttimecur)); e_time = g_strdup(orage_icaltime_to_i18_time(appt->endtimecur)); - c_time = g_strdup(appt->completed - ? orage_icaltime_to_i18_time(appt->completedtime) : na); - tip = g_strdup_printf(_("Title: %s\n Start:\t%s\n Due:\t%s\n Done:\t%s\nNote:\n%s") - , appt->title, s_time, e_time, c_time, appt->note); + if (todo) { + na = _("Never"); + c_time = g_strdup(appt->completed + ? orage_icaltime_to_i18_time(appt->completedtime) : na); + tip = g_strdup_printf(_("Title: %s\n Start:\t%s\n Due:\t%s\n Done:\t%s\nNote:\n%s") + , appt->title, s_time, e_time, c_time, appt->note); + g_free(c_time); + } + else { /* it is event */ + tip = g_strdup_printf(_("Title: %s\n Start:\t%s\n End:\t%s\n Note:\n%s") + , appt->title, s_time, e_time, appt->note); + } gtk_tooltips_set_tip(cal->Tooltips, ev, tip, NULL); g_free(s_time); g_free(e_time); - g_free(c_time); g_free(tip); - g_object_set_data_full(G_OBJECT(ev), "UID", g_strdup(appt->uid), g_free); - g_signal_connect((gpointer)ev, "button-press-event" - , G_CALLBACK(todo_clicked), cal); - } static void insert_rows(GList **todo_list, char *a_day, xfical_type ical_type @@ -416,10 +452,10 @@ } } -static gint todo_order(gconstpointer a, gconstpointer b) +static gint list_order(gconstpointer a, gconstpointer b) { #undef P_N -#define P_N "todo_order: " +#define P_N "list_order: " xfical_appt *appt1, *appt2; #ifdef ORAGE_DEBUG @@ -431,39 +467,92 @@ return(strcmp(appt1->starttimecur, appt2->starttimecur)); } -static void todo_process(gpointer a, gpointer dummy) +static void info_process(gpointer a, gpointer pbox) { #undef P_N -#define P_N "todo_process: " - xfical_appt *appt; +#define P_N "info_process: " + xfical_appt *appt = (xfical_appt *)a;; + GtkBox *box = GTK_BOX(pbox); + CalWin *cal = g_par.xfcal; + gboolean todo; #ifdef ORAGE_DEBUG orage_message(-100, P_N); #endif - appt = (xfical_appt *)a; - add_info_row(appt); + if (pbox == cal->mTodo_rows_vbox) + todo = TRUE; + else + todo = FALSE; + add_info_row(appt, box, todo); xfical_appt_free(appt); } -void create_mainbox_info(void) +void create_mainbox_todo_info(void) { #undef P_N -#define P_N "create_mainbox_info: " +#define P_N "create_mainbox_todo_info: " CalWin *cal = g_par.xfcal; #ifdef ORAGE_DEBUG orage_message(-100, P_N); #endif - cal->mInfo_scrolledWin = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cal->mInfo_scrolledWin) + cal->mTodo_vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(cal->mVbox), cal->mTodo_vbox, FALSE, FALSE, 0); + cal->mTodo_label = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(cal->mTodo_label), _("To do:")); + gtk_box_pack_start(GTK_BOX(cal->mTodo_vbox), cal->mTodo_label + , FALSE, FALSE, 0); + gtk_misc_set_alignment(GTK_MISC(cal->mTodo_label), 0, 0.5); + cal->mTodo_scrolledWin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cal->mTodo_scrolledWin) , GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(cal->mVbox), cal->mInfo_scrolledWin + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW( + cal->mTodo_scrolledWin), GTK_SHADOW_NONE); + gtk_box_pack_start(GTK_BOX(cal->mTodo_vbox), cal->mTodo_scrolledWin + , TRUE, TRUE, 0); + cal->mTodo_rows_vbox = gtk_vbox_new(FALSE, 0); + gtk_scrolled_window_add_with_viewport( + GTK_SCROLLED_WINDOW(cal->mTodo_scrolledWin), cal->mTodo_rows_vbox); +} + +void create_mainbox_event_info(void) +{ +#undef P_N +#define P_N "create_mainbox_event_info: " + CalWin *cal = g_par.xfcal; + gchar *tmp; + +#ifdef ORAGE_DEBUG + orage_message(-100, P_N); +#endif + cal->mEvent_vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(cal->mVbox), cal->mEvent_vbox, FALSE, FALSE, 0); + cal->mEvent_label = gtk_label_new(NULL); + tmp = g_strdup_printf(_("Events for %s:") + , orage_cal_to_i18_date(GTK_CALENDAR(cal->mCalendar))); + gtk_label_set_markup(GTK_LABEL(cal->mEvent_label), tmp); + g_free(tmp); + + gtk_box_pack_start(GTK_BOX(cal->mEvent_vbox), cal->mEvent_label , FALSE, FALSE, 0); - cal->mInfo_vbox = gtk_vbox_new(FALSE, 0); + gtk_misc_set_alignment(GTK_MISC(cal->mEvent_label), 0, 0.5); + cal->mEvent_scrolledWin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cal->mEvent_scrolledWin) + , GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW( + cal->mEvent_scrolledWin), GTK_SHADOW_NONE); + gtk_box_pack_start(GTK_BOX(cal->mEvent_vbox), cal->mEvent_scrolledWin + , TRUE, TRUE, 0); + cal->mEvent_rows_vbox = gtk_vbox_new(FALSE, 0); gtk_scrolled_window_add_with_viewport( - GTK_SCROLLED_WINDOW(cal->mInfo_scrolledWin), cal->mInfo_vbox); + GTK_SCROLLED_WINDOW(cal->mEvent_scrolledWin), cal->mEvent_rows_vbox); } +/********************************************************************** + * This routine is called from ical-code xfical_alarm_build_list_internal + * and ical files are already open at that time. So make sure ical files + * are opened before and closed after this call. + **********************************************************************/ void build_mainbox_info(void) { #undef P_N @@ -471,51 +560,75 @@ CalWin *cal = g_par.xfcal; char *s_time; char a_day[9]; /* yyyymmdd */ - struct tm *t; + struct tm *t, tt; xfical_type ical_type; gchar file_type[8]; gint i; GList *todo_list=NULL; + GList *event_list=NULL; #ifdef ORAGE_DEBUG orage_message(-100, P_N); #endif - t = orage_localtime(); - s_time = orage_tm_time_to_icaltime(t); - strncpy(a_day, s_time, 8); - a_day[8] = '\0'; + if (g_par.show_todos) { + t = orage_localtime(); + s_time = orage_tm_time_to_icaltime(t); + strncpy(a_day, s_time, 8); + a_day[8] = '\0'; - ical_type = XFICAL_TYPE_TODO; - /* first search base orage file */ - /* this routine is called always from libical build alarm list internal - * and ical files are already open at that time */ - /* - if (!xfical_file_open(TRUE)) - return; - */ - strcpy(file_type, "O00."); - insert_rows(&todo_list, a_day, ical_type, file_type); - /* then process all foreign files */ - for (i = 0; i < g_par.foreign_count; i++) { - g_sprintf(file_type, "F%02d.", i); + ical_type = XFICAL_TYPE_TODO; + /* first search base orage file */ + strcpy(file_type, "O00."); insert_rows(&todo_list, a_day, ical_type, file_type); + /* then process all foreign files */ + for (i = 0; i < g_par.foreign_count; i++) { + g_sprintf(file_type, "F%02d.", i); + insert_rows(&todo_list, a_day, ical_type, file_type); + } } - /* caller takes care of this - xfical_file_close(TRUE); - */ + if (g_par.show_events) { + gtk_calendar_get_date(GTK_CALENDAR(cal->mCalendar) + , &(tt.tm_year), &(tt.tm_mon), &(tt.tm_mday)); + tt.tm_year -= 1900; + s_time = orage_tm_time_to_icaltime(&tt); + strncpy(a_day, s_time, 8); + a_day[8] = '\0'; + + ical_type = XFICAL_TYPE_EVENT; + strcpy(file_type, "O00."); + insert_rows(&event_list, a_day, ical_type, file_type); + for (i = 0; i < g_par.foreign_count; i++) { + g_sprintf(file_type, "F%02d.", i); + insert_rows(&event_list, a_day, ical_type, file_type); + } + } if (todo_list) { - gtk_widget_destroy(cal->mInfo_scrolledWin); - create_mainbox_info(); - todo_list = g_list_sort(todo_list, todo_order); - g_list_foreach(todo_list, (GFunc)todo_process, NULL); + gtk_widget_destroy(cal->mTodo_vbox); + create_mainbox_todo_info(); + todo_list = g_list_sort(todo_list, list_order); + g_list_foreach(todo_list, (GFunc)info_process + , cal->mTodo_rows_vbox); g_list_free(todo_list); todo_list = NULL; - gtk_widget_show_all(cal->mInfo_scrolledWin); + gtk_widget_show_all(cal->mTodo_vbox); } else { - gtk_widget_hide_all(cal->mInfo_scrolledWin); + gtk_widget_hide_all(cal->mTodo_vbox); } + if (event_list) { + gtk_widget_destroy(cal->mEvent_vbox); + create_mainbox_event_info(); + event_list = g_list_sort(event_list, list_order); + g_list_foreach(event_list, (GFunc)info_process + , cal->mEvent_rows_vbox); + g_list_free(event_list); + event_list = NULL; + gtk_widget_show_all(cal->mEvent_vbox); + } + else { + gtk_widget_hide_all(cal->mEvent_vbox); + } } void build_mainWin() @@ -569,17 +682,17 @@ | GTK_CALENDAR_SHOW_WEEK_NUMBERS); gtk_widget_show(cal->mCalendar); - /* Build the Info box */ - create_mainbox_info(); - /* - gtk_widget_show_all(cal->mInfo_scrolledWin); - */ + /* Build the Info boxes */ + create_mainbox_todo_info(); + create_mainbox_event_info(); /* Signals */ - g_signal_connect((gpointer) cal->mCalendar, "day_selected_double_click" , G_CALLBACK(mCalendar_day_selected_double_click_cb) , (gpointer) cal); + g_signal_connect((gpointer) cal->mCalendar, "day_selected" + , G_CALLBACK(mCalendar_day_selected_cb) + , (gpointer) cal); g_signal_connect((gpointer) cal->mCalendar, "month-changed" , G_CALLBACK(mCalendar_month_changed_cb), (gpointer) cal); Modified: xfcalendar/trunk/src/mainbox.h =================================================================== --- xfcalendar/trunk/src/mainbox.h 2008-03-02 23:36:26 UTC (rev 26658) +++ xfcalendar/trunk/src/mainbox.h 2008-03-03 23:33:14 UTC (rev 26659) @@ -50,8 +50,14 @@ GtkWidget *mCalendar; - GtkWidget *mInfo_scrolledWin; - GtkWidget *mInfo_vbox; + GtkWidget *mTodo_vbox; + GtkWidget *mTodo_label; + GtkWidget *mTodo_scrolledWin; + GtkWidget *mTodo_rows_vbox; + GtkWidget *mEvent_vbox; + GtkWidget *mEvent_label; + GtkWidget *mEvent_scrolledWin; + GtkWidget *mEvent_rows_vbox; GdkColor mRed, mBlue; } CalWin; Modified: xfcalendar/trunk/src/parameters.c =================================================================== --- xfcalendar/trunk/src/parameters.c 2008-03-02 23:36:26 UTC (rev 26658) +++ xfcalendar/trunk/src/parameters.c 2008-03-03 23:33:14 UTC (rev 26659) @@ -82,6 +82,8 @@ GtkWidget *show_taskbar_checkbutton; GtkWidget *show_pager_checkbutton; GtkWidget *show_systray_checkbutton; + GtkWidget *show_todos_checkbutton; + GtkWidget *show_events_checkbutton; /* Start visibity show or hide */ GtkWidget *visibility_frame; GSList *visibility_radiobutton_group; @@ -182,6 +184,40 @@ set_menu(); } +static void set_todos() +{ + if (g_par.show_todos) + gtk_widget_show_all(g_par.xfcal->mTodo_vbox); + else + gtk_widget_hide_all(g_par.xfcal->mTodo_vbox); +} + +static void todos_changed(GtkWidget *dialog, gpointer user_data) +{ + Itf *itf = (Itf *)user_data; + + g_par.show_todos = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + itf->show_todos_checkbutton)); + set_todos(); +} + +static void set_events() +{ + if (g_par.show_events) + gtk_widget_show_all(g_par.xfcal->mEvent_vbox); + else + gtk_widget_hide_all(g_par.xfcal->mEvent_vbox); +} + +static void events_changed(GtkWidget *dialog, gpointer user_data) +{ + Itf *itf = (Itf *)user_data; + + g_par.show_events = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + itf->show_events_checkbutton)); + set_events(); +} + static void set_stick() { if (g_par.set_stick) @@ -481,29 +517,43 @@ gtk_box_pack_start(GTK_BOX(dialog->display_vbox), dialog->mode_frame , FALSE, FALSE, 5); - dialog->show_borders_checkbutton = - gtk_check_button_new_with_mnemonic(_("Show borders")); + dialog->show_borders_checkbutton = gtk_check_button_new_with_mnemonic( + _("Show borders")); gtk_box_pack_start(GTK_BOX(vbox) , dialog->show_borders_checkbutton, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( dialog->show_borders_checkbutton), g_par.show_borders); - dialog->show_menu_checkbutton = - gtk_check_button_new_with_mnemonic(_("Show menu")); + dialog->show_menu_checkbutton = gtk_check_button_new_with_mnemonic( + _("Show menu")); gtk_box_pack_start(GTK_BOX(vbox) , dialog->show_menu_checkbutton, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( dialog->show_menu_checkbutton), g_par.show_menu); - dialog->set_stick_checkbutton = - gtk_check_button_new_with_mnemonic(_("Set sticked")); + dialog->show_todos_checkbutton = gtk_check_button_new_with_mnemonic( + _("Show todo list")); gtk_box_pack_start(GTK_BOX(vbox) + , dialog->show_todos_checkbutton, FALSE, FALSE, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( + dialog->show_todos_checkbutton), g_par.show_todos); + + dialog->show_events_checkbutton = gtk_check_button_new_with_mnemonic( + _("Show event list")); + gtk_box_pack_start(GTK_BOX(vbox) + , dialog->show_events_checkbutton, FALSE, FALSE, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( + dialog->show_events_checkbutton), g_par.show_events); + + dialog->set_stick_checkbutton = gtk_check_button_new_with_mnemonic( + _("Set sticked")); + gtk_box_pack_start(GTK_BOX(vbox) , dialog->set_stick_checkbutton, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( dialog->set_stick_checkbutton), g_par.set_stick); - dialog->set_ontop_checkbutton = - gtk_check_button_new_with_mnemonic(_("Set on top")); + dialog->set_ontop_checkbutton = gtk_check_button_new_with_mnemonic( + _("Set on top")); gtk_box_pack_start(GTK_BOX(vbox) , dialog->set_ontop_checkbutton, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( @@ -513,6 +563,10 @@ , G_CALLBACK(borders_changed), dialog); g_signal_connect(G_OBJECT(dialog->show_menu_checkbutton), "toggled" , G_CALLBACK(menu_changed), dialog); + g_signal_connect(G_OBJECT(dialog->show_todos_checkbutton), "toggled" + , G_CALLBACK(todos_changed), dialog); + g_signal_connect(G_OBJECT(dialog->show_events_checkbutton), "toggled" + , G_CALLBACK(events_changed), dialog); g_signal_connect(G_OBJECT(dialog->set_stick_checkbutton), "toggled" , G_CALLBACK(stick_changed), dialog); g_signal_connect(G_OBJECT(dialog->set_ontop_checkbutton), "toggled" @@ -805,6 +859,8 @@ xfce_rc_write_bool_entry(rc, "Select Always Today" , g_par.select_always_today); xfce_rc_write_bool_entry(rc, "Show borders", g_par.show_borders); + xfce_rc_write_bool_entry(rc, "Show todos", g_par.show_todos); + xfce_rc_write_bool_entry(rc, "Show events", g_par.show_events); xfce_rc_write_bool_entry(rc, "Show in pager", g_par.show_pager); xfce_rc_write_bool_entry(rc, "Show in systray", g_par.show_systray); xfce_rc_write_bool_entry(rc, "Show in taskbar", g_par.show_taskbar); @@ -880,6 +936,8 @@ g_par.select_always_today = xfce_rc_read_bool_entry(rc, "Select Always Today", FALSE); g_par.show_borders = xfce_rc_read_bool_entry(rc, "Show borders", TRUE); + g_par.show_todos = xfce_rc_read_bool_entry(rc, "Show todos", TRUE); + g_par.show_events = xfce_rc_read_bool_entry(rc, "Show events", TRUE); g_par.show_pager = xfce_rc_read_bool_entry(rc, "Show in pager", TRUE); g_par.show_systray = xfce_rc_read_bool_entry(rc, "Show in systray", TRUE); g_par.show_taskbar = xfce_rc_read_bool_entry(rc, "Show in taskbar", TRUE); Modified: xfcalendar/trunk/src/parameters.h =================================================================== --- xfcalendar/trunk/src/parameters.h 2008-03-02 23:36:26 UTC (rev 26658) +++ xfcalendar/trunk/src/parameters.h 2008-03-03 23:33:14 UTC (rev 26659) @@ -40,6 +40,8 @@ gboolean select_always_today; gboolean show_menu; gboolean show_borders; + gboolean show_todos; + gboolean show_events; gboolean show_pager; gboolean show_systray; gboolean show_taskbar; From juha at xfce.org Tue Mar 4 08:51:40 2008 From: juha at xfce.org (Juha Kautto) Date: Tue, 4 Mar 2008 07:51:40 +0000 (UTC) Subject: [Xfce4-commits] r26660 - xfcalendar/trunk/src Message-ID: <20080304075140.DFF74F29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-04 07:51:40 +0000 (Tue, 04 Mar 2008) New Revision: 26660 Modified: xfcalendar/trunk/src/interface.c Log: added warning for updating foreign files and fixed formatting a little Modified: xfcalendar/trunk/src/interface.c =================================================================== --- xfcalendar/trunk/src/interface.c 2008-03-03 23:33:14 UTC (rev 26659) +++ xfcalendar/trunk/src/interface.c 2008-03-04 07:51:40 UTC (rev 26660) @@ -632,6 +632,7 @@ for (i = 0; i < g_par.foreign_count; i++) { hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(g_par.foreign_data[i].file); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5); if (g_par.foreign_data[i].read_only) label = gtk_label_new(_("READ ONLY")); @@ -1282,7 +1283,7 @@ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); gtk_tooltips_set_tip(intf_w->tooltips, intf_w->for_new_read_only - , _("Set this if you want to make sure that this file is never modified by Orage."), NULL); + , _("Set this if you want to make sure that this file is never modified by Orage.\nNote that modifying foreign files may make them incompatible with the original tool, where they came from!"), NULL); /***** Current files *****/ refresh_foreign_files(intf_w, TRUE); From kelnos at xfce.org Tue Mar 4 09:46:57 2008 From: kelnos at xfce.org (Brian Tarricone) Date: Tue, 4 Mar 2008 08:46:57 +0000 (UTC) Subject: [Xfce4-commits] r26661 - / Message-ID: <20080304084657.BF5E7F29D8@mocha.foo-projects.org> Author: kelnos Date: 2008-03-04 08:46:57 +0000 (Tue, 04 Mar 2008) New Revision: 26661 Removed: xfce4-iconbox/ xfce4-systray/ xfce4-themes/ xfce4-toys/ xffm-icons/ xffm/ Log: remove obsolete modules, move to new 'xfce-archive' repo From juha at xfce.org Tue Mar 4 18:01:09 2008 From: juha at xfce.org (Juha Kautto) Date: Tue, 4 Mar 2008 17:01:09 +0000 (UTC) Subject: [Xfce4-commits] r26662 - in xfcalendar/trunk: . src Message-ID: <20080304170109.A0D27F29D8@mocha.foo-projects.org> 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 #endif +#include +#include +#include + #include #include #include @@ -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); From juha at xfce.org Wed Mar 5 00:09:40 2008 From: juha at xfce.org (Juha Kautto) Date: Tue, 4 Mar 2008 23:09:40 +0000 (UTC) Subject: [Xfce4-commits] r26663 - in xfcalendar/trunk: . src Message-ID: <20080304230940.834FDF29D8@mocha.foo-projects.org> Author: juha Date: 2008-03-04 23:09:40 +0000 (Tue, 04 Mar 2008) New Revision: 26663 Modified: xfcalendar/trunk/configure.in.in xfcalendar/trunk/src/functions.c xfcalendar/trunk/src/ical-code.c xfcalendar/trunk/src/mainbox.c Log: Fixes to mainwindow handling 4.5.13.4 Modified: xfcalendar/trunk/configure.in.in =================================================================== --- xfcalendar/trunk/configure.in.in 2008-03-04 17:01:09 UTC (rev 26662) +++ xfcalendar/trunk/configure.in.in 2008-03-04 23:09:40 UTC (rev 26663) @@ -9,7 +9,7 @@ dnl dnl Version information -m4_define([orage_version], [4.5.13.3-svn]) +m4_define([orage_version], [4.5.13.4-svn]) m4_define([gtk_minimum_version], [2.6.0]) m4_define([xfce_minimum_version], [4.4.0]) Modified: xfcalendar/trunk/src/functions.c =================================================================== --- xfcalendar/trunk/src/functions.c 2008-03-04 17:01:09 UTC (rev 26662) +++ xfcalendar/trunk/src/functions.c 2008-03-04 23:09:40 UTC (rev 26663) @@ -475,9 +475,17 @@ void orage_select_date(GtkCalendar *cal , guint year, guint month, guint day) { - gtk_calendar_select_day(cal, 0); /* needed to avoid illegal day/month */ - gtk_calendar_select_month(cal, month, year); - gtk_calendar_select_day(cal, day); + guint cur_year, cur_month, cur_mday; + + gtk_calendar_get_date(cal, &cur_year, &cur_month, &cur_mday); + + if (cur_year == year && cur_month == month) + gtk_calendar_select_day(cal, day); + else { + gtk_calendar_select_day(cal, 0); /* needed to avoid illegal day/month */ + gtk_calendar_select_month(cal, month, year); + gtk_calendar_select_day(cal, day); + } } void orage_select_today(GtkCalendar *cal) Modified: xfcalendar/trunk/src/ical-code.c =================================================================== --- xfcalendar/trunk/src/ical-code.c 2008-03-04 17:01:09 UTC (rev 26662) +++ xfcalendar/trunk/src/ical-code.c 2008-03-04 23:09:40 UTC (rev 26663) @@ -3040,7 +3040,7 @@ /* order list */ g_par.alarm_list = g_list_sort(g_par.alarm_list, alarm_order); setup_orage_alarm_clock(); /* keep reminders upto date */ - build_mainbox_info(); /* refresh main calendar window todo list */ + build_mainbox_info(); /* refresh main calendar window lists */ /* moved to reminder in setup_orage_alarm_clock store_persistent_alarms(); / * keep track of alarms when orage is down * / */ Modified: xfcalendar/trunk/src/mainbox.c =================================================================== --- xfcalendar/trunk/src/mainbox.c 2008-03-04 17:01:09 UTC (rev 26662) +++ xfcalendar/trunk/src/mainbox.c 2008-03-04 23:09:40 UTC (rev 26663) @@ -210,26 +210,6 @@ create_el_win(NULL); } -void orage_show_events_for_selected_date(void) -{ - /* rebuild the info for the selected date */ - if (!xfical_file_open(TRUE)) - return; - build_mainbox_info(); - xfical_file_close(TRUE); -} - -static void mCalendar_day_selected_cb(GtkCalendar *calendar - , gpointer user_data) -{ -#undef P_N -#define P_N "mCalendar_day_selected_cb: " -#ifdef ORAGE_DEBUG - orage_message(-100, P_N); -#endif - orage_show_events_for_selected_date(); -} - static gboolean upd_calendar(GtkCalendar *calendar) { #undef P_N @@ -485,7 +465,7 @@ xfical_appt_free(appt); } -void create_mainbox_todo_info(void) +static void create_mainbox_todo_info(void) { #undef P_N #define P_N "create_mainbox_todo_info: " @@ -513,7 +493,7 @@ GTK_SCROLLED_WINDOW(cal->mTodo_scrolledWin), cal->mTodo_rows_vbox); } -void create_mainbox_event_info(void) +static void create_mainbox_event_info(void) { #undef P_N #define P_N "create_mainbox_event_info: " @@ -546,29 +526,22 @@ GTK_SCROLLED_WINDOW(cal->mEvent_scrolledWin), cal->mEvent_rows_vbox); } -/********************************************************************** - * This routine is called from ical-code xfical_alarm_build_list_internal - * and ical files are already open at that time. So make sure ical files - * are opened before and closed after this call. - **********************************************************************/ -void build_mainbox_info(void) +static void build_mainbox_todo_info(void) { #undef P_N -#define P_N "build_mainbox_info: " +#define P_N "build_mainbox_todo_info: " CalWin *cal = g_par.xfcal; char *s_time; char a_day[9]; /* yyyymmdd */ - struct tm *t, tt; + struct tm *t; xfical_type ical_type; gchar file_type[8]; gint i; GList *todo_list=NULL; - GList *event_list=NULL; #ifdef ORAGE_DEBUG orage_message(-100, P_N); #endif - if (g_par.show_todos) { t = orage_localtime(); s_time = orage_tm_time_to_icaltime(t); @@ -585,9 +558,42 @@ insert_rows(&todo_list, a_day, ical_type, file_type); } } + if (todo_list) { + gtk_widget_destroy(cal->mTodo_vbox); + create_mainbox_todo_info(); + todo_list = g_list_sort(todo_list, list_order); + g_list_foreach(todo_list, (GFunc)info_process + , cal->mTodo_rows_vbox); + g_list_free(todo_list); + todo_list = NULL; + gtk_widget_show_all(cal->mTodo_vbox); + } + else { + gtk_widget_hide_all(cal->mTodo_vbox); + } +} + +static void build_mainbox_event_info(void) +{ +#undef P_N +#define P_N "build_mainbox_event_info: " + CalWin *cal = g_par.xfcal; + char *s_time; + char a_day[9]; /* yyyymmdd */ + struct tm tt= {0,0,0,0,0,0,0,0,0}; + xfical_type ical_type; + gchar file_type[8]; + gint i; + GList *event_list=NULL; + +#ifdef ORAGE_DEBUG + orage_message(-100, P_N); +#endif if (g_par.show_events) { gtk_calendar_get_date(GTK_CALENDAR(cal->mCalendar) - , &(tt.tm_year), &(tt.tm_mon), &(tt.tm_mday)); + , (unsigned int *)&tt.tm_year + , (unsigned int *)&tt.tm_mon + , (unsigned int *)&tt.tm_mday); tt.tm_year -= 1900; s_time = orage_tm_time_to_icaltime(&tt); strncpy(a_day, s_time, 8); @@ -601,19 +607,6 @@ insert_rows(&event_list, a_day, ical_type, file_type); } } - if (todo_list) { - gtk_widget_destroy(cal->mTodo_vbox); - create_mainbox_todo_info(); - todo_list = g_list_sort(todo_list, list_order); - g_list_foreach(todo_list, (GFunc)info_process - , cal->mTodo_rows_vbox); - g_list_free(todo_list); - todo_list = NULL; - gtk_widget_show_all(cal->mTodo_vbox); - } - else { - gtk_widget_hide_all(cal->mTodo_vbox); - } if (event_list) { gtk_widget_destroy(cal->mEvent_vbox); create_mainbox_event_info(); @@ -629