diff options
author | Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> | 1998-04-15 10:40:24 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-15 10:40:24 +0800 |
commit | 0e5cfe78a5161e1c98e69f4670552e0d381b3d30 (patch) | |
tree | 058ef3f23121fbd5c87361a951c02b611c384529 /calendar/gui | |
parent | 3161696e57f03b5ebc859907725f6836f4220667 (diff) | |
download | gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.gz gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.zst gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.zip |
New widget for the year view. added required compilation of the new files.
1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
* gncal-year-view.[hc]: New widget for the year view.
* Makefile.am: added required compilation of the new files.
svn path=/trunk/; revision=134
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/eventedit.c | 15 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 22 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 2 | ||||
-rw-r--r-- | calendar/gui/main.c | 2 | ||||
-rw-r--r-- | calendar/gui/test.vcf | 8 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 135 | ||||
-rw-r--r-- | calendar/gui/year-view.h | 52 |
8 files changed, 222 insertions, 16 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 283e46e1c2..b762dae475 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -19,6 +19,8 @@ gnomecal_SOURCES = \ gncal-full-day.h \ gncal-week-view.c \ gncal-week-view.h \ + gncal-year-view.c \ + gncal-year-view.h \ gnome-cal.c \ gnome-cal.h \ main.c \ diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c index 8230c70429..74ad9570ff 100644 --- a/calendar/gui/eventedit.c +++ b/calendar/gui/eventedit.c @@ -140,7 +140,7 @@ event_editor_setup_time_frame (EventEditor *ee) GTK_FILL | GTK_SHRINK, 0, 0); gtk_table_attach (t, start_time, 2, 3, 1, 2, - GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -154,7 +154,7 @@ event_editor_setup_time_frame (EventEditor *ee) GTK_FILL | GTK_SHRINK, 0, 0); gtk_table_attach (t, end_time, 2, 3, 2, 3, - GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -659,7 +659,7 @@ static void ee_rp_init_frequency (EventEditor *ee) { char *day_names [] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; - GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *content, *week_hbox, *week_day, *w; + GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *week_hbox, *week_day, *w; GtkWidget *daily, *weekly, *monthly, *yearly; GtkNotebook *notebook; GSList *group; @@ -805,13 +805,12 @@ ee_rp_init_frequency (EventEditor *ee) 4, 5, 0, 2, 0, 0, 5, 0); gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")), 5, 6, 0, 2, 0, 0, 0, 0); - if (ee->ical->recur){ + if (ee->ical->recur) { if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS) gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1); - } else { - recur_month_enable_date ((re), ee); - } - + } else + recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee); + /* 4. The yearly recurrence */ yearly = gtk_hbox_new (0, 0); ee->recur_year_period = small_entry (year_period); diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index ce64db9173..8c3bf31db2 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -331,13 +331,27 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) /* Notify calendar of change */ - fullday = gtk_object_get_user_data (GTK_OBJECT (widget)); + fullday = GNCAL_FULL_DAY (widget->parent); gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY); return FALSE; } +static gint +child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + if (event->keyval != GDK_Escape) + return FALSE; + + /* If user pressed Esc, un-focus the child by focusing the fullday widget */ + + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event"); + gtk_widget_grab_focus (widget->parent); + + return FALSE; +} + static Child * child_new (GncalFullDay *fullday, iCalObject *ico) { @@ -353,8 +367,6 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->width = 0; child->height = 0; - gtk_object_set_user_data (GTK_OBJECT (child->widget), fullday); - child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -371,6 +383,10 @@ child_new (GncalFullDay *fullday, iCalObject *ico) (GtkSignalFunc) child_focus_out, child); + gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event", + (GtkSignalFunc) child_key_press, + child); + /* Finish setup */ gtk_text_set_editable (GTK_TEXT (child->widget), TRUE); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 8e765bda15..96567ab722 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -11,6 +11,8 @@ #include <libgnome/gnome-defs.h> #include <libgnomeui/gnome-app.h> +#include "calendar.h" + BEGIN_GNOME_DECLS #define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar) diff --git a/calendar/gui/main.c b/calendar/gui/main.c index cd4d107421..f55a3e65ca 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -244,7 +244,7 @@ new_calendar (char *full_name, char *calendar_file) printf ("Trying to load %s\n", calendar_file); gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file); } else { - printf ("tring: ./test.vcf\n"); + printf ("Trying to load ./test.vcf\n"); gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } active_calendars++; diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf index a5d9ad9db6..fc99526bd3 100644 --- a/calendar/gui/test.vcf +++ b/calendar/gui/test.vcf @@ -8,8 +8,8 @@ DCREATED:19980402T023552 UID:KOrganizer - 1804289383 SEQUENCE:1 LAST-MODIFIED:19980330T225948 -DTSTART:19980413T003000 -DTEND:19980413T010000 +DTSTART:19980414T003000 +DTEND:19980414T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980413T140000 -DTEND:19980413T160000 +DTSTART:19980414T140000 +DTEND:19980414T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c new file mode 100644 index 0000000000..d4c2d218df --- /dev/null +++ b/calendar/gui/year-view.c @@ -0,0 +1,135 @@ +/* Week view composite widget for gncal + * + * Copyright (C) 1998 The Free Software Foundation + * + * Author: Arturo Espinosa <arturo@nuclecu.unam.mx> + * + * Heavily based on Federico Mena's week view. + * + */ + +#include <time.h> + +#include "gncal-year-view.h" + +static void gncal_year_view_init (GncalYearView *yview); + +static void +select_day(GtkWidget *widget, gpointer data) +{ + int i; + + GncalYearView *yview; + + yview = GNCAL_YEAR_VIEW(data); + + for (i = 0; i < 12; i++) + gtk_signal_handler_block(GTK_OBJECT(yview->calendar[i]), + yview->handler[i]); + + for (i = 0; i < 12; i++) + if (GTK_CALENDAR(yview->calendar[i]) != GTK_CALENDAR(widget)) + gtk_calendar_select_day(GTK_CALENDAR(yview->calendar[i]), 0); + + for (i = 0; i < 12; i++) + gtk_signal_handler_unblock(GTK_OBJECT(yview->calendar[i]), + yview->handler[i]); +} + +guint +gncal_year_view_get_type (void) +{ + static guint year_view_type = 0; + + if (!year_view_type) { + GtkTypeInfo year_view_info = { + "GncalYearView", + sizeof (GncalYearView), + sizeof (GncalYearViewClass), + (GtkClassInitFunc) NULL, + (GtkObjectInitFunc) gncal_year_view_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + year_view_type = gtk_type_unique (gtk_table_get_type (), + &year_view_info); + } + + return year_view_type; +} + +static void +gncal_year_view_init (GncalYearView *yview) +{ + int i; + + for (i = 0; i < 12; i++) { + yview->calendar[i] = NULL; + yview->handler [i] = 0; + } +} + +GtkWidget * +gncal_year_view_new (int year) +{ + struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + char monthbuff[40]; + GncalYearView *yview; + GtkWidget *frame, *vbox, *label; + int i, x, y; + + yview = gtk_type_new (gncal_year_view_get_type ()); + + gtk_table_set_homogeneous (GTK_TABLE (yview), TRUE); + + yview->year = year; + + for (x = 0; x < 3; x++) + for (y = 0; y < 4; y++) { + + i = y * 3 + x; + + yview->calendar[i] = gtk_calendar_new(); + frame = gtk_frame_new(NULL); + vbox = gtk_vbox_new(0,0); + + yview->handler[i] = + gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), + "day_selected", + GTK_SIGNAL_FUNC(select_day), + (gpointer *) yview); + + my_tm.tm_mon = i; + strftime(monthbuff, 40, "%B", &my_tm); + label = gtk_label_new(monthbuff); + + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_box_pack_start(GTK_BOX(vbox), label, 0, 0, 0); + gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0); + + gtk_table_attach (GTK_TABLE (yview), + GTK_WIDGET (vbox), + x, x + 1, + y, y + 1, + 0, 0, 0, 0); + + gtk_widget_show (frame); + gtk_widget_show (vbox); + gtk_widget_show (GTK_WIDGET (yview->calendar[i])); + } + + gncal_year_view_set (yview, year); + + return GTK_WIDGET (yview); +} + +void gncal_year_view_set (GncalYearView *yview, int year) +{ + int i; + + for (i = 0; i < 12; i++) { + yview->year = year; + gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i + 1, year); + } +} diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h new file mode 100644 index 0000000000..1aedf41299 --- /dev/null +++ b/calendar/gui/year-view.h @@ -0,0 +1,52 @@ +/* Week view composite widget for gncal + * + * Copyright (C) 1998 The Free Software Foundation + * + * Author: Arturo Espinosa <arturo@nuclecu.unam.mx> + * + * Heavily based on Federico Mena's week view. + * + */ + +#ifndef YEAR_VIEW_H +#define YEAR_VIEW_H + + +#include <gtk/gtktable.h> +#include <libgnome/gnome-defs.h> +#include <libgnomeui/gtkcalendar.h> +#include "gnome-cal.h" + +BEGIN_GNOME_DECLS + + +#define GNCAL_YEAR_VIEW(obj) GTK_CHECK_CAST (obj, gncal_year_view_get_type (), GncalYearView) +#define GNCAL_YEAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_year_view_get_type (), GncalYearViewClass) +#define GNCAL_IS_YEAR_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_year_view_get_type ()) + + +typedef struct _GncalYearView GncalYearView; +typedef struct _GncalYearViewClass GncalYearViewClass; + +struct _GncalYearView { + GtkTable table; + + GtkWidget *calendar[12]; /* one calendar per month */ + guint handler[12]; /* for (un)blocking the calendars */ + gint year; +}; + +struct _GncalYearViewClass { + GtkTableClass parent_class; +}; + + +guint gncal_year_view_get_type (void); +GtkWidget *gncal_year_view_new (int year); + +void gncal_year_view_set (GncalYearView *yview, int year); + + +END_GNOME_DECLS + +#endif |