aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-04-16 06:51:48 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-16 06:51:48 +0800
commit77d15722d272941f67af74f5abb1eef1a21a4644 (patch)
tree38a3644f7873bbcdcff9e63666a583905477e1be
parentf89cf24d2093c9982e461a2478d0acb4eeacc408 (diff)
downloadgsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar.gz
gsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar.zst
gsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.zip
The general_owner may be null. Do the proper thing when creating the
1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx> * eventedit.c (ee_init_general_page): The general_owner may be null. Do the proper thing when creating the label. (ee_ok): Update the gnome calendar appropriately. * timeutil.h: * gncal-year-view.h: Add some missing prototypes. * gncal-full-day.c (child_popup_menu): Set the sensitivity of menu items according to whether the ical object is being edited or not. * eventedit.c (event_editor_new): Set the "being edited" flag on the ical object (stored as the ical object's user data). (event_editor_destroy): Release the flag. * calobj.h: The iCalObject structure now has a generic user_data pointer. * calobj.c (ical_object_set_user_data ical_object_get_user_data): Functions to set this data. svn path=/trunk/; revision=140
-rw-r--r--calendar/ChangeLog31
-rw-r--r--calendar/TODO10
-rw-r--r--calendar/cal-util/calobj.c12
-rw-r--r--calendar/cal-util/calobj.h6
-rw-r--r--calendar/calobj.c12
-rw-r--r--calendar/calobj.h6
-rw-r--r--calendar/eventedit.c67
-rw-r--r--calendar/gncal-full-day.c196
-rw-r--r--calendar/gui/eventedit.c67
-rw-r--r--calendar/gui/gncal-full-day.c196
-rw-r--r--calendar/gui/main.c4
-rw-r--r--calendar/gui/test.vcf8
-rw-r--r--calendar/gui/year-view.c1
-rw-r--r--calendar/gui/year-view.h1
-rw-r--r--calendar/main.c4
-rw-r--r--calendar/pcs/calobj.c12
-rw-r--r--calendar/pcs/calobj.h6
-rw-r--r--calendar/test.vcf8
-rw-r--r--calendar/timeutil.h2
-rw-r--r--calendar/year-view.c1
-rw-r--r--calendar/year-view.h1
21 files changed, 456 insertions, 195 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 03e9cfc784..e6601ac878 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,34 @@
+1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
+
+ * eventedit.c (ee_init_general_page): The general_owner may be
+ null. Do the proper thing when creating the label.
+ (ee_ok): Update the gnome calendar appropriately.
+
+ * timeutil.h:
+ * gncal-year-view.h: Add some missing prototypes.
+
+ * gncal-full-day.c (child_popup_menu): Set the sensitivity of menu
+ items according to whether the ical object is being edited or not.
+
+ * eventedit.c (event_editor_new): Set the "being edited" flag on
+ the ical object (stored as the ical object's user data).
+ (event_editor_destroy): Release the flag.
+
+ * calobj.h: The iCalObject structure now has a generic user_data pointer.
+ * calobj.c (ical_object_set_user_data ical_object_get_user_data):
+ Functions to set this data.
+
+ * gncal-full-day.c (child_button_press): Do child popup menu correctly.
+
+ * main.c (about_calendar_cmd): Fixed my address and added Arturo
+ to the authors in the about box.
+
+ * gncal-full-day.c (find_child_by_window): Compare child's widget
+ windows by user_data (which will be the parent widget, that is,
+ the text widget). We cannot assume that child->widget->window
+ will be *the* window we are interested on because there may be
+ child widgets with multiple windows.
+
1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
* calobj.c (ical_foreach): Define iterator routine.
diff --git a/calendar/TODO b/calendar/TODO
index 5af4c5209d..389ffc0cce 100644
--- a/calendar/TODO
+++ b/calendar/TODO
@@ -1,3 +1,9 @@
+Calendar object:
+
+- The warnings spitted when you open the event editor to edit an
+ existing calendar object happen because the alarm loading code is
+ not yet finished.
+
Gnome date selection widget:
- Make the displayed date be localized properly -- use strftime().
@@ -8,6 +14,10 @@ Event editor dialog:
Full day view widget:
+- Display vertical handle bar at the left of a child to move it.
+
+- Display alarm/whatever flags somewhere.
+
- Layout the children nicely like M$ Schedule or Netscape Calendar do
(i.e. make them not overlap each other).
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 7e5f535189..a744836c89 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -686,3 +686,15 @@ ical_foreach (GList *events, iCalObjectFn fn, void *closure)
(*fn) (ical, ical->dtstart, ical->dtend, closure);
}
}
+
+void
+ical_object_set_user_data (iCalObject *ical, void *user_data)
+{
+ ical->user_data = user_data;
+}
+
+void *
+ical_object_get_user_data (iCalObject *ical)
+{
+ return ical->user_data;
+}
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 8f7abf8871..684605b271 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -100,7 +100,8 @@ typedef struct {
typedef enum {
CHANGE_NEW = 1 << 0, /* new object */
CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2 /* dtstart / dtend */
+ CHANGE_DATES = 1 << 2, /* dtstart / dtend */
+ CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
} CalObjectChange;
/*
@@ -151,6 +152,7 @@ typedef struct {
Recurrence *recur;
int new;
+ void *user_data; /* Generic data pointer */
} iCalObject;
/* The callback for the recurrence generator */
@@ -162,6 +164,8 @@ void ical_object_destroy (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
void ical_foreach (GList *events, iCalObjectFn fn, void *closure);
+void ical_object_set_user_data (iCalObject *ical, void *user_data);
+void *ical_object_get_user_data (iCalObject *ical);
END_GNOME_DECLS
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 7e5f535189..a744836c89 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -686,3 +686,15 @@ ical_foreach (GList *events, iCalObjectFn fn, void *closure)
(*fn) (ical, ical->dtstart, ical->dtend, closure);
}
}
+
+void
+ical_object_set_user_data (iCalObject *ical, void *user_data)
+{
+ ical->user_data = user_data;
+}
+
+void *
+ical_object_get_user_data (iCalObject *ical)
+{
+ return ical->user_data;
+}
diff --git a/calendar/calobj.h b/calendar/calobj.h
index 8f7abf8871..684605b271 100644
--- a/calendar/calobj.h
+++ b/calendar/calobj.h
@@ -100,7 +100,8 @@ typedef struct {
typedef enum {
CHANGE_NEW = 1 << 0, /* new object */
CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2 /* dtstart / dtend */
+ CHANGE_DATES = 1 << 2, /* dtstart / dtend */
+ CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
} CalObjectChange;
/*
@@ -151,6 +152,7 @@ typedef struct {
Recurrence *recur;
int new;
+ void *user_data; /* Generic data pointer */
} iCalObject;
/* The callback for the recurrence generator */
@@ -162,6 +164,8 @@ void ical_object_destroy (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
void ical_foreach (GList *events, iCalObjectFn fn, void *closure);
+void ical_object_set_user_data (iCalObject *ical, void *user_data);
+void *ical_object_get_user_data (iCalObject *ical);
END_GNOME_DECLS
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
index 74ad9570ff..9547cc5bee 100644
--- a/calendar/eventedit.c
+++ b/calendar/eventedit.c
@@ -12,10 +12,16 @@
#include "main.h"
#include "timeutil.h"
-static void event_editor_init (EventEditor *ee);
+
+static void event_editor_class_init (EventEditorClass *class);
+static void event_editor_init (EventEditor *ee);
+static void event_editor_destroy (GtkObject *object);
/* Note: do not i18n these strings, they are part of the vCalendar protocol */
-char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
+static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
+
+static GtkWindowClass *parent_class;
+
guint
event_editor_get_type (void)
@@ -27,7 +33,7 @@ event_editor_get_type (void)
"EventEditor",
sizeof(EventEditor),
sizeof(EventEditorClass),
- (GtkClassInitFunc) NULL,
+ (GtkClassInitFunc) event_editor_class_init,
(GtkObjectInitFunc) event_editor_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
@@ -37,6 +43,16 @@ event_editor_get_type (void)
return event_editor_type;
}
+static void
+event_editor_class_init (EventEditorClass *class)
+{
+ GtkObjectClass *object_class;
+
+ parent_class = gtk_type_class (gtk_window_get_type ());
+
+ object_class->destroy = event_editor_destroy;
+}
+
/*
* when the start time is changed, this adjusts the end time.
*/
@@ -263,7 +279,7 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t
break;
default:
- /* Nothing */
+ break;
}
ee_alarm_setting (alarm, alarm->enabled);
@@ -379,6 +395,11 @@ ee_store_dlg_values_to_ical (EventEditor *ee)
ical->dtstart = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
ical->dtend = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
+ if (ical->summary)
+ g_free (ical->summary);
+
+ ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
+
ee_store_alarm (&ical->dalarm, ALARM_DISPLAY);
ee_store_alarm (&ical->aalarm, ALARM_AUDIO);
ee_store_alarm (&ical->palarm, ALARM_PROGRAM);
@@ -397,9 +418,6 @@ ee_store_dlg_values_to_ical (EventEditor *ee)
if (ee->ical->new)
ical->created = now;
-
- g_free (ical->summary);
- ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
}
static void
@@ -408,7 +426,9 @@ ee_ok (GtkWidget *widget, EventEditor *ee)
ee_store_dlg_values_to_ical (ee);
if (ee->ical->new)
- gnome_calendar_add_object (GNOME_CALENDAR (ee->gnome_cal), ee->ical);
+ gnome_calendar_add_object (ee->gnome_cal, ee->ical);
+ else
+ gnome_calendar_object_changed (ee->gnome_cal, ee->ical, CHANGE_ALL);
gtk_widget_destroy (GTK_WIDGET (ee));
}
@@ -416,8 +436,11 @@ ee_ok (GtkWidget *widget, EventEditor *ee)
static void
ee_cancel (GtkWidget *widget, EventEditor *ee)
{
- if (ee->ical->new)
+ if (ee->ical->new) {
ical_object_destroy (ee->ical);
+ ee->ical = NULL;
+ }
+
gtk_widget_destroy (GTK_WIDGET (ee));
}
@@ -483,7 +506,7 @@ ee_init_general_page (EventEditor *ee)
l = gtk_label_new (_("Owner:"));
gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
- ee->general_owner = gtk_label_new (ee->ical->organizer);
+ ee->general_owner = gtk_label_new (ee->ical->organizer ? ee->ical->organizer : _("?"));
gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4);
@@ -874,11 +897,30 @@ event_editor_init (EventEditor *ee)
ee->ical = 0;
}
+static void
+event_editor_destroy (GtkObject *object)
+{
+ EventEditor *ee;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_EVENT_EDITOR (object));
+
+ ee = EVENT_EDITOR (object);
+
+ if (ee->ical)
+ ical_object_set_user_data (ee->ical, NULL); /* we are no longer editing it */
+}
+
GtkWidget *
event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
{
GtkWidget *retval;
EventEditor *ee;
+
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gdk_flush ();
+
+ printf ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n");
retval = gtk_type_new (event_editor_get_type ());
ee = EVENT_EDITOR (retval);
@@ -886,7 +928,10 @@ event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
if (ical == 0){
ical = ical_new ("Test Comment", user_name, "Test Summary");
ical->new = 1;
- }
+ }
+
+ ical_object_set_user_data (ical, ee); /* so that the world can know we are editing it */
+
ee->ical = ical;
ee->gnome_cal = gcal;
event_editor_init_widgets (ee);
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
index 3e6ae677af..7e3d2e0d41 100644
--- a/calendar/gncal-full-day.c
+++ b/calendar/gncal-full-day.c
@@ -60,6 +60,7 @@ struct menu_item {
char *text;
GtkSignalFunc callback;
gpointer data;
+ int sensitive;
};
@@ -288,6 +289,94 @@ child_range_changed (GncalFullDay *fullday, Child *child)
}
static void
+popup_menu (struct menu_item *items, int nitems, guint32 time)
+{
+ GtkWidget *menu;
+ GtkWidget *item;
+ int i;
+
+ menu = gtk_menu_new (); /* FIXME: this baby is never freed */
+
+ for (i = 0; i < nitems; i++) {
+ if (items[i].text) {
+ item = gtk_menu_item_new_with_label (_(items[i].text));
+ gtk_signal_connect (GTK_OBJECT (item), "activate",
+ items[i].callback,
+ items[i].data);
+ gtk_widget_set_sensitive (item, items[i].sensitive);
+ } else
+ item = gtk_menu_item_new ();
+
+ gtk_widget_show (item);
+ gtk_menu_append (GTK_MENU (menu), item);
+ }
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, time);
+}
+
+static void
+new_appointment (GtkWidget *widget, gpointer data)
+{
+ GncalFullDay *fullday;
+
+ fullday = GNCAL_FULL_DAY (data);
+
+ /* FIXME: this should set up the start/end times in the event
+ * editor to whatever the selection range is. If there is no
+ * selection, then default to something sensible, like the row
+ * at which the button was clicked on when popping up the menu.
+ */
+
+ event_editor_new (fullday->calendar, NULL);
+}
+
+static void
+edit_appointment (GtkWidget *widget, gpointer data)
+{
+ Child *child;
+
+ child = data;
+
+ event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
+}
+
+static void
+delete_appointment (GtkWidget *widget, gpointer data)
+{
+ Child *child;
+
+ child = data;
+
+ /* FIXME */
+
+ printf ("Yay! delete_appointment() not yet implemented\n");
+}
+
+static void
+child_popup_menu (GncalFullDay *fullday, Child *child, guint32 event_time)
+{
+ int sensitive;
+
+ static struct menu_item child_items[] = {
+ { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
+ { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
+ { NULL, NULL, NULL, TRUE },
+ { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
+ };
+
+ child_items[0].data = child;
+ child_items[1].data = child;
+ child_items[3].data = fullday;
+
+ sensitive = (ical_object_get_user_data (child->ico) == NULL);
+
+ child_items[0].sensitive = sensitive;
+ child_items[1].sensitive = sensitive;
+
+ popup_menu (child_items, sizeof (child_items) / sizeof (child_items[0]), event_time);
+}
+
+static void
child_realized_setup (GtkWidget *widget, gpointer data)
{
Child *child;
@@ -359,6 +448,24 @@ child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
return FALSE;
}
+static gint
+child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ Child *child;
+ GncalFullDay *fullday;
+
+ if (event->button != 3)
+ return FALSE;
+
+ child = data;
+ fullday = GNCAL_FULL_DAY (widget->parent);
+
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
+ child_popup_menu (fullday, child, event->time);
+
+ return TRUE;
+}
+
static Child *
child_new (GncalFullDay *fullday, iCalObject *ico)
{
@@ -394,6 +501,10 @@ child_new (GncalFullDay *fullday, iCalObject *ico)
(GtkSignalFunc) child_key_press,
child);
+ gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
+ (GtkSignalFunc) child_button_press,
+ child);
+
/* Finish setup */
gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
@@ -1152,16 +1263,19 @@ find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
{
GList *children;
Child *child;
+ GtkWidget *owner;
*on_text = FALSE;
+ gdk_window_get_user_data (window, (gpointer *) &owner);
+
for (children = fullday->children; children; children = children->next) {
child = children->data;
if (child->window == window)
return child;
- if (child->widget->window == window) {
+ if (child->widget == owner) {
*on_text = TRUE;
return child;
}
@@ -1331,81 +1445,11 @@ button_1 (GncalFullDay *fullday, GdkEventButton *event)
return FALSE;
}
-static void
-popup_menu (struct menu_item *items, int nitems, guint32 time)
-{
- GtkWidget *menu;
- GtkWidget *item;
- int i;
-
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
-
- for (i = 0; i < nitems; i++) {
- if (items[i].text) {
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- items[i].callback,
- items[i].data);
- } else
- item = gtk_menu_item_new ();
-
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
- }
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, time);
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (data);
-
- /* FIXME: this should set up the start/end times in the event
- * editor to whatever the selection range is. If there is no
- * selection, then default to something sensible, like the row
- * at which the button was clicked on when popping up the menu.
- */
-
- event_editor_new (fullday->calendar, NULL);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
-
- child = data;
-
- event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
-
- child = data;
-
- /* FIXME */
-
- printf ("Yay! delete_appointment() not yet implemented\n");
-}
-
static int
button_3 (GncalFullDay *fullday, GdkEventButton *event)
{
static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL }
- };
-
- static struct menu_item child_items[] = {
- { N_("Properties..."), (GtkSignalFunc) edit_appointment, NULL },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL },
- { NULL, NULL, NULL },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL }
+ { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
};
GtkWidget *widget;
@@ -1426,14 +1470,10 @@ button_3 (GncalFullDay *fullday, GdkEventButton *event)
} else {
child = find_child_by_window (fullday, event->window, &on_text);
- if (!child)
+ if (!child || on_text)
return FALSE;
- child_items[0].data = child;
- child_items[1].data = child;
- child_items[3].data = fullday;
-
- popup_menu (child_items, sizeof (child_items) / sizeof (child_items[0]), event->time);
+ child_popup_menu (fullday, child, event->time);
return TRUE;
}
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index 74ad9570ff..9547cc5bee 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -12,10 +12,16 @@
#include "main.h"
#include "timeutil.h"
-static void event_editor_init (EventEditor *ee);
+
+static void event_editor_class_init (EventEditorClass *class);
+static void event_editor_init (EventEditor *ee);
+static void event_editor_destroy (GtkObject *object);
/* Note: do not i18n these strings, they are part of the vCalendar protocol */
-char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
+static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
+
+static GtkWindowClass *parent_class;
+
guint
event_editor_get_type (void)
@@ -27,7 +33,7 @@ event_editor_get_type (void)
"EventEditor",
sizeof(EventEditor),
sizeof(EventEditorClass),
- (GtkClassInitFunc) NULL,
+ (GtkClassInitFunc) event_editor_class_init,
(GtkObjectInitFunc) event_editor_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
@@ -37,6 +43,16 @@ event_editor_get_type (void)
return event_editor_type;
}
+static void
+event_editor_class_init (EventEditorClass *class)
+{
+ GtkObjectClass *object_class;
+
+ parent_class = gtk_type_class (gtk_window_get_type ());
+
+ object_class->destroy = event_editor_destroy;
+}
+
/*
* when the start time is changed, this adjusts the end time.
*/
@@ -263,7 +279,7 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t
break;
default:
- /* Nothing */
+ break;
}
ee_alarm_setting (alarm, alarm->enabled);
@@ -379,6 +395,11 @@ ee_store_dlg_values_to_ical (EventEditor *ee)
ical->dtstart = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
ical->dtend = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
+ if (ical->summary)
+ g_free (ical->summary);
+
+ ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
+
ee_store_alarm (&ical->dalarm, ALARM_DISPLAY);
ee_store_alarm (&ical->aalarm, ALARM_AUDIO);
ee_store_alarm (&ical->palarm, ALARM_PROGRAM);
@@ -397,9 +418,6 @@ ee_store_dlg_values_to_ical (EventEditor *ee)
if (ee->ical->new)
ical->created = now;
-
- g_free (ical->summary);
- ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
}
static void
@@ -408,7 +426,9 @@ ee_ok (GtkWidget *widget, EventEditor *ee)
ee_store_dlg_values_to_ical (ee);
if (ee->ical->new)
- gnome_calendar_add_object (GNOME_CALENDAR (ee->gnome_cal), ee->ical);
+ gnome_calendar_add_object (ee->gnome_cal, ee->ical);
+ else
+ gnome_calendar_object_changed (ee->gnome_cal, ee->ical, CHANGE_ALL);
gtk_widget_destroy (GTK_WIDGET (ee));
}
@@ -416,8 +436,11 @@ ee_ok (GtkWidget *widget, EventEditor *ee)
static void
ee_cancel (GtkWidget *widget, EventEditor *ee)
{
- if (ee->ical->new)
+ if (ee->ical->new) {
ical_object_destroy (ee->ical);
+ ee->ical = NULL;
+ }
+
gtk_widget_destroy (GTK_WIDGET (ee));
}
@@ -483,7 +506,7 @@ ee_init_general_page (EventEditor *ee)
l = gtk_label_new (_("Owner:"));
gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
- ee->general_owner = gtk_label_new (ee->ical->organizer);
+ ee->general_owner = gtk_label_new (ee->ical->organizer ? ee->ical->organizer : _("?"));
gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4);
@@ -874,11 +897,30 @@ event_editor_init (EventEditor *ee)
ee->ical = 0;
}
+static void
+event_editor_destroy (GtkObject *object)
+{
+ EventEditor *ee;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_EVENT_EDITOR (object));
+
+ ee = EVENT_EDITOR (object);
+
+ if (ee->ical)
+ ical_object_set_user_data (ee->ical, NULL); /* we are no longer editing it */
+}
+
GtkWidget *
event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
{
GtkWidget *retval;
EventEditor *ee;
+
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gdk_flush ();
+
+ printf ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n");
retval = gtk_type_new (event_editor_get_type ());
ee = EVENT_EDITOR (retval);
@@ -886,7 +928,10 @@ event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
if (ical == 0){
ical = ical_new ("Test Comment", user_name, "Test Summary");
ical->new = 1;
- }
+ }
+
+ ical_object_set_user_data (ical, ee); /* so that the world can know we are editing it */
+
ee->ical = ical;
ee->gnome_cal = gcal;
event_editor_init_widgets (ee);
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index 3e6ae677af..7e3d2e0d41 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -60,6 +60,7 @@ struct menu_item {
char *text;
GtkSignalFunc callback;
gpointer data;
+ int sensitive;
};
@@ -288,6 +289,94 @@ child_range_changed (GncalFullDay *fullday, Child *child)
}
static void
+popup_menu (struct menu_item *items, int nitems, guint32 time)
+{
+ GtkWidget *menu;
+ GtkWidget *item;
+ int i;
+
+ menu = gtk_menu_new (); /* FIXME: this baby is never freed */
+
+ for (i = 0; i < nitems; i++) {
+ if (items[i].text) {
+ item = gtk_menu_item_new_with_label (_(items[i].text));
+ gtk_signal_connect (GTK_OBJECT (item), "activate",
+ items[i].callback,
+ items[i].data);
+ gtk_widget_set_sensitive (item, items[i].sensitive);
+ } else
+ item = gtk_menu_item_new ();
+
+ gtk_widget_show (item);
+ gtk_menu_append (GTK_MENU (menu), item);
+ }
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, time);
+}
+
+static void
+new_appointment (GtkWidget *widget, gpointer data)
+{
+ GncalFullDay *fullday;
+
+ fullday = GNCAL_FULL_DAY (data);
+
+ /* FIXME: this should set up the start/end times in the event
+ * editor to whatever the selection range is. If there is no
+ * selection, then default to something sensible, like the row
+ * at which the button was clicked on when popping up the menu.
+ */
+
+ event_editor_new (fullday->calendar, NULL);
+}
+
+static void
+edit_appointment (GtkWidget *widget, gpointer data)
+{
+ Child *child;
+
+ child = data;
+
+ event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
+}
+
+static void
+delete_appointment (GtkWidget *widget, gpointer data)
+{
+ Child *child;
+
+ child = data;
+
+ /* FIXME */
+
+ printf ("Yay! delete_appointment() not yet implemented\n");
+}
+
+static void
+child_popup_menu (GncalFullDay *fullday, Child *child, guint32 event_time)
+{
+ int sensitive;
+
+ static struct menu_item child_items[] = {
+ { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
+ { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
+ { NULL, NULL, NULL, TRUE },
+ { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
+ };
+
+ child_items[0].data = child;
+ child_items[1].data = child;
+ child_items[3].data = fullday;
+
+ sensitive = (ical_object_get_user_data (child->ico) == NULL);
+
+ child_items[0].sensitive = sensitive;
+ child_items[1].sensitive = sensitive;
+
+ popup_menu (child_items, sizeof (child_items) / sizeof (child_items[0]), event_time);
+}
+
+static void
child_realized_setup (GtkWidget *widget, gpointer data)
{
Child *child;
@@ -359,6 +448,24 @@ child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
return FALSE;
}
+static gint
+child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ Child *child;
+ GncalFullDay *fullday;
+
+ if (event->button != 3)
+ return FALSE;
+
+ child = data;
+ fullday = GNCAL_FULL_DAY (widget->parent);
+
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
+ child_popup_menu (fullday, child, event->time);
+
+ return TRUE;
+}
+
static Child *
child_new (GncalFullDay *fullday, iCalObject *ico)
{
@@ -394,6 +501,10 @@ child_new (GncalFullDay *fullday, iCalObject *ico)
(GtkSignalFunc) child_key_press,
child);
+ gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
+ (GtkSignalFunc) child_button_press,
+ child);
+
/* Finish setup */
gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
@@ -1152,16 +1263,19 @@ find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
{
GList *children;
Child *child;
+ GtkWidget *owner;
*on_text = FALSE;
+ gdk_window_get_user_data (window, (gpointer *) &owner);
+
for (children = fullday->children; children; children = children->next) {
child = children->data;
if (child->window == window)
return child;
- if (child->widget->window == window) {
+ if (child->widget == owner) {
*on_text = TRUE;
return child;
}
@@ -1331,81 +1445,11 @@ button_1 (GncalFullDay *fullday, GdkEventButton *event)
return FALSE;
}
-static void
-popup_menu (struct menu_item *items, int nitems, guint32 time)
-{
- GtkWidget *menu;
- GtkWidget *item;
- int i;
-
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
-
- for (i = 0; i < nitems; i++) {
- if (items[i].text) {
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- items[i].callback,
- items[i].data);
- } else
- item = gtk_menu_item_new ();
-
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
- }
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, time);
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (data);
-
- /* FIXME: this should set up the start/end times in the event
- * editor to whatever the selection range is. If there is no
- * selection, then default to something sensible, like the row
- * at which the button was clicked on when popping up the menu.
- */
-
- event_editor_new (fullday->calendar, NULL);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
-
- child = data;
-
- event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
-
- child = data;
-
- /* FIXME */
-
- printf ("Yay! delete_appointment() not yet implemented\n");
-}
-
static int
button_3 (GncalFullDay *fullday, GdkEventButton *event)
{
static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL }
- };
-
- static struct menu_item child_items[] = {
- { N_("Properties..."), (GtkSignalFunc) edit_appointment, NULL },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL },
- { NULL, NULL, NULL },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL }
+ { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
};
GtkWidget *widget;
@@ -1426,14 +1470,10 @@ button_3 (GncalFullDay *fullday, GdkEventButton *event)
} else {
child = find_child_by_window (fullday, event->window, &on_text);
- if (!child)
+ if (!child || on_text)
return FALSE;
- child_items[0].data = child;
- child_items[1].data = child;
- child_items[3].data = fullday;
-
- popup_menu (child_items, sizeof (child_items) / sizeof (child_items[0]), event->time);
+ child_popup_menu (fullday, child, event->time);
return TRUE;
}
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index f55a3e65ca..08bb61fb8b 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -107,11 +107,11 @@ save_calendar_cmd (GtkWidget *widget, void *data)
void
about_calendar_cmd (GtkWidget *widget, void *data)
{
-
GtkWidget *about;
gchar *authors[] = {
"Miguel de Icaza (miguel@kernel.org)",
- "Federico Mena (federico@gimp.org)",
+ "Federico Mena (quartic@gimp.org)",
+ "Arturo Espinosa (arturo@nuclecu.unam.mx)",
NULL
};
diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf
index fc99526bd3..7d41d14878 100644
--- a/calendar/gui/test.vcf
+++ b/calendar/gui/test.vcf
@@ -8,8 +8,8 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980414T003000
-DTEND:19980414T010000
+DTSTART:19980415T003000
+DTEND:19980415T010000
SUMMARY:asdfasdfasfasdfasdf
STATUS:NEEDS ACTION
CLASS:PUBLIC
@@ -25,8 +25,8 @@ DCREATED:19980402T023558
UID:KOrganizer - 846930886
SEQUENCE:1
LAST-MODIFIED:19980402T023558
-DTSTART:19980414T140000
-DTEND:19980414T160000
+DTSTART:19980415T140000
+DTEND:19980415T160000
SUMMARY:asdfasfdasfasdfasfd
STATUS:NEEDS ACTION
CLASS:PUBLIC
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index c3db60f28b..2960e39d35 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -199,4 +199,3 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
g_list_free (l);
}
}
-
diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h
index 828678f56d..8cc4e8a403 100644
--- a/calendar/gui/year-view.h
+++ b/calendar/gui/year-view.h
@@ -49,6 +49,7 @@ struct _GncalYearViewClass {
guint gncal_year_view_get_type (void);
GtkWidget *gncal_year_view_new (GnomeCalendar *calendar, time_t date);
void gncal_year_view_set (GncalYearView *yview, time_t date);
+void gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags);
END_GNOME_DECLS
diff --git a/calendar/main.c b/calendar/main.c
index f55a3e65ca..08bb61fb8b 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -107,11 +107,11 @@ save_calendar_cmd (GtkWidget *widget, void *data)
void
about_calendar_cmd (GtkWidget *widget, void *data)
{
-
GtkWidget *about;
gchar *authors[] = {
"Miguel de Icaza (miguel@kernel.org)",
- "Federico Mena (federico@gimp.org)",
+ "Federico Mena (quartic@gimp.org)",
+ "Arturo Espinosa (arturo@nuclecu.unam.mx)",
NULL
};
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 7e5f535189..a744836c89 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -686,3 +686,15 @@ ical_foreach (GList *events, iCalObjectFn fn, void *closure)
(*fn) (ical, ical->dtstart, ical->dtend, closure);
}
}
+
+void
+ical_object_set_user_data (iCalObject *ical, void *user_data)
+{
+ ical->user_data = user_data;
+}
+
+void *
+ical_object_get_user_data (iCalObject *ical)
+{
+ return ical->user_data;
+}
diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h
index 8f7abf8871..684605b271 100644
--- a/calendar/pcs/calobj.h
+++ b/calendar/pcs/calobj.h
@@ -100,7 +100,8 @@ typedef struct {
typedef enum {
CHANGE_NEW = 1 << 0, /* new object */
CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2 /* dtstart / dtend */
+ CHANGE_DATES = 1 << 2, /* dtstart / dtend */
+ CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
} CalObjectChange;
/*
@@ -151,6 +152,7 @@ typedef struct {
Recurrence *recur;
int new;
+ void *user_data; /* Generic data pointer */
} iCalObject;
/* The callback for the recurrence generator */
@@ -162,6 +164,8 @@ void ical_object_destroy (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
void ical_foreach (GList *events, iCalObjectFn fn, void *closure);
+void ical_object_set_user_data (iCalObject *ical, void *user_data);
+void *ical_object_get_user_data (iCalObject *ical);
END_GNOME_DECLS
diff --git a/calendar/test.vcf b/calendar/test.vcf
index fc99526bd3..7d41d14878 100644
--- a/calendar/test.vcf
+++ b/calendar/test.vcf
@@ -8,8 +8,8 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980414T003000
-DTEND:19980414T010000
+DTSTART:19980415T003000
+DTEND:19980415T010000
SUMMARY:asdfasdfasfasdfasdf
STATUS:NEEDS ACTION
CLASS:PUBLIC
@@ -25,8 +25,8 @@ DCREATED:19980402T023558
UID:KOrganizer - 846930886
SEQUENCE:1
LAST-MODIFIED:19980402T023558
-DTSTART:19980414T140000
-DTEND:19980414T160000
+DTSTART:19980415T140000
+DTEND:19980415T160000
SUMMARY:asdfasfdasfasdfasfd
STATUS:NEEDS ACTION
CLASS:PUBLIC
diff --git a/calendar/timeutil.h b/calendar/timeutil.h
index fa0b865e76..0c91450f47 100644
--- a/calendar/timeutil.h
+++ b/calendar/timeutil.h
@@ -31,6 +31,8 @@ char *format_simple_hour (int hour, int use_am_pm);
time_t time_start_of_day (time_t t);
time_t time_end_of_day (time_t t);
time_t time_day_hour (time_t t, int hour);
+time_t time_year_begin (int year);
+time_t time_year_end (int year);
#endif
diff --git a/calendar/year-view.c b/calendar/year-view.c
index c3db60f28b..2960e39d35 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -199,4 +199,3 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
g_list_free (l);
}
}
-
diff --git a/calendar/year-view.h b/calendar/year-view.h
index 828678f56d..8cc4e8a403 100644
--- a/calendar/year-view.h
+++ b/calendar/year-view.h
@@ -49,6 +49,7 @@ struct _GncalYearViewClass {
guint gncal_year_view_get_type (void);
GtkWidget *gncal_year_view_new (GnomeCalendar *calendar, time_t date);
void gncal_year_view_set (GncalYearView *yview, time_t date);
+void gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags);
END_GNOME_DECLS