aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorArturo Espinosa Aldama <arturo@nuclecu.unam.mx>1998-04-15 14:47:33 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-15 14:47:33 +0800
commit420485aafa60a9ed46df9b4014074a1423f79dbf (patch)
tree6d8f5b7af3197baa5911648f64e109528eea290a /calendar
parentca50d9fad97731aefa9bca4075ba6f655c6e742e (diff)
downloadgsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.tar
gsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.tar.gz
gsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.tar.bz2
gsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.tar.lz
gsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.tar.xz
gsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.tar.zst
gsoc2013-evolution-420485aafa60a9ed46df9b4014074a1423f79dbf.zip
Now using time_t for new and set. Random fixes, as well.
1998-04-15 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> * gncal-year-view.[hc]: Now using time_t for new and set. Random fixes, as well. svn path=/trunk/; revision=137
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/TODO10
-rw-r--r--calendar/gncal-full-day.c188
-rw-r--r--calendar/gui/gncal-full-day.c188
-rw-r--r--calendar/gui/year-view.c55
-rw-r--r--calendar/gui/year-view.h10
-rw-r--r--calendar/views.c8
-rw-r--r--calendar/year-view.c55
-rw-r--r--calendar/year-view.h10
9 files changed, 420 insertions, 116 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 3381bb9fd3..28eaf35f8d 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,15 @@
+1998-04-15 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
+
+ * gncal-year-view.[hc]: Now using time_t for new and set.
+ Random fixes, as well.
+
+1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
+
+ * gncal-full-day.c (button_3): New popup menus activated with
+ mouse button 3.
+ (create_appointment): Create a new appointment from the popup
+ menus. See the FIXME.
+
1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gncal-full-day.c (layout_kill_rows): Routine to destory rows
diff --git a/calendar/TODO b/calendar/TODO
index 8cb3a2d68b..dfc7e2e2d0 100644
--- a/calendar/TODO
+++ b/calendar/TODO
@@ -10,19 +10,9 @@ Event editor dialog:
Full day view widget:
-- Right-click on background should pop up a menu with "New
- appointment" item.
-
-- Right-click on child should pop up a menu with "Properties" and
- "Remove appointment" items.
-
- Layout the children nicely like M$ Schedule or Netscape Calendar do
(i.e. make them not overlap each other).
-Year view:
-
-- Make use of Arturo's year view code.
-
Month view:
- Write a month view widget.
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
index eac1d3fddc..3e6ae677af 100644
--- a/calendar/gncal-full-day.c
+++ b/calendar/gncal-full-day.c
@@ -9,6 +9,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtktext.h>
+#include "eventedit.h"
#include "gncal-full-day.h"
#include "view-utils.h"
@@ -55,6 +56,12 @@ struct drag_info {
guint32 click_time;
};
+struct menu_item {
+ char *text;
+ GtkSignalFunc callback;
+ gpointer data;
+};
+
enum {
RANGE_ACTIVATED,
@@ -1141,16 +1148,23 @@ gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
}
static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window)
+find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
{
GList *children;
Child *child;
+ *on_text = FALSE;
+
for (children = fullday->children; children; children = children->next) {
child = children->data;
if (child->window == window)
return child;
+
+ if (child->widget->window == window) {
+ *on_text = TRUE;
+ return child;
+ }
}
return NULL;
@@ -1223,21 +1237,12 @@ get_row_from_y (GncalFullDay *fullday, int y, int round)
return y;
}
-static void
+static int
button_1 (GncalFullDay *fullday, GdkEventButton *event)
{
-}
-
-static void
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
+ GtkWidget *widget;
Child *child;
+ int on_text;
struct drag_info *di;
gint y;
int row_height;
@@ -1245,24 +1250,7 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
int old_max;
int paint_start_row, paint_rows_used;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- button_1 (fullday, event);
- break;
-
- case 3:
- button_3 (fullday, event);
- break;
-
- default:
- break;
- }
+ widget = GTK_WIDGET (fullday);
if (event->window == widget->window) {
/* Clicked on main window */
@@ -1306,9 +1294,9 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
} else {
/* Clicked on a child? */
- child = find_child_by_window (fullday, event->window);
+ child = find_child_by_window (fullday, event->window, &on_text);
- if (!child)
+ if (!child || on_text)
return FALSE;
/* Prepare for drag */
@@ -1344,6 +1332,140 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
}
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 }
+ };
+
+ GtkWidget *widget;
+ Child *child;
+ int on_text;
+
+ widget = GTK_WIDGET (fullday);
+
+ if (event->window == widget->window) {
+ /* Clicked on main window */
+
+ if (!GTK_WIDGET_HAS_FOCUS (widget))
+ gtk_widget_grab_focus (widget);
+
+ main_items[0].data = fullday;
+
+ popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event->time);
+ } else {
+ child = find_child_by_window (fullday, event->window, &on_text);
+
+ if (!child)
+ 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);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gint
+gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
+{
+ GncalFullDay *fullday;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ fullday = GNCAL_FULL_DAY (widget);
+
+ switch (event->button) {
+ case 1:
+ return button_1 (fullday, event);
+
+ case 3:
+ return button_3 (fullday, event);
+
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void
recompute_motion (GncalFullDay *fullday, int y)
{
struct drag_info *di;
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index eac1d3fddc..3e6ae677af 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -9,6 +9,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtktext.h>
+#include "eventedit.h"
#include "gncal-full-day.h"
#include "view-utils.h"
@@ -55,6 +56,12 @@ struct drag_info {
guint32 click_time;
};
+struct menu_item {
+ char *text;
+ GtkSignalFunc callback;
+ gpointer data;
+};
+
enum {
RANGE_ACTIVATED,
@@ -1141,16 +1148,23 @@ gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
}
static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window)
+find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
{
GList *children;
Child *child;
+ *on_text = FALSE;
+
for (children = fullday->children; children; children = children->next) {
child = children->data;
if (child->window == window)
return child;
+
+ if (child->widget->window == window) {
+ *on_text = TRUE;
+ return child;
+ }
}
return NULL;
@@ -1223,21 +1237,12 @@ get_row_from_y (GncalFullDay *fullday, int y, int round)
return y;
}
-static void
+static int
button_1 (GncalFullDay *fullday, GdkEventButton *event)
{
-}
-
-static void
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
+ GtkWidget *widget;
Child *child;
+ int on_text;
struct drag_info *di;
gint y;
int row_height;
@@ -1245,24 +1250,7 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
int old_max;
int paint_start_row, paint_rows_used;
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- button_1 (fullday, event);
- break;
-
- case 3:
- button_3 (fullday, event);
- break;
-
- default:
- break;
- }
+ widget = GTK_WIDGET (fullday);
if (event->window == widget->window) {
/* Clicked on main window */
@@ -1306,9 +1294,9 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
} else {
/* Clicked on a child? */
- child = find_child_by_window (fullday, event->window);
+ child = find_child_by_window (fullday, event->window, &on_text);
- if (!child)
+ if (!child || on_text)
return FALSE;
/* Prepare for drag */
@@ -1344,6 +1332,140 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
}
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 }
+ };
+
+ GtkWidget *widget;
+ Child *child;
+ int on_text;
+
+ widget = GTK_WIDGET (fullday);
+
+ if (event->window == widget->window) {
+ /* Clicked on main window */
+
+ if (!GTK_WIDGET_HAS_FOCUS (widget))
+ gtk_widget_grab_focus (widget);
+
+ main_items[0].data = fullday;
+
+ popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event->time);
+ } else {
+ child = find_child_by_window (fullday, event->window, &on_text);
+
+ if (!child)
+ 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);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gint
+gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
+{
+ GncalFullDay *fullday;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ fullday = GNCAL_FULL_DAY (widget);
+
+ switch (event->button) {
+ case 1:
+ return button_1 (fullday, event);
+
+ case 3:
+ return button_3 (fullday, event);
+
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void
recompute_motion (GncalFullDay *fullday, int y)
{
struct drag_info *di;
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index a3ae3ce647..c3d6057086 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -8,8 +8,6 @@
*
*/
-#include <time.h>
-
#include "gncal-year-view.h"
static void gncal_year_view_init (GncalYearView *yview);
@@ -68,29 +66,41 @@ gncal_year_view_init (GncalYearView *yview)
yview->calendar[i] = NULL;
yview->handler [i] = 0;
}
+
+ yview->year_label = NULL;
+ yview->year = 0;
}
GtkWidget *
-gncal_year_view_new (int year)
+gncal_year_view_new (time_t date)
{
struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
char monthbuff[40];
GncalYearView *yview;
GtkWidget *frame, *vbox, *label;
+ struct tm *tmptm;
int i, x, y;
yview = gtk_type_new (gncal_year_view_get_type ());
- gtk_table_set_homogeneous (GTK_TABLE (yview), TRUE);
-
- yview->year = year;
-
+ tmptm = localtime(&date);
+ yview->year = tmptm->tm_year;
+ my_tm.tm_mon = tmptm->tm_year;
+ yview->year_label = gtk_label_new("");
+ gtk_table_attach (GTK_TABLE (yview),
+ GTK_WIDGET (yview->year_label),
+ 1, 2,
+ 0, 1,
+ 0, 0, 0, 5);
+ gtk_widget_show(GTK_WIDGET(yview->year_label));
+
for (x = 0; x < 3; x++)
for (y = 0; y < 4; y++) {
i = y * 3 + x;
yview->calendar[i] = gtk_calendar_new();
+ gtk_calendar_display_options(GTK_CALENDAR(yview->calendar[i]), GTK_CALENDAR_SHOW_DAY_NAMES);
frame = gtk_frame_new(NULL);
vbox = gtk_vbox_new(0,0);
@@ -101,8 +111,7 @@ gncal_year_view_new (int year)
(gpointer *) yview);
my_tm.tm_mon = i;
- my_tm.tm_year = year;
- strftime(monthbuff, sizeof (monthbuff)-1, "%B", &my_tm);
+ strftime(monthbuff, 40, "%B", &my_tm);
label = gtk_label_new(monthbuff);
gtk_container_add(GTK_CONTAINER(frame), vbox);
@@ -110,9 +119,9 @@ gncal_year_view_new (int year)
gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0);
gtk_table_attach (GTK_TABLE (yview),
- GTK_WIDGET (vbox),
+ GTK_WIDGET (frame),
x, x + 1,
- y, y + 1,
+ y + 1, y + 2,
0, 0, 0, 0);
gtk_widget_show (frame);
@@ -120,17 +129,33 @@ gncal_year_view_new (int year)
gtk_widget_show (GTK_WIDGET (yview->calendar[i]));
}
- gncal_year_view_set (yview, year);
+ gncal_year_view_set (yview, date);
return GTK_WIDGET (yview);
}
-void gncal_year_view_set (GncalYearView *yview, int year)
+void gncal_year_view_set (GncalYearView *yview, time_t date)
{
int i;
+ char buff[10];
+ struct tm *tmptm;
+
+ tmptm = localtime(&date);
+ yview->year = tmptm->tm_year;
+
+ snprintf(buff, 10, "%d", yview->year + 1900);
+ gtk_label_set(GTK_LABEL(yview->year_label), buff);
for (i = 0; i < 12; i++) {
- yview->year = year;
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i + 1, year);
+ gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
}
}
+
+/*void
+gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
+{
+ g_return_if_fail (wview != NULL);
+ g_return_if_fail (GNCAL_IS_YEAR_VIEW (wview));
+
+ update (wview, TRUE, ico, flags);
+}*/
diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h
index 1aedf41299..bdd542abda 100644
--- a/calendar/gui/year-view.h
+++ b/calendar/gui/year-view.h
@@ -11,10 +11,12 @@
#ifndef YEAR_VIEW_H
#define YEAR_VIEW_H
-
+#include <time.h>
#include <gtk/gtktable.h>
#include <libgnome/gnome-defs.h>
#include <libgnomeui/gtkcalendar.h>
+
+#include "calendar.h"
#include "gnome-cal.h"
BEGIN_GNOME_DECLS
@@ -33,6 +35,8 @@ struct _GncalYearView {
GtkWidget *calendar[12]; /* one calendar per month */
guint handler[12]; /* for (un)blocking the calendars */
+
+ GtkWidget *year_label;
gint year;
};
@@ -42,9 +46,9 @@ struct _GncalYearViewClass {
guint gncal_year_view_get_type (void);
-GtkWidget *gncal_year_view_new (int year);
+GtkWidget *gncal_year_view_new (time_t date);
-void gncal_year_view_set (GncalYearView *yview, int year);
+void gncal_year_view_set (GncalYearView *yview, time_t date);
END_GNOME_DECLS
diff --git a/calendar/views.c b/calendar/views.c
index a066d789e8..5e09b28754 100644
--- a/calendar/views.c
+++ b/calendar/views.c
@@ -11,23 +11,23 @@
GtkWidget *
day_view_create (GnomeCalendar *gcal)
{
- return gtk_button_new_with_label ("This is supposed to be the Day View");
+ return gtk_label_new ("This is supposed to be the Day View");
}
GtkWidget *
week_view_create (GnomeCalendar *gcal)
{
- return gtk_button_new_with_label ("This is supposed to be the Week View");
+ return gtk_label_new ("This is supposed to be the Week View");
}
GtkWidget *
year_view_create (GnomeCalendar *gcal)
{
- return gtk_button_new_with_label ("This is supposed to be the Year View");
+ return gtk_label_new ("This is supposed to be the Year View");
}
GtkWidget *
tasks_create (GnomeCalendar *gcal)
{
- return gtk_button_new_with_label ("This is supposed to be the Tasks View");
+ return gtk_label_new ("This is supposed to be the Tasks View");
}
diff --git a/calendar/year-view.c b/calendar/year-view.c
index a3ae3ce647..c3d6057086 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -8,8 +8,6 @@
*
*/
-#include <time.h>
-
#include "gncal-year-view.h"
static void gncal_year_view_init (GncalYearView *yview);
@@ -68,29 +66,41 @@ gncal_year_view_init (GncalYearView *yview)
yview->calendar[i] = NULL;
yview->handler [i] = 0;
}
+
+ yview->year_label = NULL;
+ yview->year = 0;
}
GtkWidget *
-gncal_year_view_new (int year)
+gncal_year_view_new (time_t date)
{
struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
char monthbuff[40];
GncalYearView *yview;
GtkWidget *frame, *vbox, *label;
+ struct tm *tmptm;
int i, x, y;
yview = gtk_type_new (gncal_year_view_get_type ());
- gtk_table_set_homogeneous (GTK_TABLE (yview), TRUE);
-
- yview->year = year;
-
+ tmptm = localtime(&date);
+ yview->year = tmptm->tm_year;
+ my_tm.tm_mon = tmptm->tm_year;
+ yview->year_label = gtk_label_new("");
+ gtk_table_attach (GTK_TABLE (yview),
+ GTK_WIDGET (yview->year_label),
+ 1, 2,
+ 0, 1,
+ 0, 0, 0, 5);
+ gtk_widget_show(GTK_WIDGET(yview->year_label));
+
for (x = 0; x < 3; x++)
for (y = 0; y < 4; y++) {
i = y * 3 + x;
yview->calendar[i] = gtk_calendar_new();
+ gtk_calendar_display_options(GTK_CALENDAR(yview->calendar[i]), GTK_CALENDAR_SHOW_DAY_NAMES);
frame = gtk_frame_new(NULL);
vbox = gtk_vbox_new(0,0);
@@ -101,8 +111,7 @@ gncal_year_view_new (int year)
(gpointer *) yview);
my_tm.tm_mon = i;
- my_tm.tm_year = year;
- strftime(monthbuff, sizeof (monthbuff)-1, "%B", &my_tm);
+ strftime(monthbuff, 40, "%B", &my_tm);
label = gtk_label_new(monthbuff);
gtk_container_add(GTK_CONTAINER(frame), vbox);
@@ -110,9 +119,9 @@ gncal_year_view_new (int year)
gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0);
gtk_table_attach (GTK_TABLE (yview),
- GTK_WIDGET (vbox),
+ GTK_WIDGET (frame),
x, x + 1,
- y, y + 1,
+ y + 1, y + 2,
0, 0, 0, 0);
gtk_widget_show (frame);
@@ -120,17 +129,33 @@ gncal_year_view_new (int year)
gtk_widget_show (GTK_WIDGET (yview->calendar[i]));
}
- gncal_year_view_set (yview, year);
+ gncal_year_view_set (yview, date);
return GTK_WIDGET (yview);
}
-void gncal_year_view_set (GncalYearView *yview, int year)
+void gncal_year_view_set (GncalYearView *yview, time_t date)
{
int i;
+ char buff[10];
+ struct tm *tmptm;
+
+ tmptm = localtime(&date);
+ yview->year = tmptm->tm_year;
+
+ snprintf(buff, 10, "%d", yview->year + 1900);
+ gtk_label_set(GTK_LABEL(yview->year_label), buff);
for (i = 0; i < 12; i++) {
- yview->year = year;
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i + 1, year);
+ gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
}
}
+
+/*void
+gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
+{
+ g_return_if_fail (wview != NULL);
+ g_return_if_fail (GNCAL_IS_YEAR_VIEW (wview));
+
+ update (wview, TRUE, ico, flags);
+}*/
diff --git a/calendar/year-view.h b/calendar/year-view.h
index 1aedf41299..bdd542abda 100644
--- a/calendar/year-view.h
+++ b/calendar/year-view.h
@@ -11,10 +11,12 @@
#ifndef YEAR_VIEW_H
#define YEAR_VIEW_H
-
+#include <time.h>
#include <gtk/gtktable.h>
#include <libgnome/gnome-defs.h>
#include <libgnomeui/gtkcalendar.h>
+
+#include "calendar.h"
#include "gnome-cal.h"
BEGIN_GNOME_DECLS
@@ -33,6 +35,8 @@ struct _GncalYearView {
GtkWidget *calendar[12]; /* one calendar per month */
guint handler[12]; /* for (un)blocking the calendars */
+
+ GtkWidget *year_label;
gint year;
};
@@ -42,9 +46,9 @@ struct _GncalYearViewClass {
guint gncal_year_view_get_type (void);
-GtkWidget *gncal_year_view_new (int year);
+GtkWidget *gncal_year_view_new (time_t date);
-void gncal_year_view_set (GncalYearView *yview, int year);
+void gncal_year_view_set (GncalYearView *yview, time_t date);
END_GNOME_DECLS