From 9515b98403f2f7ef77dc6c51f82505fccef08c2b Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 24 Sep 2008 22:53:30 +0000 Subject: Saving progress. Experimenting with directory layout. Saving progress. Experimenting with directory layout. svn path=/branches/kill-bonobo/; revision=36446 --- calendar/gui/e-calendar-table.c | 955 ++++++++++++++++++++++------------------ 1 file changed, 532 insertions(+), 423 deletions(-) (limited to 'calendar/gui/e-calendar-table.c') diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 9e74ea2c26..ed254d0680 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -65,6 +65,16 @@ #include "e-tasks.h" #include "misc.h" +#define E_CALENDAR_TABLE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CALENDAR_TABLE, ECalendarTablePrivate)) + +struct _ECalendarTablePrivate { + gpointer shell_view; /* weak pointer */ + + EActivity *activity; +}; + enum TargetType{ TARGET_TYPE_VCALENDAR }; @@ -76,12 +86,6 @@ static GtkTargetEntry target_types[] = { static guint n_target_types = G_N_ELEMENTS (target_types); -extern ECompEditorRegistry *comp_editor_registry; - -static void e_calendar_table_class_init (ECalendarTableClass *class); -static void e_calendar_table_init (ECalendarTable *cal_table); -static void e_calendar_table_destroy (GtkObject *object); - static void e_calendar_table_on_double_click (ETable *table, gint row, gint col, @@ -118,7 +122,8 @@ enum { LAST_SIGNAL }; -static guint signals[LAST_SIGNAL] = { 0 }; +static gpointer parent_class; +static guint signals[LAST_SIGNAL]; /* The icons to represent the task. */ #define E_CALENDAR_MODEL_NUM_ICONS 4 @@ -129,30 +134,395 @@ static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { NULL }; static GdkAtom clipboard_atom = GDK_NONE; -G_DEFINE_TYPE (ECalendarTable, e_calendar_table, GTK_TYPE_TABLE) +static void +calendar_table_emit_user_created (ECalendarTable *cal_table) +{ + g_signal_emit (cal_table, signals[USER_CREATED], 0); +} + +static void +calendar_table_set_shell_view (ECalendarTable *cal_table, + EShellView *shell_view) +{ + g_return_if_fail (cal_table->priv->shell_view == NULL); + + cal_table->priv->shell_view = shell_view; + + g_object_add_weak_pointer ( + G_OBJECT (shell_view), + &cal_table->priv->shell_view); +} + +static void +calendar_table_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + calendar_table_set_shell_view ( + E_CALENDAR_TABLE (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_table_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, e_calendar_table_get_shell_view ( + E_CALENDAR_TABLE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} static void -e_calendar_table_class_init (ECalendarTableClass *class) +calendar_table_dispose (GObject *object) +{ + ECalendarTable *cal_table; + + cal_table = E_CALENDAR_TABLE (object); + + if (cal_table->model != NULL) { + g_object_unref (cal_table->model); + cal_table->model = NULL; + } + + if (cal_table->priv->activity != NULL) { + /* XXX Activity is not cancellable. */ + e_activity_complete (cal_table->priv->activity); + g_object_unref (cal_table->priv->activity); + cal_table->priv->activity = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +calendar_table_class_init (ECalendarTableClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalendarTablePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->dispose = calendar_table_dispose; + + signals[USER_CREATED] = + g_signal_new ("user_created", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ECalendarTableClass, user_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); +} + +static void +calendar_table_init (ECalendarTable *cal_table) +{ + GtkWidget *table; + ETable *e_table; + ECell *cell, *popup_cell; + ETableExtras *extras; + gint i; + GdkPixbuf *pixbuf; + GList *strings; + AtkObject *a11y; + char *etspecfile; + + cal_table->priv = E_CALENDAR_TABLE_GET_PRIVATE (cal_table); + + /* Create the model */ + + cal_table->model = (ECalModel *) e_cal_model_tasks_new (); + g_signal_connect_swapped ( + cal_table->model, "row_appended", + G_CALLBACK (calendar_table_emit_user_created), cal_table); + + /* Create the header columns */ + + extras = e_table_extras_new (); + + /* + * Normal string fields. + */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + NULL); + + e_table_extras_add_cell (extras, "calstring", cell); + + + /* + * Date fields. + */ + cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + NULL); + + popup_cell = e_cell_date_edit_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + e_table_extras_add_cell (extras, "dateedit", popup_cell); + cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); + + e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell), + e_calendar_table_get_current_time, + cal_table, NULL); + + + /* + * Combo fields. + */ + + /* Classification field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("Public")); + strings = g_list_append (strings, (char*) _("Private")); + strings = g_list_append (strings, (char*) _("Confidential")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "classification", popup_cell); + + /* Priority field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("High")); + strings = g_list_append (strings, (char*) _("Normal")); + strings = g_list_append (strings, (char*) _("Low")); + strings = g_list_append (strings, (char*) _("Undefined")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "priority", popup_cell); + + /* Percent field. */ + cell = e_cell_percent_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("0%")); + strings = g_list_append (strings, (char*) _("10%")); + strings = g_list_append (strings, (char*) _("20%")); + strings = g_list_append (strings, (char*) _("30%")); + strings = g_list_append (strings, (char*) _("40%")); + strings = g_list_append (strings, (char*) _("50%")); + strings = g_list_append (strings, (char*) _("60%")); + strings = g_list_append (strings, (char*) _("70%")); + strings = g_list_append (strings, (char*) _("80%")); + strings = g_list_append (strings, (char*) _("90%")); + strings = g_list_append (strings, (char*) _("100%")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "percent", popup_cell); + + /* Transparency field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("Free")); + strings = g_list_append (strings, (char*) _("Busy")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "transparency", popup_cell); + + /* Status field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + g_object_set (G_OBJECT (cell), + "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, + "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, + "bg_color_column", E_CAL_MODEL_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + strings = NULL; + strings = g_list_append (strings, (char*) _("Not Started")); + strings = g_list_append (strings, (char*) _("In Progress")); + strings = g_list_append (strings, (char*) _("Completed")); + strings = g_list_append (strings, (char*) _("Canceled")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "calstatus", popup_cell); + + e_table_extras_add_compare (extras, "date-compare", + date_compare_cb); + e_table_extras_add_compare (extras, "percent-compare", + percent_compare_cb); + e_table_extras_add_compare (extras, "priority-compare", + priority_compare_cb); + e_table_extras_add_compare (extras, "status-compare", + status_compare_cb); + + /* Create pixmaps */ + + if (!icon_pixbufs[0]) + for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { + icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], E_ICON_SIZE_LIST); + } + + cell = e_cell_toggle_new (0, E_CALENDAR_MODEL_NUM_ICONS, icon_pixbufs); + e_table_extras_add_cell(extras, "icon", cell); + e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); + + pixbuf = e_icon_factory_get_icon ("stock_check-filled", E_ICON_SIZE_LIST); + e_table_extras_add_pixbuf(extras, "complete", pixbuf); + g_object_unref(pixbuf); + + /* Create the table */ + + etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, + "e-calendar-table.etspec", + NULL); + table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (cal_table->model), + extras, + etspecfile, + NULL); + g_free (etspecfile); + + /* FIXME: this causes a message from GLib about 'extras' having only a floating + reference */ + /* g_object_unref (extras); */ + + cal_table->etable = table; + gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (table); + + + e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table)); + g_signal_connect (e_table, "double_click", G_CALLBACK (e_calendar_table_on_double_click), cal_table); + g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table); + g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table); + g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table); + g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), cal_table); + gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE); + + a11y = gtk_widget_get_accessible ((GtkWidget *)e_table); + if (a11y) + atk_object_set_name (a11y, _("Tasks")); +} + +GType +e_calendar_table_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ECalendarTableClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) calendar_table_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ECalendarTable), + 0, /* n_preallocs */ + (GInstanceInitFunc) calendar_table_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + GTK_TYPE_TABLE, "ECalendarTable", &type_info, 0); + } + + return type; +} + +/** + * e_calendar_table_new: + * @shell_view: an #EShellView + * + * Returns a new #ECalendarTable. + * + * Returns: a new #ECalendarTable + **/ +GtkWidget * +e_calendar_table_new (EShellView *shell_view) { - GtkObjectClass *object_class; + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - object_class = (GtkObjectClass *) class; - - /* Method override */ - object_class->destroy = e_calendar_table_destroy; + return g_object_new ( + E_TYPE_CALENDAR_TABLE, + "shell-view", shell_view, NULL); +} - signals[USER_CREATED] = - g_signal_new ("user_created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalendarTableClass, user_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); +EShellView * +e_calendar_table_get_shell_view (ECalendarTable *cal_table) +{ + g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); - /* clipboard atom */ - if (!clipboard_atom) - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); + return cal_table->priv->shell_view; } static gint @@ -256,12 +626,6 @@ status_compare_cb (gconstpointer a, gconstpointer b) return 0; } -static void -row_appended_cb (ECalModel *model, ECalendarTable *cal_table) -{ - g_signal_emit (cal_table, signals[USER_CREATED], 0); -} - static void get_time_as_text (struct icaltimetype *tt, icaltimezone *f_zone, icaltimezone *t_zone, char *buff, int buff_len) { @@ -321,403 +685,148 @@ query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk if (!comp || !comp->icalcomp) return FALSE; - new_comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (comp->icalcomp))) { - g_object_unref (new_comp); - return FALSE; - } - - box = gtk_vbox_new (FALSE, 0); - - str = e_calendar_view_get_icalcomponent_summary (comp->client, comp->icalcomp, &free_text); - if (!(str && *str)) { - if (free_text) - g_free ((char *)str); - free_text = FALSE; - str = _("* No Summary *"); - } - - l = gtk_label_new (NULL); - tmp = g_markup_printf_escaped ("%s", str); - gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); - gtk_label_set_markup (GTK_LABEL (l), tmp); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - w = gtk_event_box_new (); - - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); - gtk_container_add (GTK_CONTAINER (w), l); - gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); - g_free (tmp); - - if (free_text) - g_free ((char *)str); - free_text = FALSE; - - w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); - - l = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (w), l); - gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); - w = l; - - e_cal_component_get_organizer (new_comp, &organizer); - if (organizer.cn) { - char *ptr ; - ptr = strchr( organizer.value, ':'); - - if (ptr) { - ptr++; - /* To Translators: It will display "Organiser: NameOfTheUser " */ - tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); - } else { - /* With SunOne accounts, there may be no ':' in organiser.value */ - tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); - } - - l = gtk_label_new (tmp); - gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - g_free (tmp); - } - - e_cal_component_get_dtstart (new_comp, &dtstart); - e_cal_component_get_due (new_comp, &dtdue); - - default_zone = e_cal_model_get_timezone (cal_table->model); - - if (dtstart.tzid) { - zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); - if (!zone) - e_cal_get_timezone (comp->client, dtstart.tzid, &zone, NULL); - if (!zone) - zone = default_zone; - } else { - zone = NULL; - } - - tmp2 = g_string_new (""); - - if (dtstart.value) { - get_time_as_text (dtstart.value, zone, default_zone, buff, 1000); - - if (buff [0]) { - g_string_append (tmp2, _("Start: ")); - g_string_append (tmp2, buff); - } - } - - if (dtdue.value) { - get_time_as_text (dtdue.value, zone, default_zone, buff, 1000); - - if (buff [0]) { - if (tmp2->len) - g_string_append (tmp2, "; "); - - g_string_append (tmp2, _("Due: ")); - g_string_append (tmp2, buff); - } - } - - if (tmp2->len) { - l = gtk_label_new (tmp2->str); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - } - - g_string_free (tmp2, TRUE); - - e_cal_component_free_datetime (&dtstart); - e_cal_component_free_datetime (&dtdue); - - tmp2 = g_string_new (""); - e_cal_component_get_description_list (new_comp, &desc); - for (len = 0, p = desc; p != NULL; p = p->next) { - ECalComponentText *text = p->data; - - if (text->value != NULL) { - len += strlen (text->value); - g_string_append (tmp2, text->value); - if (len > 1024) { - g_string_set_size (tmp2, 1020); - g_string_append (tmp2, "..."); - break; - } - } - } - e_cal_component_free_text_list (desc); - - if (tmp2->len) { - l = gtk_label_new (tmp2->str); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - } - - g_string_free (tmp2, TRUE); - - gtk_widget_show_all (box); - gtk_tooltip_set_custom (tooltip, box); - - g_object_unref (new_comp); - - return TRUE; -} - -static void -e_calendar_table_init (ECalendarTable *cal_table) -{ - GtkWidget *table; - ETable *e_table; - ECell *cell, *popup_cell; - ETableExtras *extras; - gint i; - GdkPixbuf *pixbuf; - GList *strings; - AtkObject *a11y; - char *etspecfile; - - /* Create the model */ - - cal_table->model = (ECalModel *) e_cal_model_tasks_new (); - g_signal_connect (cal_table->model, "row_appended", G_CALLBACK (row_appended_cb), cal_table); - - cal_table->user_created_cal = NULL; - - /* Create the header columns */ - - extras = e_table_extras_new(); - - /* - * Normal string fields. - */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); - - e_table_extras_add_cell (extras, "calstring", cell); - - - /* - * Date fields. - */ - cell = e_cell_date_edit_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); - - popup_cell = e_cell_date_edit_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - e_table_extras_add_cell (extras, "dateedit", popup_cell); - cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); - - e_cell_date_edit_set_get_time_callback (E_CELL_DATE_EDIT (popup_cell), - e_calendar_table_get_current_time, - cal_table, NULL); - - - /* - * Combo fields. - */ - - /* Classification field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); - - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - - strings = NULL; - strings = g_list_append (strings, (char*) _("Public")); - strings = g_list_append (strings, (char*) _("Private")); - strings = g_list_append (strings, (char*) _("Confidential")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); - - e_table_extras_add_cell (extras, "classification", popup_cell); - - /* Priority field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); - - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - - strings = NULL; - strings = g_list_append (strings, (char*) _("High")); - strings = g_list_append (strings, (char*) _("Normal")); - strings = g_list_append (strings, (char*) _("Low")); - strings = g_list_append (strings, (char*) _("Undefined")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + new_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (comp->icalcomp))) { + g_object_unref (new_comp); + return FALSE; + } - e_table_extras_add_cell (extras, "priority", popup_cell); + box = gtk_vbox_new (FALSE, 0); - /* Percent field. */ - cell = e_cell_percent_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - NULL); + str = e_calendar_view_get_icalcomponent_summary (comp->client, comp->icalcomp, &free_text); + if (!(str && *str)) { + if (free_text) + g_free ((char *)str); + free_text = FALSE; + str = _("* No Summary *"); + } - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); + l = gtk_label_new (NULL); + tmp = g_markup_printf_escaped ("%s", str); + gtk_label_set_line_wrap (GTK_LABEL (l), TRUE); + gtk_label_set_markup (GTK_LABEL (l), tmp); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + w = gtk_event_box_new (); - strings = NULL; - strings = g_list_append (strings, (char*) _("0%")); - strings = g_list_append (strings, (char*) _("10%")); - strings = g_list_append (strings, (char*) _("20%")); - strings = g_list_append (strings, (char*) _("30%")); - strings = g_list_append (strings, (char*) _("40%")); - strings = g_list_append (strings, (char*) _("50%")); - strings = g_list_append (strings, (char*) _("60%")); - strings = g_list_append (strings, (char*) _("70%")); - strings = g_list_append (strings, (char*) _("80%")); - strings = g_list_append (strings, (char*) _("90%")); - strings = g_list_append (strings, (char*) _("100%")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); + gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); + g_free (tmp); - e_table_extras_add_cell (extras, "percent", popup_cell); + if (free_text) + g_free ((char *)str); + free_text = FALSE; - /* Transparency field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); + w = gtk_event_box_new (); + gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); + l = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (w), l); + gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); + w = l; - strings = NULL; - strings = g_list_append (strings, (char*) _("Free")); - strings = g_list_append (strings, (char*) _("Busy")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + e_cal_component_get_organizer (new_comp, &organizer); + if (organizer.cn) { + char *ptr ; + ptr = strchr( organizer.value, ':'); - e_table_extras_add_cell (extras, "transparency", popup_cell); + if (ptr) { + ptr++; + /* To Translators: It will display "Organiser: NameOfTheUser " */ + tmp = g_strdup_printf (_("Organizer: %s <%s>"), organizer.cn, ptr); + } else { + /* With SunOne accounts, there may be no ':' in organiser.value */ + tmp = g_strdup_printf (_("Organizer: %s"), organizer.cn); + } - /* Status field. */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (cell), - "strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, - "bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE, - "bg_color_column", E_CAL_MODEL_FIELD_COLOR, - "editable", FALSE, - NULL); + l = gtk_label_new (tmp); + gtk_label_set_line_wrap (GTK_LABEL (l), FALSE); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + g_free (tmp); + } - popup_cell = e_cell_combo_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); + e_cal_component_get_dtstart (new_comp, &dtstart); + e_cal_component_get_due (new_comp, &dtdue); - strings = NULL; - strings = g_list_append (strings, (char*) _("Not Started")); - strings = g_list_append (strings, (char*) _("In Progress")); - strings = g_list_append (strings, (char*) _("Completed")); - strings = g_list_append (strings, (char*) _("Canceled")); - e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), - strings); + default_zone = e_cal_model_get_timezone (cal_table->model); - e_table_extras_add_cell (extras, "calstatus", popup_cell); + if (dtstart.tzid) { + zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); + if (!zone) + e_cal_get_timezone (comp->client, dtstart.tzid, &zone, NULL); + if (!zone) + zone = default_zone; + } else { + zone = NULL; + } - e_table_extras_add_compare (extras, "date-compare", - date_compare_cb); - e_table_extras_add_compare (extras, "percent-compare", - percent_compare_cb); - e_table_extras_add_compare (extras, "priority-compare", - priority_compare_cb); - e_table_extras_add_compare (extras, "status-compare", - status_compare_cb); + tmp2 = g_string_new (""); - /* Create pixmaps */ + if (dtstart.value) { + get_time_as_text (dtstart.value, zone, default_zone, buff, 1000); - if (!icon_pixbufs[0]) - for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { - icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], E_ICON_SIZE_LIST); + if (buff [0]) { + g_string_append (tmp2, _("Start: ")); + g_string_append (tmp2, buff); } + } - cell = e_cell_toggle_new (0, E_CALENDAR_MODEL_NUM_ICONS, icon_pixbufs); - e_table_extras_add_cell(extras, "icon", cell); - e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); + if (dtdue.value) { + get_time_as_text (dtdue.value, zone, default_zone, buff, 1000); - pixbuf = e_icon_factory_get_icon ("stock_check-filled", E_ICON_SIZE_LIST); - e_table_extras_add_pixbuf(extras, "complete", pixbuf); - g_object_unref(pixbuf); + if (buff [0]) { + if (tmp2->len) + g_string_append (tmp2, "; "); - /* Create the table */ + g_string_append (tmp2, _("Due: ")); + g_string_append (tmp2, buff); + } + } - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-calendar-table.etspec", - NULL); - table = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (cal_table->model), - extras, - etspecfile, - NULL); - g_free (etspecfile); + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + } - /* FIXME: this causes a message from GLib about 'extras' having only a floating - reference */ - /* g_object_unref (extras); */ + g_string_free (tmp2, TRUE); - cal_table->etable = table; - gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (table); + e_cal_component_free_datetime (&dtstart); + e_cal_component_free_datetime (&dtdue); + tmp2 = g_string_new (""); + e_cal_component_get_description_list (new_comp, &desc); + for (len = 0, p = desc; p != NULL; p = p->next) { + ECalComponentText *text = p->data; - e_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (table)); - g_signal_connect (e_table, "double_click", G_CALLBACK (e_calendar_table_on_double_click), cal_table); - g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table); - g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table); - g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table); - g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), cal_table); - gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE); + if (text->value != NULL) { + len += strlen (text->value); + g_string_append (tmp2, text->value); + if (len > 1024) { + g_string_set_size (tmp2, 1020); + g_string_append (tmp2, "..."); + break; + } + } + } + e_cal_component_free_text_list (desc); - a11y = gtk_widget_get_accessible ((GtkWidget *)e_table); - if (a11y) - atk_object_set_name (a11y, _("Tasks")); -} + if (tmp2->len) { + l = gtk_label_new (tmp2->str); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); + } + g_string_free (tmp2, TRUE); -/** - * e_calendar_table_new: - * @Returns: a new #ECalendarTable. - * - * Creates a new #ECalendarTable. - **/ -GtkWidget * -e_calendar_table_new (void) -{ - GtkWidget *cal_table; + gtk_widget_show_all (box); + gtk_tooltip_set_custom (tooltip, box); - cal_table = GTK_WIDGET (g_object_new (e_calendar_table_get_type (), NULL)); + g_object_unref (new_comp); - return cal_table; + return TRUE; } @@ -739,21 +848,6 @@ e_calendar_table_get_model (ECalendarTable *cal_table) } -static void -e_calendar_table_destroy (GtkObject *object) -{ - ECalendarTable *cal_table; - - cal_table = E_CALENDAR_TABLE (object); - - if (cal_table->model) { - g_object_unref (cal_table->model); - cal_table->model = NULL; - } - - GTK_OBJECT_CLASS (e_calendar_table_parent_class)->destroy (object); -} - /** * e_calendar_table_get_table: * @cal_table: A calendar table. @@ -1836,20 +1930,35 @@ static char *test[] = { #endif void -e_calendar_table_set_activity_handler (ECalendarTable *cal_table, EActivityHandler *activity_handler) +e_calendar_table_set_status_message (ECalendarTable *cal_table, + const gchar *message, + gdouble percent) { - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - - cal_table->activity_handler = activity_handler; -} + EActivity *activity; + EShellView *shell_view; -void -e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *message, int percent) -{ g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - if (!cal_table->activity_handler) - return; + activity = cal_table->priv->activity; + shell_view = e_calendar_table_get_shell_view (cal_table); + + if (message == NULL || *message == '\0') { + if (activity != NULL) { + e_activity_complete (activity); + g_object_unref (activity); + cal_table->priv->activity = NULL; + } + + } else if (activity == NULL) { + activity = e_activity_new (message); + cal_able->priv->activity = activity; + e_activity_set_percent (activity, percent); + e_shell_view_add_activity (shell_view, activity); + + } else { + e_activity_set_percent (activity, percent); + e_activity_set_primary_text (activity, message); + } if (!message || !*message) { if (cal_table->activity_id != 0) { -- cgit v1.2.3