aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-03 12:53:51 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-03 12:53:51 +0800
commitdc90ad6b4302059c79a95d535c8363829faed7df (patch)
tree16d6a6f39048e3e01a8b63de62659230e3924a77 /calendar/gui
parent01b4ff7532756f9202336e59d2f1e401e758fcf9 (diff)
downloadgsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.tar
gsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.tar.gz
gsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.tar.bz2
gsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.tar.lz
gsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.tar.xz
gsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.tar.zst
gsoc2013-evolution-dc90ad6b4302059c79a95d535c8363829faed7df.zip
More calendar work -mig
svn path=/trunk/; revision=98
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am4
-rw-r--r--calendar/gui/calendar.c16
-rw-r--r--calendar/gui/eventedit.c158
-rw-r--r--calendar/gui/eventedit.h38
-rw-r--r--calendar/gui/gnome-cal.h7
-rw-r--r--calendar/gui/main.c16
-rw-r--r--calendar/gui/main.h3
-rw-r--r--calendar/gui/view-utils.c2
8 files changed, 237 insertions, 7 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 6ab68ffb7d..0b715efa5e 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -25,7 +25,9 @@ gnomecal_SOURCES = \
view-utils.h \
view-utils.c \
views.h \
- views.c
+ views.c \
+ eventedit.c \
+ eventedit.h
#gncal_SOURCES = \
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 5d7cb1dd8a..482543b84b 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -87,6 +87,17 @@ calendar_destroy (Calendar *cal)
g_free (cal);
}
+char *
+ice (time_t t)
+{
+ static char buffer [100];
+ struct tm *tm;
+
+ tm = localtime (&t);
+ sprintf (buffer, "%d/%d/%d", tm->tm_mday, tm->tm_mon, tm->tm_year);
+ return buffer;
+}
+
static GList *
calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func)
{
@@ -94,12 +105,13 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompar
for (; objects; objects = objects->next){
iCalObject *object = objects->data;
-
- if ((start <= object->dtstart) && (end >= object->dtend))
+
+ if ((start <= object->dtstart) && (object->dtend <= end)){
if (sort_func)
new_events = g_list_insert_sorted (new_events, object, sort_func);
else
new_events = g_list_prepend (new_events, object);
+ }
}
return new_events;
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
new file mode 100644
index 0000000000..c8a5ad58bf
--- /dev/null
+++ b/calendar/gui/eventedit.c
@@ -0,0 +1,158 @@
+/*
+ * EventEditor widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+
+#include <gnome.h>
+#include "eventedit.h"
+#include "main.h"
+
+static void event_editor_init (EventEditor *ee);
+GtkWindow *parent_class;
+
+guint
+event_editor_get_type (void)
+{
+ static guint event_editor_type = 0;
+
+ if(!event_editor_type) {
+ GtkTypeInfo event_editor_info = {
+ "EventEditor",
+ sizeof(EventEditor),
+ sizeof(EventEditorClass),
+ (GtkClassInitFunc) NULL,
+ (GtkObjectInitFunc) event_editor_init,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL,
+ };
+ event_editor_type = gtk_type_unique (gtk_window_get_type (), &event_editor_info);
+ parent_class = gtk_type_class (gtk_window_get_type ());
+ }
+ return event_editor_type;
+}
+
+/*
+ * when the start time is changed, this adjusts the end time.
+ */
+static void
+adjust_end_time (GtkWidget *widget, EventEditor *ee)
+{
+ struct tm *tm;
+ time_t start_t;
+
+ start_t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
+ tm = localtime (&start_t);
+ if (tm->tm_hour < 22)
+ tm->tm_hour++;
+ gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (tm));
+}
+
+GtkWidget *
+adjust (GtkWidget *w, gfloat x, gfloat y, gfloat xs, gfloat ys)
+{
+ GtkWidget *a = gtk_alignment_new (x, y, xs, ys);
+
+ gtk_container_add (GTK_CONTAINER (a), w);
+ return a;
+}
+
+static GtkWidget *
+event_editor_setup_time_frame (EventEditor *ee)
+{
+ GtkWidget *frame;
+ GtkWidget *start_time, *end_time;
+ GtkTable *t;
+
+ frame = gtk_frame_new (_("Time"));
+ t = GTK_TABLE (ee->general_time_table = gtk_table_new (1, 1, 0));
+ gtk_container_add (GTK_CONTAINER (frame), ee->general_time_table);
+
+ ee->start_time = start_time = gnome_date_edit_new (0);
+ ee->end_time = end_time = gnome_date_edit_new (0);
+ gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_begin, day_end);
+ gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_begin, day_end);
+ gtk_signal_connect (GTK_OBJECT (start_time), "time_changed",
+ GTK_SIGNAL_FUNC (adjust_end_time), ee);
+ gtk_table_attach (t, gtk_label_new (_("Start time")), 1, 2, 1, 2, 0, 0, 0, 0);
+ gtk_table_attach (t, gtk_label_new (_("End time")), 1, 2, 2, 3, 0, 0, 0, 0);
+
+ gtk_table_attach (t, start_time, 2, 3, 1, 2, 0, 0, 0, 0);
+ gtk_table_attach (t, end_time, 2, 3, 2, 3, 0, 0, 0, 0);
+ return frame;
+}
+
+static GtkWidget *
+ee_create_buttons ()
+{
+ return gtk_label_new ("xx");
+}
+
+enum {
+ OWNER_LINE,
+ DESC_LINE,
+ SUMMARY_LINE,
+ TIME_LINE = 4
+};
+
+#define LABEL_SPAN 2
+
+static void
+event_editor_init (EventEditor *ee)
+{
+ GtkWidget *frame, *l;
+
+ ee->hbox = gtk_vbox_new (0, 0);
+ gtk_container_add (GTK_CONTAINER (ee), ee->hbox);
+
+ ee->notebook = gtk_notebook_new ();
+ gtk_box_pack_start (GTK_BOX (ee->hbox), ee->notebook, 1, 1, 0);
+
+ ee->general_table = (GtkTable *) gtk_table_new (1, 1, 0);
+ gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->general_table),
+ gtk_label_new (_("General")));
+
+ l = adjust (gtk_label_new (_("Owner:")), 1.0, 0.5, 1.0, 1.0);
+ gtk_table_attach (ee->general_table, l,
+ 1, LABEL_SPAN, OWNER_LINE, OWNER_LINE + 1, GTK_FILL|GTK_EXPAND, 0, 0, 6);
+
+ ee->general_owner = gtk_label_new ("");
+ gtk_table_attach (ee->general_table, ee->general_owner,
+ LABEL_SPAN, LABEL_SPAN + 1, OWNER_LINE, OWNER_LINE + 1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
+
+ l = gtk_label_new (_("Description:"));
+ gtk_table_attach (ee->general_table, l,
+ 1, LABEL_SPAN, DESC_LINE, DESC_LINE + 1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
+
+ ee->general_summary = gtk_text_new (NULL, NULL);
+ gtk_widget_set_usize (ee->general_summary, 0, 60);
+ gtk_text_set_editable (GTK_TEXT (ee->general_summary), 1);
+ gtk_table_attach (ee->general_table, ee->general_summary,
+ 1, 40, SUMMARY_LINE, SUMMARY_LINE+1, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 6, 0);
+
+ frame = event_editor_setup_time_frame (ee);
+ gtk_table_attach (ee->general_table, frame,
+ 1, 40, TIME_LINE + 2, TIME_LINE + 3,
+ GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+
+ /* Separator */
+ gtk_box_pack_start (GTK_BOX (ee->hbox), gtk_hseparator_new (), 1, 1, 0);
+
+ /* Buttons */
+ gtk_box_pack_start (GTK_BOX (ee->hbox), ee_create_buttons (), 1, 1, 0);
+
+ /* We show all of the contained widgets */
+ gtk_widget_show_all (GTK_WIDGET (ee));
+ /* And we hide the toplevel, to be consistent with the rest of Gtk */
+ gtk_widget_hide (GTK_WIDGET (ee));
+}
+
+GtkWidget *
+event_editor_new (void)
+{
+ GtkWidget *retval;
+
+ retval = gtk_type_new (event_editor_get_type ());
+ return retval;
+}
diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h
new file mode 100644
index 0000000000..edd8059af1
--- /dev/null
+++ b/calendar/gui/eventedit.h
@@ -0,0 +1,38 @@
+/*
+ * EventEditor widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+
+#ifndef EVENT_EDITOR_H
+#define EVENT_EDITOR_H
+
+BEGIN_GNOME_DECLS
+
+#define EVENT_EDITOR(obj) GTK_CHECK_CAST(obj, event_editor_get_type(), EventEditor)
+#define EVENT_EDITOR_CLASS(class) GTK_CHECK_CAST_CLASS(class, event_editor_get_type(), EventEditorClass)
+#define IS_EVENT_EDITOR(obj) GTK_CHECK_TYPE(obj, event_editor_get_type())
+
+typedef struct {
+ GtkWindow gtk_window;
+ GtkWidget *notebook;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+
+ GtkWidget *general;
+ GtkTable *general_table;
+ GtkWidget *general_time_table;
+ GtkWidget *general_owner;
+ GtkWidget *general_summary;
+ GtkWidget *start_time, *end_time;
+} EventEditor;
+
+typedef struct {
+ GnomePropertyBoxClass parent_class;
+} EventEditorClass;
+
+GtkWidget *event_editor_new (void);
+
+END_GNOME_DECLS
+#endif
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 3b2108c560..8a93d18450 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -18,9 +18,10 @@ BEGIN_GNOME_DECLS
#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type())
typedef struct {
- GnomeApp gnome_app;
- Calendar *cal;
- GtkWidget *week_view;
+ GnomeApp gnome_app;
+ Calendar *cal;
+ GtkWidget *week_view;
+ void *event_editor;
} GnomeCalendar;
typedef struct {
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 628626dcb8..0c41fb77a5 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -11,6 +11,7 @@
#include <sys/types.h>
#include "calendar.h"
#include "gnome-cal.h"
+#include "main.h"
/* The username, used to set the `owner' field of the event */
char *user_name;
@@ -119,6 +120,15 @@ about_calendar_cmd (GtkWidget *widget, void *data)
}
void
+display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
+{
+ if (!gcal->event_editor){
+ gcal->event_editor = event_editor_new ();
+ gtk_widget_show (gcal->event_editor);
+ }
+}
+
+void
quit_cmd (GtkWidget *widget, GnomeCalendar *gcal)
{
/* FIXME: check all of the calendars for their state (modified) */
@@ -167,8 +177,14 @@ GnomeUIInfo gnome_cal_about_menu [] = {
GNOMEUIINFO_END
};
+GnomeUIInfo gnome_cal_edit_menu [] = {
+ { GNOME_APP_UI_ITEM, N_("Appointment"), NULL, display_objedit },
+ GNOMEUIINFO_END
+};
+
GnomeUIInfo gnome_cal_menu [] = {
{ GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu },
+ { GNOME_APP_UI_SUBTREE, N_("Edit"), NULL, &gnome_cal_edit_menu },
{ GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu },
GNOMEUIINFO_END
};
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
new file mode 100644
index 0000000000..91ba1e403a
--- /dev/null
+++ b/calendar/gui/main.h
@@ -0,0 +1,3 @@
+
+extern int day_begin, day_end;
+extern char *user_name;
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
index b13fbf7b54..0c661d9dd6 100644
--- a/calendar/gui/view-utils.c
+++ b/calendar/gui/view-utils.c
@@ -79,7 +79,7 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect
str = ico->summary;
if (flags & VIEW_UTILS_DRAW_END) {
- strftime (buf, 512, "%R%p - ", &tm_start);
+ strftime (buf, 512, "%R%p-", &tm_start);
len = strlen (buf);
strftime (buf + len, 512 - len, "%R%p ", &tm_end);
} else