diff options
author | Miguel de Icaza <miguel@nuclecu.unam.mx> | 1999-01-28 04:26:10 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1999-01-28 04:26:10 +0800 |
commit | c970e7ace5de19acdb9cf664435cbec8264ee89e (patch) | |
tree | 9aa8a570c2ce45f48b2ee7dfafbf90970820fec3 /calendar/main.c | |
parent | 6d97fa0fe88d5511cbefe38c0251bcce8d5d1575 (diff) | |
download | gsoc2013-evolution-c970e7ace5de19acdb9cf664435cbec8264ee89e.tar.gz gsoc2013-evolution-c970e7ace5de19acdb9cf664435cbec8264ee89e.tar.zst gsoc2013-evolution-c970e7ace5de19acdb9cf664435cbec8264ee89e.zip |
Warn if the calendar file has changed.
1999-01-27 Miguel de Icaza <miguel@nuclecu.unam.mx>
* main.c (save_calendar_cmd): Warn if the calendar file has
changed.
* calendar.c (calendar_load, calendar_save): Keep track of the
modification time for the calendar file.
svn path=/trunk/; revision=632
Diffstat (limited to 'calendar/main.c')
-rw-r--r-- | calendar/main.c | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/calendar/main.c b/calendar/main.c index 9d03fecd61..16072c221c 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -11,6 +11,7 @@ #include <gnome.h> #include <pwd.h> #include <sys/types.h> +#include <sys/stat.h> #include <string.h> #include <ctype.h> #include "calendar.h" @@ -391,9 +392,34 @@ save_calendar_cmd (GtkWidget *widget, void *data) { GnomeCalendar *gcal = data; - if (gcal->cal->filename) + if (gcal->cal->filename){ + struct stat s; + + stat (gcal->cal->filename, &s); + + if (s.st_mtime != gcal->cal->file_time){ + GtkWidget *box; + char *str; + int b; + + str = g_strdup_printf ( + _("File %s has changed since it was loaded\nContinue?"), + gcal->cal->filename); + box = gnome_message_box_new (str, GNOME_MESSAGE_BOX_INFO, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + g_free (str); + gnome_dialog_set_default (GNOME_DIALOG (box), 1); + b = gnome_dialog_run (GNOME_DIALOG (box)); + gtk_object_destroy (GTK_OBJECT (box)); + + if (b != 0) + return; + } + calendar_save (gcal->cal, gcal->cal->filename); - else + } else save_as_calendar_cmd (widget, data); } @@ -650,17 +676,17 @@ parse_an_arg (poptContext ctx, } } -static const struct poptOption options[] = { - {NULL, '\0', POPT_ARG_CALLBACK, parse_an_arg, 0, NULL, NULL}, - {"events", 'e', POPT_ARG_NONE, NULL, 'e', N_("Show events and quit"), - NULL}, - {"from", 'f', POPT_ARG_STRING, NULL, 'f', N_("Specifies start date [for --events]"), N_("DATE")}, - {"file", 'F', POPT_ARG_STRING, NULL, 'F', N_("File to load calendar from"), N_("FILE")}, - {"userfile", '\0', POPT_ARG_NONE, NULL, USERFILE_KEY, N_("Load the user calendar"), NULL}, - {"geometry", '\0', POPT_ARG_STRING, NULL, GEOMETRY_KEY, N_("Geometry for starting up"), N_("GEOMETRY")}, - {"view", '\0', POPT_ARG_STRING, NULL, VIEW_KEY, N_("The startup view mode"), N_("VIEW")}, - {"to", 't', POPT_ARG_STRING, NULL, 't', N_("Specifies ending date [for --events]"), N_("DATE")}, - {NULL, '\0', 0, NULL, 0} +static const struct poptOption options [] = { + { NULL, '\0', POPT_ARG_CALLBACK, parse_an_arg, 0, NULL, NULL }, + { "events", 'e', POPT_ARG_NONE, NULL, 'e', N_("Show events and quit"), + NULL }, + { "from", 'f', POPT_ARG_STRING, NULL, 'f', N_("Specifies start date [for --events]"), N_("DATE") }, + { "file", 'F', POPT_ARG_STRING, NULL, 'F', N_("File to load calendar from"), N_("FILE") }, + { "userfile", '\0', POPT_ARG_NONE, NULL, USERFILE_KEY, N_("Load the user calendar"), NULL }, + { "geometry", '\0', POPT_ARG_STRING, NULL, GEOMETRY_KEY, N_("Geometry for starting up"), N_("GEOMETRY") }, + { "view", '\0', POPT_ARG_STRING, NULL, VIEW_KEY, N_("The startup view mode"), N_("VIEW") }, + { "to", 't', POPT_ARG_STRING, NULL, 't', N_("Specifies ending date [for --events]"), N_("DATE") }, + { NULL, '\0', 0, NULL, 0} }; static void @@ -719,14 +745,14 @@ main(int argc, char *argv[]) { GnomeClient *client; - bindtextdomain(PACKAGE, GNOMELOCALEDIR); - textdomain(PACKAGE); + bindtextdomain (PACKAGE, GNOMELOCALEDIR); + textdomain (PACKAGE); - gnome_init_with_popt_table("calendar", VERSION, argc, argv, - options, 0, NULL); + gnome_init_with_popt_table ("calendar", VERSION, argc, argv, + options, 0, NULL); if (show_events) - dump_events (); + dump_events (); client = gnome_master_client (); if (client){ |