aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/gnome-cal.c29
-rw-r--r--calendar/gui/gnome-cal.h4
-rw-r--r--calendar/gui/gnome-month-item.h21
-rw-r--r--calendar/gui/main.c66
-rw-r--r--calendar/gui/month-view.c91
-rw-r--r--calendar/gui/month-view.h12
-rw-r--r--calendar/gui/prop.c3
7 files changed, 176 insertions, 50 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index e3f1250687..c9c62101b9 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -51,7 +51,7 @@ setup_widgets (GnomeCalendar *gcal)
gcal->notebook = gtk_notebook_new ();
gcal->day_view = gncal_day_panel_new (gcal, now);
gcal->week_view = gncal_week_view_new (gcal, now);
- gcal->month_view = month_view_new (gcal);
+ gcal->month_view = month_view_new (gcal, now);
gcal->year_view = gncal_year_view_new (gcal, now);
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
@@ -80,6 +80,8 @@ gnome_calendar_get_current_view_name (GnomeCalendar *gcal)
return "dayview";
else if (page == gcal->week_view)
return "weekview";
+ else if (page == gcal->month_view)
+ return "monthview";
else if (page == gcal->year_view)
return "yearview";
else
@@ -99,6 +101,8 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time);
else if (current == gcal->week_view)
gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
+ else if (current == gcal->month_view)
+ month_view_set (MONTH_VIEW (gcal->month_view), new_time);
else if (current == gcal->year_view)
gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time);
else {
@@ -118,7 +122,9 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
if (cp == gcal->day_view)
new_time = time_add_day (gcal->current_display, 1 * direction);
else if (cp == gcal->week_view)
- new_time = time_add_day (gcal->current_display, 7 * direction);
+ new_time = time_add_week (gcal->current_display, 1 * direction);
+ else if (cp == gcal->month_view)
+ new_time = time_add_month (gcal->current_display, 1 * direction);
else if (cp == gcal->year_view)
new_time = time_add_year (gcal->current_display, 1 * direction);
else {
@@ -164,8 +170,10 @@ gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name)
page = 0;
else if (strcmp (page_name, "weekview") == 0)
page = 1;
- else if (strcmp (page_name, "yearview") == 0)
+ else if (strcmp (page_name, "monthview") == 0)
page = 2;
+ else if (strcmp (page_name, "yearview") == 0)
+ page = 3;
gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page);
}
@@ -196,6 +204,7 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
{
gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags);
gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags);
+ month_view_update (MONTH_VIEW (cal->month_view), object, flags);
gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
}
@@ -417,3 +426,17 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
gtk_calendar_thaw (gtk_cal);
}
+
+void
+gnome_calendar_time_format_changed (GnomeCalendar *gcal)
+{
+ g_return_if_fail (gcal != NULL);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
+ /* FIXME: the queue resizes will do until we rewrite those views... */
+
+ gtk_widget_queue_resize (gcal->day_view);
+ gtk_widget_queue_resize (gcal->week_view);
+ month_view_time_format_changed (MONTH_VIEW (gcal->month_view));
+ gtk_widget_queue_resize (gcal->year_view);
+}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 0d6c9525d9..186e90bc83 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -64,6 +64,10 @@ void gnome_calendar_object_changed (GnomeCalendar *gcal,
iCalObject *obj,
int flags);
+/* Notifies the calendar that the time format has changed and it must update all its views */
+void gnome_calendar_time_format_changed (GnomeCalendar *gcal);
+
+
END_GNOME_DECLS
#endif
diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h
index b1b11f9d01..03ba0c84a7 100644
--- a/calendar/gui/gnome-month-item.h
+++ b/calendar/gui/gnome-month-item.h
@@ -46,6 +46,27 @@ typedef enum {
GNOME_MONTH_ITEM_LAST = 147 /* total number of items */
} GnomeMonthItemChild;
+/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of
+ * canvas items, which can be accessed using the functions provided. The monthly calendar is
+ * anchored with respect to a point. The following arguments are available:
+ *
+ * name type read/write description
+ * ------------------------------------------------------------------------------------------
+ * year uint RW Full year (1-9999)
+ * month uint RW Number of month (0-11)
+ * x double RW X position of anchor point
+ * y double RW Y position of anchor point
+ * width double RW Width of calendar in canvas units
+ * height double RW Height of calendar in canvas units
+ * anchor GtkAnchorType RW Anchor side for calendar
+ * head_padding double RW Padding inside heading boxes
+ * day_padding double RW Padding inside day boxes
+ * day_names char ** R Array of strings corresponding to the day names (sun-sat)
+ * heading_height double RW Height of headings bar in canvas units
+ * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes
+ * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes
+ * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday
+ */
#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ())
#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem))
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 55aa861e0c..9f8bcae2dd 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -4,7 +4,7 @@
*
* Authors:
* Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
+ * Federico Mena (federico@nuclecu.unam.mx)
*/
#include <config.h>
@@ -193,13 +193,8 @@ time_format_changed (void)
{
GList *l;
- /* FIXME: update all the calendars and stuff */
-
- for (l = all_calendars; l; l = l->next){
- GnomeCalendar *cal = GNOME_CALENDAR (l->data);
-
- gtk_widget_queue_resize (cal->notebook);
- }
+ for (l = all_calendars; l; l = l->next)
+ gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data));
}
static void
@@ -327,66 +322,51 @@ save_calendar_cmd (GtkWidget *widget, void *data)
}
static GnomeUIInfo gnome_cal_file_menu [] = {
- { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW },
+ GNOMEUIINFO_ITEM_STOCK (N_("New calendar"), NULL, new_calendar_cmd, GNOME_STOCK_MENU_NEW),
+ GNOMEUIINFO_ITEM_STOCK (N_("Open calendar..."), NULL, open_calendar_cmd, GNOME_STOCK_MENU_OPEN),
+ GNOMEUIINFO_ITEM_STOCK (N_("Save calendar"), NULL, save_calendar_cmd, GNOME_STOCK_MENU_SAVE),
+ GNOMEUIINFO_ITEM_STOCK (N_("Save calendar as..."), NULL, save_as_calendar_cmd, GNOME_STOCK_MENU_SAVE),
- { GNOME_APP_UI_ITEM, N_("Open calendar..."), NULL, open_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN },
-
- { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
+ GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Save calendar as..."), NULL, save_as_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
+ GNOMEUIINFO_ITEM_STOCK (N_("Preferences..."), NULL, properties, GNOME_STOCK_MENU_PREF),
- { GNOME_APP_UI_SEPARATOR },
- { GNOME_APP_UI_ITEM, N_("Close this calendar"), NULL, close_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
+ GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
+ GNOMEUIINFO_ITEM_STOCK (N_("Close this calendar"), NULL, close_cmd, GNOME_STOCK_MENU_EXIT),
+ GNOMEUIINFO_ITEM_STOCK (N_("Exit"), NULL, quit_cmd, GNOME_STOCK_MENU_EXIT),
GNOMEUIINFO_END
};
-static GnomeUIInfo gnome_cal_about_menu [] = {
- { GNOME_APP_UI_ITEM, N_("About..."), NULL, about_calendar_cmd, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT },
+static GnomeUIInfo gnome_cal_help_menu [] = {
+ GNOMEUIINFO_ITEM_STOCK (N_("About Gnomecal..."), NULL, about_calendar_cmd, GNOME_STOCK_MENU_ABOUT),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_HELP ("cal"),
GNOMEUIINFO_END
};
static GnomeUIInfo gnome_cal_edit_menu [] = {
- { GNOME_APP_UI_ITEM, N_("New appointment..."), NULL, display_objedit },
- { GNOME_APP_UI_ITEM, N_("New appointment for today..."), NULL, display_objedit_today },
- GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Preferences..."), NULL, properties, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF },
+ GNOMEUIINFO_ITEM_STOCK (N_("New appointment..."), NULL, display_objedit, GNOME_STOCK_MENU_NEW),
+ GNOMEUIINFO_ITEM_STOCK (N_("New appointment for today..."), NULL, display_objedit_today, GNOME_STOCK_MENU_NEW),
GNOMEUIINFO_END
};
static GnomeUIInfo gnome_cal_menu [] = {
- { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu },
- { GNOME_APP_UI_SUBTREE, N_("Calendar"), NULL, &gnome_cal_edit_menu },
- { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu },
+ GNOMEUIINFO_SUBTREE (N_("File"), &gnome_cal_file_menu),
+ GNOMEUIINFO_SUBTREE (N_("Edit"), &gnome_cal_edit_menu),
+ GNOMEUIINFO_SUBTREE (N_("Help"), &gnome_cal_help_menu),
GNOMEUIINFO_END
};
static GnomeUIInfo gnome_toolbar [] = {
- { GNOME_APP_UI_ITEM, N_("New"), N_("Create a new appointment"), display_objedit, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW },
+ GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), display_objedit, GNOME_STOCK_PIXMAP_NEW),
GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Prev"), N_("Go back in time"), previous_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK },
-
- { GNOME_APP_UI_ITEM, N_("Today"), N_("Go to present time"), today_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HOME },
-
- { GNOME_APP_UI_ITEM, N_("Next"), N_("Go forward in time"), next_clicked, 0, 0,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD },
+ GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_MENU_BACK),
+ GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME),
+ GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_MENU_FORWARD),
GNOMEUIINFO_SEPARATOR,
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
index de6b89db2b..0abc717366 100644
--- a/calendar/gui/month-view.c
+++ b/calendar/gui/month-view.c
@@ -6,10 +6,14 @@
*/
#include <config.h>
+#include <libgnomeui/gnome-canvas-text.h>
#include "month-view.h"
#include "main.h"
+#define SPACING 4 /* Spacing between title and calendar */
+
+
static void month_view_class_init (MonthViewClass *class);
static void month_view_init (MonthView *mv);
static void month_view_size_request (GtkWidget *widget,
@@ -60,6 +64,17 @@ month_view_class_init (MonthViewClass *class)
static void
month_view_init (MonthView *mv)
{
+ /* Title */
+
+ mv->title = gnome_canvas_item_new (GNOME_CANVAS_GROUP (mv->canvas.root),
+ gnome_canvas_text_get_type (),
+ "anchor", GTK_ANCHOR_N,
+ "font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1",
+ "fill_color", "black",
+ NULL);
+
+ /* Month item */
+
mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root));
gnome_canvas_item_set (mv->mitem,
"x", 0.0,
@@ -71,16 +86,17 @@ month_view_init (MonthView *mv)
}
GtkWidget *
-month_view_new (GnomeCalendar *calendar)
+month_view_new (GnomeCalendar *calendar, time_t month)
{
MonthView *mv;
g_return_val_if_fail (calendar != NULL, NULL);
mv = gtk_type_new (month_view_get_type ());
-
mv->calendar = calendar;
+ month_view_set (mv, month);
+
return GTK_WIDGET (mv);
}
@@ -102,6 +118,9 @@ static void
month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
MonthView *mv;
+ GdkFont *font;
+ GtkArg arg;
+ int y;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -113,8 +132,74 @@ month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height);
+
+ /* Adjust items to new size */
+
+ arg.name = "font_gdk";
+ gtk_object_getv (GTK_OBJECT (mv->title), 1, &arg);
+ font = GTK_VALUE_BOXED (arg);
+
+ gnome_canvas_item_set (mv->title,
+ "x", (double) allocation->width / 2.0,
+ "y", (double) SPACING,
+ NULL);
+
+ y = font->ascent + font->descent + 2 * SPACING;
gnome_canvas_item_set (mv->mitem,
+ "y", (double) y,
"width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
+ "height", (double) (allocation->height - y - 1),
+ NULL);
+
+ /* FIXME: adjust events */
+}
+
+void
+month_view_update (MonthView *mv, iCalObject *object, int flags)
+{
+ g_return_if_fail (mv != NULL);
+ g_return_if_fail (IS_MONTH_VIEW (mv));
+
+ /* FIXME */
+}
+
+void
+month_view_set (MonthView *mv, time_t month)
+{
+ struct tm *tm;
+ char buf[100];
+
+ g_return_if_fail (mv != NULL);
+ g_return_if_fail (IS_MONTH_VIEW (mv));
+
+ /* Title */
+
+ tm = localtime (&month);
+ strftime (buf, 100, "%B %Y", tm);
+
+ gnome_canvas_item_set (mv->title,
+ "text", buf,
+ NULL);
+
+ /* Month item */
+
+ gnome_canvas_item_set (mv->mitem,
+ "year", tm->tm_year + 1900,
+ "month", tm->tm_mon,
NULL);
+
+ /* FIXME: update events */
+}
+
+void
+month_view_time_format_changed (MonthView *mv)
+{
+ g_return_if_fail (mv != NULL);
+ g_return_if_fail (IS_MONTH_VIEW (mv));
+
+ gnome_canvas_item_set (mv->mitem,
+ "start_on_monday", week_starts_on_monday,
+ NULL);
+
+ /* FIXME: update events */
}
diff --git a/calendar/gui/month-view.h b/calendar/gui/month-view.h
index 0f35817d78..a164332f98 100644
--- a/calendar/gui/month-view.h
+++ b/calendar/gui/month-view.h
@@ -31,6 +31,7 @@ struct _MonthView {
GnomeCalendar *calendar; /* The calendar we are associated to */
+ GnomeCanvasItem *title; /* The title heading with the month/year */
GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
};
@@ -43,7 +44,16 @@ struct _MonthViewClass {
GtkType month_view_get_type (void);
/* Creates a new month view widget associated to the specified calendar */
-GtkWidget *month_view_new (GnomeCalendar *calendar);
+GtkWidget *month_view_new (GnomeCalendar *calendar, time_t month);
+
+/* Notifies the month view that a calendar object has changed */
+void month_view_update (MonthView *mv, iCalObject *ico, int flags);
+
+/* Notifies the month view about a change of date */
+void month_view_set (MonthView *mv, time_t month);
+
+/* Notifies the month view that the time format has changed */
+void month_view_time_format_changed (MonthView *mv);
END_GNOME_DECLS
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
index c339230a1a..709d321229 100644
--- a/calendar/gui/prop.c
+++ b/calendar/gui/prop.c
@@ -101,6 +101,7 @@ build_two_radio_group (char *title,
gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value);
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value);
gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled",
(GtkSignalFunc) toggled,
@@ -135,6 +136,8 @@ hour_activated (GtkWidget *widget, gpointer data)
gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end);
} else
g_assert_not_reached ();
+
+ gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
}
/* Builds an option menu of 24 hours */