aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-04-22 07:55:49 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-22 07:55:49 +0800
commitb707ff2b15af01713ebac9a572b798485bb4b288 (patch)
treee85e0ac644913dcf55bb8fac0fc7325f17c3172f /calendar/gui
parent2c6974eb71de10279567a4b16f487270c6e5eef5 (diff)
downloadgsoc2013-evolution-b707ff2b15af01713ebac9a572b798485bb4b288.tar.gz
gsoc2013-evolution-b707ff2b15af01713ebac9a572b798485bb4b288.tar.zst
gsoc2013-evolution-b707ff2b15af01713ebac9a572b798485bb4b288.zip
Made it use GncalDayPanel.
1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx> * gnome-cal.c: Made it use GncalDayPanel. * gncal-day-panel.c: New widget for the day view in the main calendar toplevel. It basically takes care of everything gnome-cal did by hand with respect to the day view. * Makefile.am (gnomecal_SOURCES): Added gncal-day-panel.[ch] to the rules. * main.c: Added a separator between the About menu item and the help topics. svn path=/trunk/; revision=177
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am2
-rw-r--r--calendar/gui/gncal-day-panel.c198
-rw-r--r--calendar/gui/gncal-day-panel.h61
-rw-r--r--calendar/gui/gncal-week-view.h2
-rw-r--r--calendar/gui/gncal.desktop1
-rw-r--r--calendar/gui/gnome-cal.c127
-rw-r--r--calendar/gui/gnome-cal.h4
-rw-r--r--calendar/gui/main.c1
8 files changed, 290 insertions, 106 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 15e7bf5f95..9c433a771e 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -16,6 +16,8 @@ gnomecal_SOURCES = \
calendar.h \
calobj.c \
calobj.h \
+ gncal-day-panel.c \
+ gncal-day-panel.h \
gncal-day-view.c \
gncal-day-view.h \
gncal-full-day.c \
diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c
new file mode 100644
index 0000000000..d546cda34f
--- /dev/null
+++ b/calendar/gui/gncal-day-panel.c
@@ -0,0 +1,198 @@
+/* Day view notebook panel for gncal
+ *
+ * Copyright (C) 1998 The Free Software Foundation
+ *
+ * Author: Federico Mena <quartic@gimp.org>
+ */
+
+#include "gncal-day-panel.h"
+#include "main.h"
+#include "timeutil.h"
+
+
+guint
+gncal_day_panel_get_type (void)
+{
+ static guint day_panel_type = 0;
+
+ if (!day_panel_type) {
+ GtkTypeInfo day_panel_info = {
+ "GncalDayPanel",
+ sizeof (GncalDayPanel),
+ sizeof (GncalDayPanelClass),
+ (GtkClassInitFunc) NULL,
+ (GtkObjectInitFunc) NULL,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL
+ };
+
+ day_panel_type = gtk_type_unique (gtk_table_get_type (), &day_panel_info);
+ }
+
+ return day_panel_type;
+}
+
+static void
+day_view_range_activated (GncalFullDay *fullday, GncalDayPanel *dpanel)
+{
+ iCalObject *ical;
+
+ ical = ical_new ("", user_name, "");
+ ical->new = 1;
+
+ gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
+
+ gnome_calendar_add_object (dpanel->calendar, ical);
+ gncal_full_day_focus_child (fullday, ical);
+}
+
+static void
+full_day_mapped (GtkWidget *widget, GncalDayPanel *dpanel)
+{
+ GtkAdjustment *adj;
+
+ adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
+
+ adj->value = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
+ gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
+}
+
+static void
+calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
+{
+ gint y, m, d;
+ struct tm tm;
+
+ gtk_calendar_get_date (calendar, &y, &m, &d);
+
+ tm.tm_year = y;
+ tm.tm_mon = m;
+ tm.tm_mday = d;
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+
+ gnome_calendar_goto (dpanel->calendar, mktime (&tm));
+}
+
+GtkWidget *
+gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day)
+{
+ GncalDayPanel *dpanel;
+ GtkWidget *w;
+
+ g_return_val_if_fail (calendar != NULL, NULL);
+
+ dpanel = gtk_type_new (gncal_day_panel_get_type ());
+
+ gtk_container_border_width (GTK_CONTAINER (dpanel), 4);
+ gtk_table_set_row_spacings (GTK_TABLE (dpanel), 4);
+ gtk_table_set_col_spacings (GTK_TABLE (dpanel), 4);
+
+ dpanel->calendar = calendar;
+
+ /* Date label */
+
+ w = gtk_label_new ("");
+ dpanel->date_label = GTK_LABEL (w);
+ gtk_table_attach (GTK_TABLE (dpanel), w,
+ 1, 2, 0, 1,
+ GTK_FILL | GTK_SHRINK,
+ GTK_FILL | GTK_SHRINK,
+ 0, 0);
+ gtk_widget_show (w);
+
+ /* Full day */
+
+ w = gtk_scrolled_window_new (NULL, NULL);
+ dpanel->fullday_sw = GTK_SCROLLED_WINDOW (w);
+ gtk_scrolled_window_set_policy (dpanel->fullday_sw,
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_table_attach (GTK_TABLE (dpanel), w,
+ 1, 2, 1, 3,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ 0, 0);
+ gtk_widget_show (w);
+
+ w = gncal_full_day_new (calendar, time_start_of_day (start_of_day), time_end_of_day (start_of_day));
+ dpanel->fullday = GNCAL_FULL_DAY (w);
+ gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "range_activated",
+ (GtkSignalFunc) day_view_range_activated,
+ dpanel);
+ gtk_container_add (GTK_CONTAINER (dpanel->fullday_sw), w);
+ gtk_widget_show (w);
+
+ /* When the full day widget gets mapped, we'll scroll the list to the proper initial position */
+
+ gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "map",
+ (GtkSignalFunc) full_day_mapped,
+ dpanel);
+
+ /* Gtk calendar */
+
+ w = gtk_calendar_new ();
+ dpanel->gtk_calendar = GTK_CALENDAR (w);
+ gtk_calendar_display_options (dpanel->gtk_calendar,
+ GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);
+ dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "day_selected",
+ (GtkSignalFunc) calendar_day_selected,
+ dpanel);
+ gtk_table_attach (GTK_TABLE (dpanel), w,
+ 0, 1, 1, 2,
+ GTK_FILL | GTK_SHRINK,
+ GTK_FILL | GTK_SHRINK,
+ 0, 0);
+ gtk_widget_show (w);
+
+ /* To-do */
+
+ w = gtk_button_new_with_label ("TODO");
+ dpanel->todo_list = w;
+ gtk_table_attach (GTK_TABLE (dpanel), w,
+ 0, 1, 2, 3,
+ GTK_FILL | GTK_SHRINK,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ 0, 0);
+ gtk_widget_show (w);
+
+ /* Done */
+
+ gncal_day_panel_set (dpanel, start_of_day);
+
+ return GTK_WIDGET (dpanel);
+}
+
+void
+gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags)
+{
+ g_return_if_fail (dpanel != NULL);
+ g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
+
+ gncal_full_day_update (dpanel->fullday, ico, flags);
+}
+
+void
+gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
+{
+ char buf[256];
+ struct tm *tm;
+
+ g_return_if_fail (dpanel != NULL);
+ g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
+
+ dpanel->start_of_day = time_start_of_day (start_of_day);
+
+ strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&dpanel->start_of_day));
+ gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
+
+ gncal_full_day_set_bounds (dpanel->fullday, dpanel->start_of_day, time_end_of_day (dpanel->start_of_day));
+
+ tm = localtime (&dpanel->start_of_day);
+ gtk_calendar_select_month (dpanel->gtk_calendar, tm->tm_mon, tm->tm_year + 1900);
+
+ gtk_signal_handler_block (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
+ gtk_calendar_select_day (dpanel->gtk_calendar, tm->tm_mday);
+ gtk_signal_handler_unblock (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
+}
diff --git a/calendar/gui/gncal-day-panel.h b/calendar/gui/gncal-day-panel.h
new file mode 100644
index 0000000000..aefbd5a3f9
--- /dev/null
+++ b/calendar/gui/gncal-day-panel.h
@@ -0,0 +1,61 @@
+/* Day view notebook panel for gncal
+ *
+ * Copyright (C) 1998 The Free Software Foundation
+ *
+ * Author: Federico Mena <quartic@gimp.org>
+ */
+
+#ifndef GNCAL_DAY_PANEL_H
+#define GNCAL_DAY_PANEL_H
+
+#include <gtk/gtklabel.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtktable.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnomeui/gtkcalendar.h>
+#include "gnome-cal.h"
+#include "gncal-full-day.h"
+
+
+BEGIN_GNOME_DECLS
+
+
+#define GNCAL_DAY_PANEL(obj) GTK_CHECK_CAST (obj, gncal_day_panel_get_type (), GncalDayPanel)
+#define GNCAL_DAY_PANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_panel_get_type (), GncalDayPanelClass)
+#define GNCAL_IS_DAY_PANEL(obj) GTK_CHECK_TYPE (obj, gncal_day_panel_get_type ())
+
+
+typedef struct _GncalDayPanel GncalDayPanel;
+typedef struct _GncalDayPanelClass GncalDayPanelClass;
+
+struct _GncalDayPanel {
+ GtkTable table;
+
+ GnomeCalendar *calendar; /* the calendar we are associated to */
+
+ time_t start_of_day;
+
+ GtkLabel *date_label;
+ GncalFullDay *fullday;
+ GtkScrolledWindow *fullday_sw;
+ GtkCalendar *gtk_calendar;
+ GtkWidget *todo_list;
+
+ guint day_selected_id;
+};
+
+struct _GncalDayPanelClass {
+ GtkTableClass parent_class;
+};
+
+
+guint gncal_day_panel_get_type (void);
+GtkWidget *gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day);
+
+void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
+void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
+
+
+END_GNOME_DECLS
+
+#endif
diff --git a/calendar/gui/gncal-week-view.h b/calendar/gui/gncal-week-view.h
index 9df1e35b91..16dfa40eb0 100644
--- a/calendar/gui/gncal-week-view.h
+++ b/calendar/gui/gncal-week-view.h
@@ -12,8 +12,8 @@
#include <gtk/gtktable.h>
#include <libgnome/gnome-defs.h>
#include <libgnomeui/gtkcalendar.h>
-#include "gncal-day-view.h"
#include "gnome-cal.h"
+#include "gncal-day-view.h"
BEGIN_GNOME_DECLS
diff --git a/calendar/gui/gncal.desktop b/calendar/gui/gncal.desktop
index 6c784e9c7b..840965c27c 100644
--- a/calendar/gui/gncal.desktop
+++ b/calendar/gui/gncal.desktop
@@ -4,6 +4,7 @@ Name[es]=Calendario
Name[fr]=Calendrier
Name[de]=Kalender
Comment=Calendar application
+Comment[es]=Calendario de Gnome
Comment[fr]=Calendrier Gnome
Comment[de]=Gnome Kalender
Exec=gnomecal
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index bc26be5c92..a71e7fb343 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -11,15 +11,13 @@
#include <sys/wait.h>
#include "calendar.h"
#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-year-view.h"
+#include "gncal-day-panel.h"
#include "gncal-week-view.h"
+#include "gncal-year-view.h"
#include "timeutil.h"
#include "views.h"
#include "main.h"
-static void gnome_calendar_init (GnomeCalendar *gcal);
-
GnomeApp *parent_class;
guint
@@ -32,7 +30,7 @@ gnome_calendar_get_type (void)
sizeof(GnomeCalendar),
sizeof(GnomeCalendarClass),
(GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gnome_calendar_init,
+ (GtkObjectInitFunc) NULL,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
};
@@ -43,70 +41,6 @@ gnome_calendar_get_type (void)
}
static void
-day_view_range_activated (GncalFullDay *fullday, GnomeCalendar *gcal)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (gcal, ical);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-set_day_view_label (GnomeCalendar *gcal, time_t t)
-{
- static char buf[256];
-
- strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&t));
- gtk_label_set (GTK_LABEL (gcal->day_view_label), buf);
-}
-
-static void
-setup_day_view (GnomeCalendar *gcal, time_t now)
-{
- GtkTable *t;
- GtkWidget *sw;
-
- time_t a, b;
-
- a = time_start_of_day (now);
- b = time_end_of_day (now);
-
- gcal->day_view = gncal_full_day_new (gcal, a, b);
- gtk_signal_connect (GTK_OBJECT (gcal->day_view), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- gcal);
-
- t = (GtkTable *) gcal->day_view_container = gtk_table_new (0, 0, 0);
- gtk_container_border_width (GTK_CONTAINER (t), 4);
- gtk_table_set_row_spacings (t, 4);
- gtk_table_set_col_spacings (t, 4);
-
- gcal->day_view_label = gtk_label_new ("");
- set_day_view_label (gcal, now);
- gtk_table_attach (t, gcal->day_view_label, 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_table_attach (t, sw, 0, 1, 1, 2,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK,
- 0, 0);
- gtk_container_add (GTK_CONTAINER (sw), gcal->day_view);
-
- gtk_widget_show_all (GTK_WIDGET (t));
-}
-
-static void
setup_widgets (GnomeCalendar *gcal)
{
time_t now;
@@ -114,13 +48,12 @@ setup_widgets (GnomeCalendar *gcal)
now = time (NULL);
gcal->notebook = gtk_notebook_new ();
+ gcal->day_view = gncal_day_panel_new (gcal, now);
gcal->week_view = gncal_week_view_new (gcal, now);
gcal->year_view = gncal_year_view_new (gcal, now);
gcal->task_view = tasks_create (gcal);
- setup_day_view (gcal, now);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view_container, gtk_label_new (_("Day View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
/* gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo"))); */
@@ -131,16 +64,6 @@ setup_widgets (GnomeCalendar *gcal)
}
-static void
-gnome_calendar_init(GnomeCalendar *gcal)
-{
- gcal->cal = 0;
- gcal->day_view = 0;
- gcal->week_view = 0;
- gcal->year_view = 0;
- gcal->event_editor = 0;
-}
-
static GtkWidget *
get_current_page (GnomeCalendar *gcal)
{
@@ -153,17 +76,17 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
GtkWidget *current = get_current_page (gcal);
g_assert (new_time != -1);
- if (current == gcal->week_view)
+ if (current == gcal->day_view)
+ 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->day_view_container){
- gncal_full_day_set_bounds (GNCAL_FULL_DAY (gcal->day_view),
- time_start_of_day (new_time),
- time_end_of_day (new_time));
- set_day_view_label (gcal, new_time);
- } else if (current == gcal->year_view)
+ else if (current == gcal->year_view)
gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time);
- else
- printf ("My penguin is gone!\n");
+ else {
+ g_warning ("My penguin is gone!");
+ g_assert_not_reached ();
+ }
+
gcal->current_display = new_time;
}
@@ -173,22 +96,24 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
GtkWidget *cp = get_current_page (gcal);
time_t new_time;
- if (cp == gcal->week_view)
- new_time = time_add_day (gcal->current_display, 7 * direction);
- else if (cp == gcal->day_view_container)
+ 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);
else if (cp == gcal->year_view)
new_time = time_add_year (gcal->current_display, 1 * direction);
- else
+ else {
g_warning ("Weee! Where did the penguin go?");
-
+ g_assert_not_reached ();
+ }
+
gnome_calendar_goto (gcal, new_time);
}
void
gnome_calendar_next (GnomeCalendar *gcal)
{
-gnome_calendar_direction (gcal, 1);
+ gnome_calendar_direction (gcal, 1);
}
void
@@ -229,7 +154,7 @@ gnome_calendar_new (char *title)
static void
gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
{
- gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view), object, 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);
gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
}
@@ -358,14 +283,14 @@ calendar_notify (time_t time, void *data)
if (ico->malarm.enabled && ico->malarm.trigger == time){
char *command;
time_t app = ico->malarm.trigger + ico->malarm.offset;
-
+
command = g_copy_strings ("mail -s '",
_("Reminder of your appointment at "),
ctime (&app), "' '",
ico->malarm.data, "' ",
NULL);
execute (command, 1);
-
+
g_free (command);
return;
}
@@ -383,5 +308,3 @@ calendar_notify (time_t time, void *data)
return;
}
}
-
-
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 88e5fc5b6d..653244b075 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -25,10 +25,8 @@ typedef struct {
time_t current_display;
GtkWidget *notebook;
- GtkWidget *week_view;
GtkWidget *day_view;
- GtkWidget *day_view_container;
- GtkWidget *day_view_label;
+ GtkWidget *week_view;
GtkWidget *year_view;
GtkWidget *task_view;
void *event_editor;
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 14a4a183a1..0f70bb1cd4 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -298,6 +298,7 @@ static GnomeUIInfo gnome_cal_file_menu [] = {
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 },
+ GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_HELP ("cal"),
GNOMEUIINFO_END
};