aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-21 02:00:54 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-21 02:00:54 +0800
commit26e5915000652f4807e337a2b370ce0051972f04 (patch)
treee439a67248bf8c320c79774d6247fb5a3c37a05b /calendar/gui
parentefc1cef1db090cbce9b25260d7f236a21fc7e129 (diff)
downloadgsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.tar
gsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.tar.gz
gsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.tar.bz2
gsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.tar.lz
gsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.tar.xz
gsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.tar.zst
gsoc2013-evolution-26e5915000652f4807e337a2b370ce0051972f04.zip
A lot of usability changes to GnomeCal -miguel
svn path=/trunk/; revision=168
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/eventedit.c96
-rw-r--r--calendar/gui/eventedit.h1
-rw-r--r--calendar/gui/gncal-full-day.c49
-rw-r--r--calendar/gui/gncal-full-day.h2
-rw-r--r--calendar/gui/view-utils.c39
-rw-r--r--calendar/gui/view-utils.h1
6 files changed, 107 insertions, 81 deletions
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index b4063bb17f..de5da85fa6 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -209,13 +209,6 @@ set_all_day (GtkToggleButton *toggle, EventEditor *ee)
gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (tm));
}
-static void
-recur_check_toggled (GtkToggleButton *toggle, EventEditor *ee)
-{
- gtk_widget_set_sensitive (ee->recur_page_label, toggle->active);
- gtk_widget_set_sensitive (ee->recur_table, toggle->active);
-}
-
static GtkWidget *
event_editor_setup_time_frame (EventEditor *ee)
{
@@ -231,7 +224,12 @@ event_editor_setup_time_frame (EventEditor *ee)
gtk_container_add (GTK_CONTAINER (frame), ee->general_time_table);
/* 1. Start time */
+ if (ee->ical->dtstart == 0){
+ ee->ical->dtstart = time (NULL);
+ ee->ical->dtend = time_add_minutes (ee->ical->dtstart, 30);
+ }
ee->start_time = start_time = gnome_date_edit_new (ee->ical->dtstart, TRUE);
+ print_time_t (ee->ical->dtstart);
gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_begin, day_end);
gtk_signal_connect (GTK_OBJECT (start_time), "date_changed",
GTK_SIGNAL_FUNC (check_dates), ee);
@@ -272,13 +270,6 @@ event_editor_setup_time_frame (EventEditor *ee)
4, 0);
ee_check_all_day (ee);
- /* 4. Recurring event checkbox */
- ee->general_recur = gtk_check_button_new_with_label (_("Recurring event"));
- gtk_table_attach (t, ee->general_recur, 3, 4, 2, 3,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 4, 0);
-
return frame;
}
@@ -514,7 +505,7 @@ option_menu_active_number (GtkWidget *omenu)
return ni->num;
}
-static void
+static int
ee_store_recur_rule_to_ical (EventEditor *ee)
{
iCalObject *ical;
@@ -529,14 +520,21 @@ ee_store_recur_rule_to_ical (EventEditor *ee)
i = g_slist_length (ee->recur_rr_group) - i - 1; /* buttons are stored in reverse order of insertion */
+ /* NOne selected, no rule to be stored */
+ if (i == 0)
+ return 0;
+
+ if (!ical->recur)
+ ical->recur = g_new0 (Recurrence, 1);
+
switch (i) {
- case 0:
+ case 1:
/* Daily */
ical->recur->type = RECUR_DAILY;
ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_day_period));
break;
- case 1:
+ case 2:
/* Weekly */
ical->recur->type = RECUR_WEEKLY;
ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_week_period));
@@ -552,7 +550,7 @@ ee_store_recur_rule_to_ical (EventEditor *ee)
break;
- case 2:
+ case 3:
/* Monthly */
if (GTK_WIDGET_SENSITIVE (ee->recur_rr_month_date)) {
@@ -574,7 +572,7 @@ ee_store_recur_rule_to_ical (EventEditor *ee)
break;
- case 3:
+ case 4:
/* Yearly */
ical->recur->type = RECUR_YEARLY_BY_DAY;
/* FIXME: need to specify anything else? I am assuming the code will look at the dtstart
@@ -585,6 +583,7 @@ ee_store_recur_rule_to_ical (EventEditor *ee)
default:
g_assert_not_reached ();
}
+ return 1;
}
static void
@@ -668,16 +667,19 @@ ee_store_recur_exceptions_to_ical (EventEditor *ee)
static void
ee_store_recur_values_to_ical (EventEditor *ee)
{
- if (GTK_TOGGLE_BUTTON (ee->general_recur)->active) {
- if (!ee->ical->recur)
- ee->ical->recur = g_new0 (Recurrence, 1);
-
- ee_store_recur_rule_to_ical (ee);
+ if (ee_store_recur_rule_to_ical (ee)){
ee_store_recur_end_to_ical (ee);
ee_store_recur_exceptions_to_ical (ee);
} else if (ee->ical->recur) {
g_free (ee->ical->recur);
ee->ical->recur = NULL;
+ if (ee->ical->exdate){
+ GList *l = ee->ical->exdate;
+
+ for (; l; l = l->next)
+ g_free (l->data);
+ g_list_free (l);
+ }
}
}
@@ -844,6 +846,7 @@ ee_init_summary_page (EventEditor *ee)
struct {
char *name;
} recurrence_types [] = {
+ { N_("None") },
{ N_("Daily") },
{ N_("Weekly") },
{ N_("Monthly") },
@@ -862,7 +865,7 @@ recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
for (which = 0; list; list = list->next, which++) {
if (list->data == radio) {
- gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_rr_notebook), 3 - which);
+ gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_rr_notebook), 4 - which);
return;
}
}
@@ -933,7 +936,7 @@ ee_rp_init_rule (EventEditor *ee)
{
static char *day_names [] = { N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat"), N_("Sun") };
GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *b, *week_hbox, *week_day, *w;
- GtkWidget *daily, *weekly, *monthly, *yearly;
+ GtkWidget *none, *daily, *weekly, *monthly, *yearly;
GtkNotebook *notebook;
GSList *group;
int i, page, day_period, week_period, month_period, year_period;
@@ -973,37 +976,38 @@ ee_rp_init_rule (EventEditor *ee)
/* Determine which should be the default selection */
+ page = 0;
if (ee->ical->recur) {
enum RecurType type = ee->ical->recur->type;
int interval = ee->ical->recur->interval;
switch (type) {
case RECUR_DAILY:
- page = 0;
+ page = 1;
day_period = interval;
break;
case RECUR_WEEKLY:
- page = 1;
+ page = 2;
week_period = interval;
week_vector = ee->ical->recur->weekday;
break;
case RECUR_MONTHLY_BY_POS:
- page = 2;
+ page = 3;
month_period = interval;
def_pos = ee->ical->recur->u.month_pos;
default_day = ee->ical->recur->u.month_day;
break;
case RECUR_MONTHLY_BY_DAY:
- page = 2;
+ page = 3;
month_period = interval;
default_day = ee->ical->recur->u.month_day;
break;
case RECUR_YEARLY_BY_MONTH:
- page = 3;
+ page = 4;
year_period = interval;
break;
@@ -1028,6 +1032,9 @@ ee_rp_init_rule (EventEditor *ee)
ee->recur_rr_group = group;
+ /* 0. No recurrence */
+ none = gtk_label_new ("");
+
/* 1. The daily recurrence */
daily = gtk_vbox_new (FALSE, 0);
@@ -1123,6 +1130,7 @@ ee_rp_init_rule (EventEditor *ee)
/* Finish setting this up */
+ gtk_notebook_append_page (notebook, none, gtk_label_new (""));
gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
@@ -1144,7 +1152,6 @@ ee_rp_init_rule (EventEditor *ee)
static void
sensitize_by_toggle (GtkToggleButton *toggle, gpointer data)
{
- gtk_widget_set_sensitive (GTK_WIDGET (data), toggle->active);
}
static void
@@ -1197,12 +1204,6 @@ ee_rp_init_ending_date (EventEditor *ee)
ee->recur_ed_end_on = widget = gnome_date_edit_new (enddate, FALSE);
gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
- gtk_signal_connect (GTK_OBJECT (radio1), "toggled",
- (GtkSignalFunc) sensitize_by_toggle,
- ihbox);
-
- gtk_widget_set_sensitive (ihbox, FALSE);
-
/* end after n occurrences */
hbox = gtk_hbox_new (FALSE, 0);
@@ -1226,12 +1227,6 @@ ee_rp_init_ending_date (EventEditor *ee)
widget = gtk_label_new (_("occurrence(s)"));
gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
- gtk_signal_connect (GTK_OBJECT (radio2), "toggled",
- (GtkSignalFunc) sensitize_by_toggle,
- ihbox);
-
- gtk_widget_set_sensitive (ihbox, FALSE);
-
/* Activate appropriate item */
if (ee->ical->recur) {
@@ -1412,17 +1407,6 @@ ee_init_recurrence_page (EventEditor *ee)
ee_rp_init_rule (ee);
ee_rp_init_ending_date (ee);
ee_rp_init_exceptions (ee);
-
- /* Make the recurrence button sensitize the recurrence page */
-
- recur_check_toggled (GTK_TOGGLE_BUTTON (ee->general_recur), ee);
-
- gtk_signal_connect (GTK_OBJECT (ee->general_recur), "toggled",
- (GtkSignalFunc) recur_check_toggled,
- ee);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_recur),
- (ee->ical->recur != NULL));
}
static void
@@ -1484,7 +1468,7 @@ event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
if (ical == 0){
ical = ical_new ("", user_name, "");
- ical->new = 1;
+ ical->new = 1;
}
ical->user_data = ee; /* so that the world can know we are editing it */
diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h
index ccb2224450..c7aa5a8405 100644
--- a/calendar/gui/eventedit.h
+++ b/calendar/gui/eventedit.h
@@ -27,7 +27,6 @@ typedef struct {
GtkWidget *general_table;
GtkWidget *general_time_table;
GtkWidget *general_allday;
- GtkWidget *general_recur;
GtkWidget *general_owner;
GtkWidget *general_summary;
GtkWidget *start_time, *end_time;
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index 1af9daa65f..c18866957b 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -2,7 +2,8 @@
*
* 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 <string.h>
@@ -12,7 +13,7 @@
#include "eventedit.h"
#include "gncal-full-day.h"
#include "view-utils.h"
-
+#include "main.h"
#define TEXT_BORDER 2
#define HANDLE_SIZE 8
@@ -341,16 +342,16 @@ new_appointment (GtkWidget *widget, gpointer data)
{
GncalFullDay *fullday;
GtkWidget *ee;
-
+ iCalObject *ico;
+ time_t lower, upper;
+
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.
- */
-
- ee = event_editor_new (fullday->calendar, NULL);
+ ico = ical_new ("", user_name, "");
+ ico->new = 1;
+
+ gncal_full_day_selection_range (fullday, &ico->dtstart, &ico->dtend);
+ ee = event_editor_new (fullday->calendar, ico);
gtk_widget_show (ee);
}
@@ -695,7 +696,7 @@ calc_labels_width (GncalFullDay *fullday)
struct tm cur, upper;
time_t tim, time_upper;
int width, max_w;
- char buf[256];
+ char buf[40];
get_tm_range (fullday, fullday->lower, fullday->upper, &cur, &upper, NULL, NULL);
@@ -705,7 +706,11 @@ calc_labels_width (GncalFullDay *fullday)
time_upper = mktime (&upper);
while (tim < time_upper) {
- strftime (buf, 256, "%X", &cur);
+ if (am_pm_flag)
+ strftime (buf, sizeof (buf), "%I:%M%p", &cur);
+ else
+ strftime (buf, sizeof (buf), "%H:%M", &cur);
+
width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf);
@@ -1006,7 +1011,7 @@ paint_back (GncalFullDay *fullday, GdkRectangle *area)
int i, y;
GdkGC *gc;
struct tm tm;
- char buf[256];
+ char buf [40];
widget = GTK_WIDGET (fullday);
@@ -1143,7 +1148,10 @@ paint_back (GncalFullDay *fullday, GdkRectangle *area)
mktime (&tm);
if (gdk_rectangle_intersect (&rect, area, &dest)) {
- strftime (buf, 256, "%X", &tm);
+ if (am_pm_flag)
+ strftime (buf, sizeof (buf), "%I:%M%p", &tm);
+ else
+ strftime (buf, sizeof (buf), "%H:%M", &tm);
if ((di->sel_rows_used != 0)
&& (i >= di->sel_start_row)
@@ -1984,8 +1992,19 @@ gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *up
di = fullday->drag_info;
- if (di->sel_rows_used == 0)
+ if (di->sel_rows_used == 0){
+ time_t now = time (NULL);
+ struct tm tm = *localtime (&now);
+ struct tm thisd = *localtime (&fullday->lower);
+
+ thisd.tm_hour = tm.tm_hour;
+ thisd.tm_min = tm.tm_min;
+ thisd.tm_sec = 0;
+ *lower = mktime (&thisd);
+ thisd.tm_hour++;
+ *upper = mktime (&thisd);
return FALSE;
+ }
get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper);
diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h
index ed4d0bf847..97d4d9482d 100644
--- a/calendar/gui/gncal-full-day.h
+++ b/calendar/gui/gncal-full-day.h
@@ -57,6 +57,8 @@ void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower,
/* Returns the selected range in lower and upper. If nothing is
* selected, return value is FALSE, otherwise it is TRUE.
+ * The lower and upper values are always set to proper values, regardless of
+ * the selection value
*/
int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper);
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
index ccbe125291..0c074bd944 100644
--- a/calendar/gui/view-utils.c
+++ b/calendar/gui/view-utils.c
@@ -2,19 +2,41 @@
*
* 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 <string.h>
#include "view-utils.h"
+int am_pm_flag = 0;
+
+char *
+nicetime (struct tm *tm)
+{
+ static char buf [20];
+
+ if (am_pm_flag){
+ if (tm->tm_min)
+ strftime (buf, sizeof (buf), "%I:%M%p", tm);
+ else
+ strftime (buf, sizeof (buf), "%I%p", tm);
+ } else {
+ if (tm->tm_min)
+ strftime (buf, sizeof (buf), "%H:%M", tm);
+ else
+ strftime (buf, sizeof (buf), "%H", tm);
+ }
+ return buf;
+}
+
void
view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
int flags, GList *events, time_t start, time_t end)
{
int font_height;
int x, y, max_y;
- char buf[512];
+ char buf [40];
int len;
struct tm tm_start, tm_end;
char *str;
@@ -35,13 +57,12 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect
tm_end = *localtime (&co->ev_end);
str = ico->summary;
- if (flags & VIEW_UTILS_DRAW_END) {
- strftime (buf, 512, "%X-", &tm_start);
- len = strlen (buf);
- strftime (buf + len, 512 - len, "%X ", &tm_end);
- } else
- strftime (buf, 512, "%X ", &tm_start);
-
+ strcpy (buf, nicetime (&tm_start));
+
+ if (flags & VIEW_UTILS_DRAW_END){
+ strcat (buf, "-");
+ strcat (buf, nicetime (&tm_end));
+ }
gdk_draw_string (window,
widget->style->font,
gc,
diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h
index a1876b6032..ef00dbf848 100644
--- a/calendar/gui/view-utils.h
+++ b/calendar/gui/view-utils.h
@@ -24,5 +24,6 @@ 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;
#endif