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
This commit is contained in:
committed by
Arturo Espinosa
parent
6d97fa0fe8
commit
c970e7ace5
@ -1,3 +1,11 @@
|
||||
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.
|
||||
|
||||
1999-01-20 Nat Friedman <nat@nat.org>
|
||||
|
||||
* gncal-full-day.c (gncal_full_day_key_press): Only trap printable
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "calendar.h"
|
||||
#include "alarm.h"
|
||||
#include "timeutil.h"
|
||||
@ -280,6 +281,7 @@ calendar_load (Calendar *cal, char *fname)
|
||||
{
|
||||
VObject *vcal;
|
||||
time_t calendar_today;
|
||||
struct stat s;
|
||||
|
||||
if (cal->filename){
|
||||
g_warning ("Calendar load called again\n");
|
||||
@ -291,6 +293,8 @@ calendar_load (Calendar *cal, char *fname)
|
||||
if (!vcal)
|
||||
return "Could not load the calendar";
|
||||
|
||||
stat (fname, &s);
|
||||
cal->file_time = s.st_mtime;
|
||||
calendar_today = time (NULL);
|
||||
calendar_day_begin = time_day_begin (calendar_today);
|
||||
calendar_day_end = time_day_end (calendar_today);
|
||||
@ -307,6 +311,7 @@ calendar_save (Calendar *cal, char *fname)
|
||||
VObject *vcal;
|
||||
GList *l;
|
||||
time_t now = time (NULL);
|
||||
struct stat s;
|
||||
|
||||
if (fname == NULL)
|
||||
fname = cal->filename;
|
||||
@ -348,6 +353,9 @@ calendar_save (Calendar *cal, char *fname)
|
||||
g_free (backup_name);
|
||||
}
|
||||
writeVObjectToFile (fname, vcal);
|
||||
|
||||
stat (fname, &s);
|
||||
cal->file_time = s.st_mtime;
|
||||
|
||||
cleanVObject (vcal);
|
||||
cleanStrTbl ();
|
||||
|
||||
@ -20,6 +20,9 @@ typedef struct {
|
||||
/* Time at which the calendar was created */
|
||||
time_t created;
|
||||
|
||||
/* Timestamp in the filename */
|
||||
time_t file_time;
|
||||
|
||||
/* If the calendar was last modified */
|
||||
int modified;
|
||||
void *temp;
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "calendar.h"
|
||||
#include "alarm.h"
|
||||
#include "timeutil.h"
|
||||
@ -280,6 +281,7 @@ calendar_load (Calendar *cal, char *fname)
|
||||
{
|
||||
VObject *vcal;
|
||||
time_t calendar_today;
|
||||
struct stat s;
|
||||
|
||||
if (cal->filename){
|
||||
g_warning ("Calendar load called again\n");
|
||||
@ -291,6 +293,8 @@ calendar_load (Calendar *cal, char *fname)
|
||||
if (!vcal)
|
||||
return "Could not load the calendar";
|
||||
|
||||
stat (fname, &s);
|
||||
cal->file_time = s.st_mtime;
|
||||
calendar_today = time (NULL);
|
||||
calendar_day_begin = time_day_begin (calendar_today);
|
||||
calendar_day_end = time_day_end (calendar_today);
|
||||
@ -307,6 +311,7 @@ calendar_save (Calendar *cal, char *fname)
|
||||
VObject *vcal;
|
||||
GList *l;
|
||||
time_t now = time (NULL);
|
||||
struct stat s;
|
||||
|
||||
if (fname == NULL)
|
||||
fname = cal->filename;
|
||||
@ -348,6 +353,9 @@ calendar_save (Calendar *cal, char *fname)
|
||||
g_free (backup_name);
|
||||
}
|
||||
writeVObjectToFile (fname, vcal);
|
||||
|
||||
stat (fname, &s);
|
||||
cal->file_time = s.st_mtime;
|
||||
|
||||
cleanVObject (vcal);
|
||||
cleanStrTbl ();
|
||||
|
||||
@ -20,6 +20,9 @@ typedef struct {
|
||||
/* Time at which the calendar was created */
|
||||
time_t created;
|
||||
|
||||
/* Timestamp in the filename */
|
||||
time_t file_time;
|
||||
|
||||
/* If the calendar was last modified */
|
||||
int modified;
|
||||
void *temp;
|
||||
|
||||
@ -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){
|
||||
|
||||
@ -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){
|
||||
|
||||
Reference in New Issue
Block a user