aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog18
-rw-r--r--calendar/gui/calendar-commands.c7
-rw-r--r--calendar/gui/e-day-view.c2
-rw-r--r--calendar/gui/e-week-view.c105
-rw-r--r--calendar/gui/e-week-view.h5
-rw-r--r--calendar/gui/gnome-cal.h4
6 files changed, 138 insertions, 3 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 657bc588ea..80f10623fa 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,21 @@
+2000-06-17 Damon Chaplin <damon@helixcode.com>
+
+ * gui/e-week-view.c: added little buttons which are shown when there
+ are more events than will fit in a day. Clicking on the button takes
+ the user to the 1-Day view and shows the full day.
+
+ * gui/e-day-view.c:
+ * gui/e-week-view.c: set the "use_ellipsis" arg to TRUE for the EText
+ items so we get tooltips automatically. Though we may want to use our
+ own code to show tooltips so we can show the tips when the mouse is
+ around the edges of the event box, and we may want to show the start
+ and end times of the event in full.
+
+ * gui/calendar-commands.c (calendar_control_activate):
+ * gui/gnome-cal.h: added view_toolbar_buttons[] so we can access the
+ radio buttons in the code easily. We need this if we want to jump to
+ another view programmatically.
+
2000-06-16 Damon Chaplin <damon@helixcode.com>
* gui/jump.xpm: new icon for the EWeekView to jump to the day.
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index 0a4d12f93a..730dbdce26 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -594,7 +594,7 @@ calendar_control_activate (BonoboControl *control,
GnomeUIBuilderData uibdata;
BonoboUIHandler *uih = bonobo_control_get_ui_handler (control);
gchar *page_name;
- gint button;
+ gint button, i;
g_assert (uih);
uibdata.connect_func = do_ui_signal_connect;
@@ -616,6 +616,9 @@ calendar_control_activate (BonoboControl *control,
/*gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));*/
+ for (i = 0; i < GNOME_CALENDAR_NUM_VIEWS; i++)
+ cal->view_toolbar_buttons[i] = gnome_toolbar_view_buttons[i].widget;
+
/* Note that these indices should correspond with the button indices
in gnome_toolbar_view_buttons. */
page_name = gnome_calendar_get_current_view_name (cal);
@@ -634,7 +637,7 @@ calendar_control_activate (BonoboControl *control,
button = 0;
}
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gnome_toolbar_view_buttons[button].widget), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cal->view_toolbar_buttons[i]), TRUE);
gtk_widget_show_all (toolbar);
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index e0e13664f2..ff7753cd54 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -3347,6 +3347,7 @@ e_day_view_reshape_long_event (EDayView *day_view,
"clip", TRUE,
"max_lines", 1,
"editable", TRUE,
+ "use_ellipsis", TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (event->canvas_item), "event",
GTK_SIGNAL_FUNC (e_day_view_on_text_item_event),
@@ -3703,6 +3704,7 @@ e_day_view_reshape_day_event (EDayView *day_view,
"line_wrap", TRUE,
"editable", TRUE,
"clip", TRUE,
+ "use_ellipsis", TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (event->canvas_item),
"event",
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 7f5eb7b15f..96eacac213 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -29,6 +29,8 @@
#include <config.h>
#include <math.h>
#include <gnome.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
#include "calendar-commands.h"
#include "e-week-view.h"
#include "e-week-view-event-item.h"
@@ -43,6 +45,8 @@
#include "bell.xpm"
#include "recur.xpm"
+#include "jump.xpm"
+
#define E_WEEK_VIEW_SMALL_FONT \
"-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*"
#define E_WEEK_VIEW_SMALL_FONT_FALLBACK \
@@ -53,6 +57,12 @@
reached anyway. */
#define E_WEEK_VIEW_MAX_ROWS_PER_CELL 127
+#define E_WEEK_VIEW_JUMP_BUTTON_WIDTH 16
+#define E_WEEK_VIEW_JUMP_BUTTON_HEIGHT 8
+
+#define E_WEEK_VIEW_JUMP_BUTTON_X_PAD 3
+#define E_WEEK_VIEW_JUMP_BUTTON_Y_PAD 3
+
static void e_week_view_class_init (EWeekViewClass *class);
static void e_week_view_init (EWeekView *week_view);
static void e_week_view_destroy (GtkObject *object);
@@ -138,6 +148,9 @@ static void e_week_view_foreach_event_with_uid (EWeekView *week_view,
static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *event,
EWeekView *week_view);
+static gboolean e_week_view_on_jump_button_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ EWeekView *week_view);
static gint e_week_view_key_press (GtkWidget *widget, GdkEventKey *event);
static void e_week_view_on_new_appointment (GtkWidget *widget,
gpointer data);
@@ -218,6 +231,8 @@ e_week_view_init (EWeekView *week_view)
gint nfailed;
GnomeCanvasGroup *canvas_group;
GtkObject *adjustment;
+ GdkPixbuf *pixbuf;
+ gint i;
GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS);
@@ -329,6 +344,23 @@ e_week_view_init (EWeekView *week_view)
GTK_SIGNAL_FUNC (e_week_view_on_motion),
week_view);
+ /* Create the buttons to jump to each days. */
+ pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**) jump_xpm);
+
+ for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) {
+ week_view->jump_buttons[i] = gnome_canvas_item_new
+ (canvas_group,
+ gnome_canvas_pixbuf_get_type (),
+ "GnomeCanvasPixbuf::pixbuf", pixbuf,
+ NULL);
+
+ gtk_signal_connect (GTK_OBJECT (week_view->jump_buttons[i]),
+ "event",
+ GTK_SIGNAL_FUNC (e_week_view_on_jump_button_event),
+ week_view);
+ }
+
+
/*
* Scrollbar.
*/
@@ -1634,7 +1666,7 @@ e_week_view_layout_events (EWeekView *week_view)
{
EWeekViewEvent *event;
EWeekViewEventSpan *span;
- gint event_num, span_num;
+ gint num_days, day, event_num, span_num;
guint8 *grid;
GArray *spans, *old_spans;
@@ -1648,6 +1680,12 @@ e_week_view_layout_events (EWeekView *week_view)
/* We create a new array of spans, which will replace the old one. */
spans = g_array_new (FALSE, FALSE, sizeof (EWeekViewEventSpan));
+ /* Clear the number of rows used per day. */
+ num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7;
+ for (day = 0; day <= num_days; day++) {
+ week_view->rows_per_day[day] = 0;
+ }
+
/* Iterate over the events, finding which weeks they cover, and putting
them in the first free row available. */
for (event_num = 0; event_num < week_view->events->len; event_num++) {
@@ -1736,6 +1774,7 @@ e_week_view_layout_event (EWeekView *week_view,
for (day = span_start_day; day <= span_end_day;
day++) {
grid[day * rows_per_cell + free_row] = 1;
+ week_view->rows_per_day[day] = MAX (week_view->rows_per_day[day], free_row + 1);
}
#if 0
g_print (" Span start:%i end:%i row:%i\n",
@@ -1811,6 +1850,8 @@ e_week_view_reshape_events (EWeekView *week_view)
{
EWeekViewEvent *event;
gint event_num, span_num;
+ gint num_days, day, day_x, day_y, day_w, day_h, max_rows;
+ gboolean is_weekend;
for (event_num = 0; event_num < week_view->events->len; event_num++) {
event = &g_array_index (week_view->events, EWeekViewEvent,
@@ -1820,6 +1861,42 @@ e_week_view_reshape_events (EWeekView *week_view)
span_num);
}
}
+
+ /* Reshape the jump buttons and show/hide them as appropriate. */
+ num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7;
+ for (day = 0; day < num_days; day++) {
+
+ is_weekend = (day % 7 >= 5) ? TRUE : FALSE;
+ if (!is_weekend || (week_view->display_month
+ && !week_view->compress_weekend))
+ max_rows = week_view->rows_per_cell;
+ else
+ max_rows = week_view->rows_per_compressed_cell;
+
+ g_print ("rows in the day:%i max rows:%i\n",
+ week_view->rows_per_day[day], max_rows);
+
+ /* Determine whether the jump button should be shown. */
+ if (week_view->rows_per_day[day] <= max_rows) {
+ gnome_canvas_item_hide (week_view->jump_buttons[day]);
+ } else {
+ e_week_view_get_day_position (week_view, day,
+ &day_x, &day_y,
+ &day_w, &day_h);
+
+ gnome_canvas_item_set (week_view->jump_buttons[day],
+ "GnomeCanvasPixbuf::x", (gdouble) (day_x + day_w - E_WEEK_VIEW_JUMP_BUTTON_X_PAD - E_WEEK_VIEW_JUMP_BUTTON_WIDTH),
+ "GnomeCanvasPixbuf::y", (gdouble) (day_y + day_h - E_WEEK_VIEW_JUMP_BUTTON_Y_PAD - E_WEEK_VIEW_JUMP_BUTTON_HEIGHT),
+ NULL);
+
+ gnome_canvas_item_show (week_view->jump_buttons[day]);
+ gnome_canvas_item_raise_to_top (week_view->jump_buttons[day]);
+ }
+ }
+
+ for (day = num_days; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) {
+ gnome_canvas_item_hide (week_view->jump_buttons[day]);
+ }
}
@@ -1902,6 +1979,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
#endif
"editable", TRUE,
"text", ico->summary ? ico->summary : "",
+ "use_ellipsis", TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (span->text_item), "event",
GTK_SIGNAL_FUNC (e_week_view_on_text_item_event),
@@ -2725,3 +2803,28 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
gnome_calendar_update_object (week_view->calendar, new_ico);
ical_object_unref (new_ico);
}
+
+
+static gboolean
+e_week_view_on_jump_button_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ EWeekView *week_view)
+{
+ gint day;
+
+ if (event->type == GDK_BUTTON_PRESS) {
+ for (day = 0; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) {
+ if (item == week_view->jump_buttons[day]) {
+ gnome_calendar_dayjump (week_view->calendar,
+ week_view->day_starts[day]);
+ /* A quick hack to make the 'Day' toolbar
+ button active. */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (week_view->calendar->view_toolbar_buttons[0]), TRUE);
+ return TRUE;
+ }
+ }
+
+ }
+
+ return FALSE;
+}
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 86031d2e58..dbb61a58b7 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -161,6 +161,8 @@ struct _EWeekView
GtkWidget *main_canvas;
GnomeCanvasItem *main_canvas_item;
+ GnomeCanvasItem *jump_buttons[E_WEEK_VIEW_MAX_WEEKS * 7];
+
GtkWidget *vscrollbar;
/* The calendar we are associated with. */
@@ -203,6 +205,9 @@ struct _EWeekView
gint rows_per_cell;
gint rows_per_compressed_cell;
+ /* The number of rows we have used for each day (i.e. each cell) */
+ gint rows_per_day[E_WEEK_VIEW_MAX_WEEKS * 7];
+
/* If the small font is used for displaying the minutes. */
gboolean use_small_font;
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index a6f8a342ff..015de10a65 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -24,6 +24,8 @@ BEGIN_GNOME_DECLS
#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass)
#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type())
+#define GNOME_CALENDAR_NUM_VIEWS 4
+
typedef struct {
GtkVBox vbox;
@@ -48,6 +50,8 @@ typedef struct {
GtkWidget *week_view;
GtkWidget *month_view;
+ GtkWidget *view_toolbar_buttons[GNOME_CALENDAR_NUM_VIEWS];
+
void *event_editor;
/* The signal handler id for our GtkCalendar "day_selected" handler. */