diff options
author | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-22 13:19:51 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-22 13:19:51 +0800 |
commit | 821548d922e719881f5dff34a34b3d6285b10855 (patch) | |
tree | 54c20eeb1fc960a4a0d5ea864741efb8215d09e5 /calendar/gui | |
parent | 6b159ed2c33a1a208395f9b57b7d61d7c1d04842 (diff) | |
download | gsoc2013-evolution-821548d922e719881f5dff34a34b3d6285b10855.tar.gz gsoc2013-evolution-821548d922e719881f5dff34a34b3d6285b10855.tar.zst gsoc2013-evolution-821548d922e719881f5dff34a34b3d6285b10855.zip |
1. Calendar property configuration is finally here with nice live-updates.
1. Calendar property configuration is finally here with
nice live-updates.
2. Double clicking on week view jumps to that day in the
day view; Context menu allows adding an appointment
on that day.
Miguel.
svn path=/trunk/; revision=182
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/Makefile.am | 1 | ||||
-rw-r--r-- | calendar/gui/gncal-day-view.c | 62 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 34 | ||||
-rw-r--r-- | calendar/gui/gncal-week-view.c | 2 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 1 | ||||
-rw-r--r-- | calendar/gui/main.c | 25 | ||||
-rw-r--r-- | calendar/gui/main.h | 4 | ||||
-rw-r--r-- | calendar/gui/view-utils.c | 34 | ||||
-rw-r--r-- | calendar/gui/view-utils.h | 10 |
9 files changed, 127 insertions, 46 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 9c433a771e..61ace641f3 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -30,6 +30,7 @@ gnomecal_SOURCES = \ gnome-cal.c \ gnome-cal.h \ main.c \ + prop.c \ timeutil.c \ timeutil.h \ view-utils.h \ diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c index e62d6ba2e6..59c11eab69 100644 --- a/calendar/gui/gncal-day-view.c +++ b/calendar/gui/gncal-day-view.c @@ -2,14 +2,16 @@ * * Copyright (C) 1998 The Free Software Foundation * - * Author: Federico Mena <quartic@gimp.org> + * Authors: Federico Mena <quartic@gimp.org> + * Miguel de Icaza <miguel@kernel.org> */ #include <gtk/gtksignal.h> #include "gncal-day-view.h" #include "timeutil.h" #include "view-utils.h" - +#include "main.h" +#include "eventedit.h" #define TEXT_BORDER 2 #define MIN_INFO_WIDTH 50 @@ -23,6 +25,8 @@ static void gncal_day_view_size_request (GtkWidget *widget, GtkRequisition *requisition); static gint gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event); +static gint gncal_day_view_button_press (GtkWidget *widget, + GdkEventButton *event); static GtkWidgetClass *parent_class; @@ -66,6 +70,7 @@ gncal_day_view_class_init (GncalDayViewClass *class) widget_class->realize = gncal_day_view_realize; widget_class->size_request = gncal_day_view_size_request; widget_class->expose_event = gncal_day_view_expose; + widget_class->button_press_event = gncal_day_view_button_press; } static void @@ -100,6 +105,59 @@ gncal_day_view_destroy (GtkObject *object) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } +static int +new_appointment (GtkWidget *widget, gpointer data) +{ + GncalDayView *dayview = GNCAL_DAY_VIEW (data); + iCalObject *ico; + GtkWidget *ee; + struct tm tm; + + ico = ical_new ("", user_name, ""); + ico->new = 1; + + tm = *localtime (&dayview->lower); + tm.tm_hour = day_begin; + ico->dtstart = mktime (&tm); + tm.tm_hour++; + ico->dtend = mktime (&tm); + ee = event_editor_new (dayview->calendar, ico); + gtk_widget_show (ee); + return 1; +} + +static void +context_menu (GncalDayView *dayview, GdkEventButton *event) +{ + static struct menu_item main_items[] = { + { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE } + }; + + main_items [0].data = dayview; + popup_menu (main_items, 1, event->time); +} + +static void +switch_to_day (GncalDayView *dayview) +{ +} + +static gint +gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event) +{ + GncalDayView *dayview; + + dayview = GNCAL_DAY_VIEW (widget); + + if (event->button == 3) + context_menu (dayview, event); + + if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) + gnome_calendar_dayjump (dayview->calendar, dayview->lower); + + return TRUE; +} + GtkWidget * gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper) { diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 2aa614c70a..02ac1aece2 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -61,14 +61,6 @@ struct drag_info { guint32 click_time; }; -struct menu_item { - char *text; - GtkSignalFunc callback; - gpointer data; - int sensitive; -}; - - enum { RANGE_ACTIVATED, LAST_SIGNAL @@ -313,32 +305,6 @@ child_range_changed (GncalFullDay *fullday, Child *child) } 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); - gtk_widget_set_sensitive (item, items[i].sensitive); - } 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; diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c index ab5e7fbea0..2a389f5fe5 100644 --- a/calendar/gui/gncal-week-view.c +++ b/calendar/gui/gncal-week-view.c @@ -8,7 +8,7 @@ #include <string.h> #include "gncal-week-view.h" - +#include "timeutil.h" static void gncal_week_view_init (GncalWeekView *wview); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index e1c300071d..755785836a 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -106,6 +106,7 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction) else { g_warning ("Weee! Where did the penguin go?"); g_assert_not_reached (); + new_time = 0; } gnome_calendar_goto (gcal, new_time); diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 77abc20866..581004ac82 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -93,11 +93,11 @@ init_calendar (void) { init_username (); user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf"); - calendar_settings = g_copy_strings ("=", gnome_util_user_home (), ".gnome/calendar=", NULL); gnome_config_push_prefix (calendar_settings); - day_begin = range_check_hour (gnome_config_get_int ("/Calendar/Day start=8")); - day_end = range_check_hour (gnome_config_get_int ("/Calendar/Day end=17")); + day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8")); + day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17")); + am_pm_flag = range_check_hour (gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0")); if (day_end < day_begin){ day_begin = 8; @@ -155,6 +155,21 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal) gtk_main_quit (); } +/* + * Updates all of the open calendars when the day_begin/day_end values have changed + */ +void +day_range_changed (void) +{ + GList *l; + + for (l = all_calendars; l; l = l->next){ + GnomeCalendar *cal = GNOME_CALENDAR (l->data); + + gtk_widget_queue_draw (cal->notebook); + } +} + static void quit_cmd (GtkWidget *widget, GnomeCalendar *gcal) { @@ -306,6 +321,8 @@ static GnomeUIInfo gnome_cal_about_menu [] = { static GnomeUIInfo gnome_cal_edit_menu [] = { { GNOME_APP_UI_ITEM, N_("New appointment"), NULL, display_objedit }, + { GNOME_APP_UI_ITEM, N_("Properties"), NULL, properties, NULL, NULL, + GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP }, GNOMEUIINFO_END }; @@ -490,7 +507,7 @@ main(int argc, char *argv[]) bindtextdomain(PACKAGE, GNOMELOCALEDIR); textdomain(PACKAGE); - gnome_init ("gncal", &parser, argc, argv, 0, NULL); + gnome_init ("calendar", &parser, argc, argv, 0, NULL); process_dates (); alarm_init (); diff --git a/calendar/gui/main.h b/calendar/gui/main.h index 91ba1e403a..adab317549 100644 --- a/calendar/gui/main.h +++ b/calendar/gui/main.h @@ -1,3 +1,7 @@ extern int day_begin, day_end; extern char *user_name; +extern int am_pm_flag; + +void properties (void); +void day_range_changed (void); diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c index 62cb86fc7c..e8b78deeca 100644 --- a/calendar/gui/view-utils.c +++ b/calendar/gui/view-utils.c @@ -18,14 +18,14 @@ nicetime (struct tm *tm) if (am_pm_flag){ if (tm->tm_min) - strftime (buf, sizeof (buf), "%I:%M%p", tm); + strftime (buf, sizeof (buf), "%l:%M%p", tm); else - strftime (buf, sizeof (buf), "%I%p", tm); + strftime (buf, sizeof (buf), "%l%p", tm); } else { if (tm->tm_min) - strftime (buf, sizeof (buf), "%H:%M", tm); + strftime (buf, sizeof (buf), "%k:%M", tm); else - strftime (buf, sizeof (buf), "%H", tm); + strftime (buf, sizeof (buf), "%k", tm); } return buf; } @@ -124,3 +124,29 @@ view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectang rect->x, rect->y, rect->width, rect->height); } + +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); + gtk_widget_set_sensitive (item, items[i].sensitive); + } 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); +} diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h index ef00dbf848..f351b4885d 100644 --- a/calendar/gui/view-utils.h +++ b/calendar/gui/view-utils.h @@ -24,6 +24,14 @@ void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, Gd void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow); -extern int am_pm_flag; + +struct menu_item { + char *text; + GtkSignalFunc callback; + gpointer data; + int sensitive; +}; + +void popup_menu (struct menu_item *items, int nitems, guint32 time); #endif |