aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gncal-full-day.c
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 /calendar/gui/gncal-full-day.c
parentf89cf24d2093c9982e461a2478d0acb4eeacc408 (diff)
downloadgsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar
gsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar.gz
gsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar.bz2
gsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar.lz
gsoc2013-evolution-77d15722d272941f67af74f5abb1eef1a21a4644.tar.xz
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
Diffstat (limited to 'calendar/gui/gncal-full-day.c')
-rw-r--r--calendar/gui/gncal-full-day.c196
1 files changed, 118 insertions, 78 deletions
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;
}