aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog19
-rw-r--r--calendar/Makefile.am1
-rw-r--r--calendar/gncal-day-view.c62
-rw-r--r--calendar/gncal-full-day.c34
-rw-r--r--calendar/gncal-week-view.c2
-rw-r--r--calendar/gnome-cal.c1
-rw-r--r--calendar/gui/Makefile.am1
-rw-r--r--calendar/gui/gncal-day-view.c62
-rw-r--r--calendar/gui/gncal-full-day.c34
-rw-r--r--calendar/gui/gncal-week-view.c2
-rw-r--r--calendar/gui/gnome-cal.c1
-rw-r--r--calendar/gui/main.c25
-rw-r--r--calendar/gui/main.h4
-rw-r--r--calendar/gui/view-utils.c34
-rw-r--r--calendar/gui/view-utils.h10
-rw-r--r--calendar/main.c25
-rw-r--r--calendar/main.h4
-rw-r--r--calendar/timeutil.c2
-rw-r--r--calendar/view-utils.c34
-rw-r--r--calendar/view-utils.h10
20 files changed, 274 insertions, 93 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 108bb0e832..39878e6174 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,24 @@
+1998-04-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * prop.c (properties): Added Calendar properties editor.
+
+ * main.c: Save/load properties (fix to old commit).
+
1998-04-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
+ * timeutil.c (isodate_from_time_t): Do not save with the global
+ time flag (Z at the end of the isodate). When we figure out a way
+ to load times in GMT time, we will add this back
+
+ * view-utils.c (popup_menu): Moved this routine here as there are
+ more users of this code.
+
+ * gncal-day-view.c (gncal_day_view_class_init): Add button press
+ handler.
+ (new_appointment): New routine for creating appointments on a day.
+
+
+
* main.c (save_ok): Added call to gtk_window_set_wmclass.
* gncal-day-panel.c (calendar_day_selected): Fix, years for mktime
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index 9c433a771e..61ace641f3 100644
--- a/calendar/Makefile.am
+++ b/calendar/Makefile.am
@@ -30,6 +30,7 @@ gnomecal_SOURCES = \
gnome-cal.c \
gnome-cal.h \
main.c \
+ prop.c \
timeutil.c \
timeutil.h \
view-utils.h \
diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c
index e62d6ba2e6..59c11eab69 100644
--- a/calendar/gncal-day-view.c
+++ b/calendar/gncal-day-view.c
@@ -2,14 +2,16 @@
*
* Copyright (C) 1998 The Free Software Foundation
*
- * Author: Federico Mena <quartic@gimp.org>
+ * Authors: Federico Mena <quartic@gimp.org>
+ * Miguel de Icaza <miguel@kernel.org>
*/
#include <gtk/gtksignal.h>
#include "gncal-day-view.h"
#include "timeutil.h"
#include "view-utils.h"
-
+#include "main.h"
+#include "eventedit.h"
#define TEXT_BORDER 2
#define MIN_INFO_WIDTH 50
@@ -23,6 +25,8 @@ static void gncal_day_view_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gint gncal_day_view_expose (GtkWidget *widget,
GdkEventExpose *event);
+static gint gncal_day_view_button_press (GtkWidget *widget,
+ GdkEventButton *event);
static GtkWidgetClass *parent_class;
@@ -66,6 +70,7 @@ gncal_day_view_class_init (GncalDayViewClass *class)
widget_class->realize = gncal_day_view_realize;
widget_class->size_request = gncal_day_view_size_request;
widget_class->expose_event = gncal_day_view_expose;
+ widget_class->button_press_event = gncal_day_view_button_press;
}
static void
@@ -100,6 +105,59 @@ gncal_day_view_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
+static int
+new_appointment (GtkWidget *widget, gpointer data)
+{
+ GncalDayView *dayview = GNCAL_DAY_VIEW (data);
+ iCalObject *ico;
+ GtkWidget *ee;
+ struct tm tm;
+
+ ico = ical_new ("", user_name, "");
+ ico->new = 1;
+
+ tm = *localtime (&dayview->lower);
+ tm.tm_hour = day_begin;
+ ico->dtstart = mktime (&tm);
+ tm.tm_hour++;
+ ico->dtend = mktime (&tm);
+ ee = event_editor_new (dayview->calendar, ico);
+ gtk_widget_show (ee);
+ return 1;
+}
+
+static void
+context_menu (GncalDayView *dayview, GdkEventButton *event)
+{
+ static struct menu_item main_items[] = {
+ { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
+ };
+
+ main_items [0].data = dayview;
+ popup_menu (main_items, 1, event->time);
+}
+
+static void
+switch_to_day (GncalDayView *dayview)
+{
+}
+
+static gint
+gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
+{
+ GncalDayView *dayview;
+
+ dayview = GNCAL_DAY_VIEW (widget);
+
+ if (event->button == 3)
+ context_menu (dayview, event);
+
+ if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
+ gnome_calendar_dayjump (dayview->calendar, dayview->lower);
+
+ return TRUE;
+}
+
GtkWidget *
gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
{
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
index 2aa614c70a..02ac1aece2 100644
--- a/calendar/gncal-full-day.c
+++ b/calendar/gncal-full-day.c
@@ -61,14 +61,6 @@ struct drag_info {
guint32 click_time;
};
-struct menu_item {
- char *text;
- GtkSignalFunc callback;
- gpointer data;
- int sensitive;
-};
-
-
enum {
RANGE_ACTIVATED,
LAST_SIGNAL
@@ -313,32 +305,6 @@ 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;
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
index ab5e7fbea0..2a389f5fe5 100644
--- a/calendar/gncal-week-view.c
+++ b/calendar/gncal-week-view.c
@@ -8,7 +8,7 @@
#include <string.h>
#include "gncal-week-view.h"
-
+#include "timeutil.h"
static void gncal_week_view_init (GncalWeekView *wview);
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index e1c300071d..755785836a 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -106,6 +106,7 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
else {
g_warning ("Weee! Where did the penguin go?");
g_assert_not_reached ();
+ new_time = 0;
}
gnome_calendar_goto (gcal, new_time);
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 9c433a771e..61ace641f3 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -30,6 +30,7 @@ gnomecal_SOURCES = \
gnome-cal.c \
gnome-cal.h \
main.c \
+ prop.c \
timeutil.c \
timeutil.h \
view-utils.h \
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
index e62d6ba2e6..59c11eab69 100644
--- a/calendar/gui/gncal-day-view.c
+++ b/calendar/gui/gncal-day-view.c
@@ -2,14 +2,16 @@
*
* Copyright (C) 1998 The Free Software Foundation
*
- * Author: Federico Mena <quartic@gimp.org>
+ * Authors: Federico Mena <quartic@gimp.org>
+ * Miguel de Icaza <miguel@kernel.org>
*/
#include <gtk/gtksignal.h>
#include "gncal-day-view.h"
#include "timeutil.h"
#include "view-utils.h"
-
+#include "main.h"
+#include "eventedit.h"
#define TEXT_BORDER 2
#define MIN_INFO_WIDTH 50
@@ -23,6 +25,8 @@ static void gncal_day_view_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gint gncal_day_view_expose (GtkWidget *widget,
GdkEventExpose *event);
+static gint gncal_day_view_button_press (GtkWidget *widget,
+ GdkEventButton *event);
static GtkWidgetClass *parent_class;
@@ -66,6 +70,7 @@ gncal_day_view_class_init (GncalDayViewClass *class)
widget_class->realize = gncal_day_view_realize;
widget_class->size_request = gncal_day_view_size_request;
widget_class->expose_event = gncal_day_view_expose;
+ widget_class->button_press_event = gncal_day_view_button_press;
}
static void
@@ -100,6 +105,59 @@ gncal_day_view_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
+static int
+new_appointment (GtkWidget *widget, gpointer data)
+{
+ GncalDayView *dayview = GNCAL_DAY_VIEW (data);
+ iCalObject *ico;
+ GtkWidget *ee;
+ struct tm tm;
+
+ ico = ical_new ("", user_name, "");
+ ico->new = 1;
+
+ tm = *localtime (&dayview->lower);
+ tm.tm_hour = day_begin;
+ ico->dtstart = mktime (&tm);
+ tm.tm_hour++;
+ ico->dtend = mktime (&tm);
+ ee = event_editor_new (dayview->calendar, ico);
+ gtk_widget_show (ee);
+ return 1;
+}
+
+static void
+context_menu (GncalDayView *dayview, GdkEventButton *event)
+{
+ static struct menu_item main_items[] = {
+ { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
+ };
+
+ main_items [0].data = dayview;
+ popup_menu (main_items, 1, event->time);
+}
+
+static void
+switch_to_day (GncalDayView *dayview)
+{
+}
+
+static gint
+gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
+{
+ GncalDayView *dayview;
+
+ dayview = GNCAL_DAY_VIEW (widget);
+
+ if (event->button == 3)
+ context_menu (dayview, event);
+
+ if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
+ gnome_calendar_dayjump (dayview->calendar, dayview->lower);
+
+ return TRUE;
+}
+
GtkWidget *
gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
{
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index 2aa614c70a..02ac1aece2 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -61,14 +61,6 @@ struct drag_info {
guint32 click_time;
};
-struct menu_item {
- char *text;
- GtkSignalFunc callback;
- gpointer data;
- int sensitive;
-};
-
-
enum {
RANGE_ACTIVATED,
LAST_SIGNAL
@@ -313,32 +305,6 @@ 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;
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
index ab5e7fbea0..2a389f5fe5 100644
--- a/calendar/gui/gncal-week-view.c
+++ b/calendar/gui/gncal-week-view.c
@@ -8,7 +8,7 @@
#include <string.h>
#include "gncal-week-view.h"
-
+#include "timeutil.h"
static void gncal_week_view_init (GncalWeekView *wview);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index e1c300071d..755785836a 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -106,6 +106,7 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
else {
g_warning ("Weee! Where did the penguin go?");
g_assert_not_reached ();
+ new_time = 0;
}
gnome_calendar_goto (gcal, new_time);
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 77abc20866..581004ac82 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -93,11 +93,11 @@ init_calendar (void)
{
init_username ();
user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
- calendar_settings = g_copy_strings ("=", gnome_util_user_home (), ".gnome/calendar=", NULL);
gnome_config_push_prefix (calendar_settings);
- day_begin = range_check_hour (gnome_config_get_int ("/Calendar/Day start=8"));
- day_end = range_check_hour (gnome_config_get_int ("/Calendar/Day end=17"));
+ day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8"));
+ day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17"));
+ am_pm_flag = range_check_hour (gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"));
if (day_end < day_begin){
day_begin = 8;
@@ -155,6 +155,21 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
gtk_main_quit ();
}
+/*
+ * Updates all of the open calendars when the day_begin/day_end values have changed
+ */
+void
+day_range_changed (void)
+{
+ GList *l;
+
+ for (l = all_calendars; l; l = l->next){
+ GnomeCalendar *cal = GNOME_CALENDAR (l->data);
+
+ gtk_widget_queue_draw (cal->notebook);
+ }
+}
+
static void
quit_cmd (GtkWidget *widget, GnomeCalendar *gcal)
{
@@ -306,6 +321,8 @@ static GnomeUIInfo gnome_cal_about_menu [] = {
static GnomeUIInfo gnome_cal_edit_menu [] = {
{ GNOME_APP_UI_ITEM, N_("New appointment"), NULL, display_objedit },
+ { GNOME_APP_UI_ITEM, N_("Properties"), NULL, properties, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP },
GNOMEUIINFO_END
};
@@ -490,7 +507,7 @@ main(int argc, char *argv[])
bindtextdomain(PACKAGE, GNOMELOCALEDIR);
textdomain(PACKAGE);
- gnome_init ("gncal", &parser, argc, argv, 0, NULL);
+ gnome_init ("calendar", &parser, argc, argv, 0, NULL);
process_dates ();
alarm_init ();
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
index 91ba1e403a..adab317549 100644
--- a/calendar/gui/main.h
+++ b/calendar/gui/main.h
@@ -1,3 +1,7 @@
extern int day_begin, day_end;
extern char *user_name;
+extern int am_pm_flag;
+
+void properties (void);
+void day_range_changed (void);
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
index 62cb86fc7c..e8b78deeca 100644
--- a/calendar/gui/view-utils.c
+++ b/calendar/gui/view-utils.c
@@ -18,14 +18,14 @@ nicetime (struct tm *tm)
if (am_pm_flag){
if (tm->tm_min)
- strftime (buf, sizeof (buf), "%I:%M%p", tm);
+ strftime (buf, sizeof (buf), "%l:%M%p", tm);
else
- strftime (buf, sizeof (buf), "%I%p", tm);
+ strftime (buf, sizeof (buf), "%l%p", tm);
} else {
if (tm->tm_min)
- strftime (buf, sizeof (buf), "%H:%M", tm);
+ strftime (buf, sizeof (buf), "%k:%M", tm);
else
- strftime (buf, sizeof (buf), "%H", tm);
+ strftime (buf, sizeof (buf), "%k", tm);
}
return buf;
}
@@ -124,3 +124,29 @@ view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectang
rect->x, rect->y,
rect->width, rect->height);
}
+
+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);
+}
diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h
index ef00dbf848..f351b4885d 100644
--- a/calendar/gui/view-utils.h
+++ b/calendar/gui/view-utils.h
@@ -24,6 +24,14 @@ void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, Gd
void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-extern int am_pm_flag;
+
+struct menu_item {
+ char *text;
+ GtkSignalFunc callback;
+ gpointer data;
+ int sensitive;
+};
+
+void popup_menu (struct menu_item *items, int nitems, guint32 time);
#endif
diff --git a/calendar/main.c b/calendar/main.c
index 77abc20866..581004ac82 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -93,11 +93,11 @@ init_calendar (void)
{
init_username ();
user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
- calendar_settings = g_copy_strings ("=", gnome_util_user_home (), ".gnome/calendar=", NULL);
gnome_config_push_prefix (calendar_settings);
- day_begin = range_check_hour (gnome_config_get_int ("/Calendar/Day start=8"));
- day_end = range_check_hour (gnome_config_get_int ("/Calendar/Day end=17"));
+ day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8"));
+ day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17"));
+ am_pm_flag = range_check_hour (gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"));
if (day_end < day_begin){
day_begin = 8;
@@ -155,6 +155,21 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
gtk_main_quit ();
}
+/*
+ * Updates all of the open calendars when the day_begin/day_end values have changed
+ */
+void
+day_range_changed (void)
+{
+ GList *l;
+
+ for (l = all_calendars; l; l = l->next){
+ GnomeCalendar *cal = GNOME_CALENDAR (l->data);
+
+ gtk_widget_queue_draw (cal->notebook);
+ }
+}
+
static void
quit_cmd (GtkWidget *widget, GnomeCalendar *gcal)
{
@@ -306,6 +321,8 @@ static GnomeUIInfo gnome_cal_about_menu [] = {
static GnomeUIInfo gnome_cal_edit_menu [] = {
{ GNOME_APP_UI_ITEM, N_("New appointment"), NULL, display_objedit },
+ { GNOME_APP_UI_ITEM, N_("Properties"), NULL, properties, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP },
GNOMEUIINFO_END
};
@@ -490,7 +507,7 @@ main(int argc, char *argv[])
bindtextdomain(PACKAGE, GNOMELOCALEDIR);
textdomain(PACKAGE);
- gnome_init ("gncal", &parser, argc, argv, 0, NULL);
+ gnome_init ("calendar", &parser, argc, argv, 0, NULL);
process_dates ();
alarm_init ();
diff --git a/calendar/main.h b/calendar/main.h
index 91ba1e403a..adab317549 100644
--- a/calendar/main.h
+++ b/calendar/main.h
@@ -1,3 +1,7 @@
extern int day_begin, day_end;
extern char *user_name;
+extern int am_pm_flag;
+
+void properties (void);
+void day_range_changed (void);
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
index 85652d3146..61df809a93 100644
--- a/calendar/timeutil.c
+++ b/calendar/timeutil.c
@@ -57,7 +57,7 @@ isodate_from_time_t (time_t t)
static char isotime [40];
tm = localtime (&t);
- strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%SZ", tm);
+ strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S ", tm);
return isotime;
}
diff --git a/calendar/view-utils.c b/calendar/view-utils.c
index 62cb86fc7c..e8b78deeca 100644
--- a/calendar/view-utils.c
+++ b/calendar/view-utils.c
@@ -18,14 +18,14 @@ nicetime (struct tm *tm)
if (am_pm_flag){
if (tm->tm_min)
- strftime (buf, sizeof (buf), "%I:%M%p", tm);
+ strftime (buf, sizeof (buf), "%l:%M%p", tm);
else
- strftime (buf, sizeof (buf), "%I%p", tm);
+ strftime (buf, sizeof (buf), "%l%p", tm);
} else {
if (tm->tm_min)
- strftime (buf, sizeof (buf), "%H:%M", tm);
+ strftime (buf, sizeof (buf), "%k:%M", tm);
else
- strftime (buf, sizeof (buf), "%H", tm);
+ strftime (buf, sizeof (buf), "%k", tm);
}
return buf;
}
@@ -124,3 +124,29 @@ view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectang
rect->x, rect->y,
rect->width, rect->height);
}
+
+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);
+}
diff --git a/calendar/view-utils.h b/calendar/view-utils.h
index ef00dbf848..f351b4885d 100644
--- a/calendar/view-utils.h
+++ b/calendar/view-utils.h
@@ -24,6 +24,14 @@ void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, Gd
void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-extern int am_pm_flag;
+
+struct menu_item {
+ char *text;
+ GtkSignalFunc callback;
+ gpointer data;
+ int sensitive;
+};
+
+void popup_menu (struct menu_item *items, int nitems, guint32 time);
#endif