diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-12-08 06:20:49 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-12-08 14:55:28 +0800 |
commit | dd65b18ddf2f4e7fdc108b0ed147658c36103eea (patch) | |
tree | 063b83f2bd337c34bcb573cbae4b6d60ec34eab6 /calendar/gui | |
parent | eb60a4e448fff45d0db5a5856cb19e3abb90a9e0 (diff) | |
download | gsoc2013-evolution-dd65b18ddf2f4e7fdc108b0ed147658c36103eea.tar.gz gsoc2013-evolution-dd65b18ddf2f4e7fdc108b0ed147658c36103eea.tar.zst gsoc2013-evolution-dd65b18ddf2f4e7fdc108b0ed147658c36103eea.zip |
Kill ETableScrolled.
ETableScrolled is nothing but a GtkScrolledWindow containing an ETable.
It adds nothing of value and actually makes customizing ETable harder.
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-cal-list-view.c | 73 | ||||
-rw-r--r-- | calendar/gui/e-cal-list-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 639 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.h | 18 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 579 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.h | 18 |
6 files changed, 606 insertions, 723 deletions
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 7d95e41aa8..64a3ca2ac4 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -134,7 +134,7 @@ static void e_cal_list_view_init (ECalListView *cal_list_view) { cal_list_view->query = NULL; - cal_list_view->table_scrolled = NULL; + cal_list_view->table = NULL; cal_list_view->cursor_event = NULL; cal_list_view->set_table_id = 0; } @@ -173,7 +173,7 @@ e_cal_list_view_load_state (ECalListView *cal_list_view, gchar *filename) g_return_if_fail (filename != NULL); if (g_stat (filename, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) - e_table_load_state (e_table_scrolled_get_table (cal_list_view->table_scrolled), filename); + e_table_load_state (cal_list_view->table, filename); } void @@ -183,7 +183,7 @@ e_cal_list_view_save_state (ECalListView *cal_list_view, gchar *filename) g_return_if_fail (E_IS_CAL_LIST_VIEW (cal_list_view)); g_return_if_fail (filename != NULL); - e_table_save_state (e_table_scrolled_get_table (cal_list_view->table_scrolled), filename); + e_table_save_state (cal_list_view->table, filename); } static void @@ -195,6 +195,8 @@ setup_e_table (ECalListView *cal_list_view) ECell *cell, *popup_cell; GnomeCanvas *canvas; GtkStyle *style; + GtkWidget *container; + GtkWidget *widget; gchar *etspecfile; model = e_calendar_view_get_model (E_CALENDAR_VIEW (cal_list_view)); @@ -276,19 +278,33 @@ setup_e_table (ECalListView *cal_list_view) /* Create table view */ - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-cal-list-view.etspec", - NULL); - cal_list_view->table_scrolled = E_TABLE_SCROLLED ( - e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (model), - extras, - etspecfile, - NULL)); + container = GTK_WIDGET (cal_list_view); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_table_attach ( + GTK_TABLE (container), widget, 0, 2, 0, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1); + gtk_widget_show (widget); + + container = widget; + + etspecfile = g_build_filename ( + EVOLUTION_ETSPECDIR, "e-cal-list-view.etspec", NULL); + widget = e_table_new_from_spec_file ( + E_TABLE_MODEL (model), extras, etspecfile, NULL); + gtk_container_add (GTK_CONTAINER (container), widget); + cal_list_view->table = E_TABLE (widget); + gtk_widget_show (widget); g_free (etspecfile); /* Make sure text is readable on top of our color coding */ - canvas = GNOME_CANVAS (e_table_scrolled_get_table (cal_list_view->table_scrolled)->table_canvas); + canvas = GNOME_CANVAS (cal_list_view->table->table_canvas); style = gtk_widget_get_style (GTK_WIDGET (canvas)); style->fg [GTK_STATE_SELECTED] = style->text [GTK_STATE_NORMAL]; @@ -296,18 +312,18 @@ setup_e_table (ECalListView *cal_list_view) gtk_widget_set_style (GTK_WIDGET (canvas), style); /* Connect signals */ - g_signal_connect (e_table_scrolled_get_table (cal_list_view->table_scrolled), - "double_click", G_CALLBACK (e_cal_list_view_on_table_double_click), cal_list_view); - g_signal_connect (e_table_scrolled_get_table (cal_list_view->table_scrolled), - "right-click", G_CALLBACK (e_cal_list_view_on_table_right_click), cal_list_view); - g_signal_connect_after (e_table_scrolled_get_table (cal_list_view->table_scrolled), - "cursor_change", G_CALLBACK (e_cal_list_view_cursor_change_cb), cal_list_view); - - /* Attach and show widget */ - - gtk_table_attach (GTK_TABLE (cal_list_view), GTK_WIDGET (cal_list_view->table_scrolled), - 0, 2, 0, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1); - gtk_widget_show (GTK_WIDGET (cal_list_view->table_scrolled)); + g_signal_connect ( + cal_list_view->table, "double_click", + G_CALLBACK (e_cal_list_view_on_table_double_click), + cal_list_view); + g_signal_connect ( + cal_list_view->table, "right-click", + G_CALLBACK (e_cal_list_view_on_table_right_click), + cal_list_view); + g_signal_connect_after ( + cal_list_view->table, "cursor_change", + G_CALLBACK (e_cal_list_view_cursor_change_cb), + cal_list_view); } /** @@ -354,9 +370,9 @@ e_cal_list_view_destroy (GtkObject *object) cal_list_view->cursor_event = NULL; } - if (cal_list_view->table_scrolled) { - gtk_widget_destroy (GTK_WIDGET (cal_list_view->table_scrolled)); - cal_list_view->table_scrolled = NULL; + if (cal_list_view->table) { + gtk_widget_destroy (GTK_WIDGET (cal_list_view->table)); + cal_list_view->table = NULL; } GTK_OBJECT_CLASS (e_cal_list_view_parent_class)->destroy (object); @@ -476,7 +492,8 @@ e_cal_list_view_get_selected_events (ECalendarView *cal_view) E_CAL_LIST_VIEW (cal_view)->cursor_event = NULL; } - cursor_row = e_table_get_cursor_row (e_table_scrolled_get_table (E_CAL_LIST_VIEW (cal_view)->table_scrolled)); + cursor_row = e_table_get_cursor_row ( + E_CAL_LIST_VIEW (cal_view)->table); if (cursor_row >= 0) { ECalendarViewEvent *event; diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h index f4f71a6269..0874b73c5b 100644 --- a/calendar/gui/e-cal-list-view.h +++ b/calendar/gui/e-cal-list-view.h @@ -62,7 +62,7 @@ struct _ECalListView { ECalendarView parent; /* The main display table */ - ETableScrolled *table_scrolled; + ETable *table; /* S-expression for query and the query object */ ECalView *query; diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 3dd4d7435b..a1495fb005 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -230,20 +230,6 @@ calendar_table_status_compare_cb (gconstpointer a, } static void -calendar_table_double_click_cb (ECalendarTable *cal_table, - gint row, - gint col, - GdkEvent *event) -{ - ECalModel *model; - ECalModelComponent *comp_data; - - model = e_calendar_table_get_model (cal_table); - comp_data = e_cal_model_get_component_at (model, row); - calendar_table_emit_open_component (cal_table, comp_data); -} - -static void calendar_table_model_cal_view_progress_cb (ECalendarTable *cal_table, const gchar *message, gint progress, @@ -262,245 +248,6 @@ calendar_table_model_cal_view_done_cb (ECalendarTable *cal_table, calendar_table_emit_status_message (cal_table, NULL, -1.0); } -static gboolean -calendar_table_query_tooltip_cb (ECalendarTable *cal_table, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip) -{ - ECalModel *model; - ECalModelComponent *comp_data; - gint row = -1, col = -1; - GtkWidget *box, *l, *w; - GtkStyle *style = gtk_widget_get_default_style (); - gchar *tmp; - const gchar *str; - GString *tmp2; - gchar buff[1001]; - gboolean free_text = FALSE; - gboolean use_24_hour_format; - ECalComponent *new_comp; - ECalComponentOrganizer organizer; - ECalComponentDateTime dtstart, dtdue; - icalcomponent *clone; - icaltimezone *zone, *default_zone; - GSList *desc, *p; - gint len; - ETable *etable; - ESelectionModel *esm; - struct tm tmp_tm; - - if (keyboard_mode) - return FALSE; - - etable = e_calendar_table_get_table (cal_table); - e_table_get_mouse_over_cell (etable, &row, &col); - if (row == -1 || !etable) - return FALSE; - - /* Respect sorting option; the 'e_table_get_mouse_over_cell' - * returns sorted row, not the model one. */ - esm = e_table_get_selection_model (etable); - if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter)) - row = e_sorter_sorted_to_model (esm->sorter, row); - - model = e_calendar_table_get_model (cal_table); - comp_data = e_cal_model_get_component_at (model, row); - if (!comp_data || !comp_data->icalcomp) - return FALSE; - - new_comp = e_cal_component_new (); - clone = icalcomponent_new_clone (comp_data->icalcomp); - if (!e_cal_component_set_icalcomponent (new_comp, clone)) { - g_object_unref (new_comp); - return FALSE; - } - - box = gtk_vbox_new (FALSE, 0); - - str = e_calendar_view_get_icalcomponent_summary ( - comp_data->client, comp_data->icalcomp, &free_text); - if (!(str && *str)) { - if (free_text) - g_free ((gchar *)str); - free_text = FALSE; - str = _("* No Summary *"); - } - - l = gtk_label_new (NULL); - tmp = g_markup_printf_escaped ("<b>%s</b>", 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 ((gchar *)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) { - gchar *ptr; - ptr = strchr( organizer.value, ':'); - - if (ptr) { - ptr++; - /* To Translators: It will display "Organizer: NameOfTheUser <email@ofuser.com>" */ - 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 (model); - use_24_hour_format = e_cal_model_get_use_24_hour_format (model); - - if (dtstart.tzid) { - zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); - if (!zone) - e_cal_get_timezone ( - comp_data->client, dtstart.tzid, &zone, NULL); - if (!zone) - zone = default_zone; - } else { - zone = NULL; - } - - tmp2 = g_string_new (""); - - if (dtstart.value) { - buff[0] = 0; - - tmp_tm = icaltimetype_to_tm_with_zone ( - dtstart.value, zone, default_zone); - e_time_format_date_and_time ( - &tmp_tm, use_24_hour_format, - FALSE, FALSE, buff, 1000); - - if (buff [0]) { - g_string_append (tmp2, _("Start: ")); - g_string_append (tmp2, buff); - } - } - - if (dtdue.value) { - buff[0] = 0; - - tmp_tm = icaltimetype_to_tm_with_zone ( - dtdue.value, zone, default_zone); - e_time_format_date_and_time ( - &tmp_tm, use_24_hour_format, - FALSE, FALSE, 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); - - tmp = e_calendar_view_get_attendees_status_info ( - new_comp, comp_data->client); - if (tmp) { - l = gtk_label_new (tmp); - 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); - tmp = NULL; - } - - 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_label_set_line_wrap (GTK_LABEL (l), TRUE); - 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 gboolean -calendar_table_popup_menu_cb (ECalendarTable *cal_table) -{ - calendar_table_emit_popup_event (cal_table, NULL); - - return TRUE; -} - -static gint -calendar_table_right_click_cb (ECalendarTable *cal_table, - gint row, - gint col, - GdkEvent *event) -{ - calendar_table_emit_popup_event (cal_table, event); - - return TRUE; -} - static void calendar_table_set_model (ECalendarTable *cal_table, ECalModel *model) @@ -609,9 +356,7 @@ static void calendar_table_constructed (GObject *object) { ECalendarTable *cal_table; - GtkWidget *widget; ECalModel *model; - ETable *table; ECell *cell, *popup_cell; ETableExtras *extras; gint i; @@ -826,39 +571,286 @@ calendar_table_constructed (GObject *object) etspecfile = g_build_filename ( EVOLUTION_ETSPECDIR, "e-calendar-table.etspec", NULL); - widget = e_table_scrolled_new_from_spec_file ( - E_TABLE_MODEL (model), extras, etspecfile, NULL); - gtk_table_attach ( - GTK_TABLE (cal_table), widget, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - cal_table->etable = widget; - gtk_widget_show (widget); + e_table_construct_from_spec_file ( + E_TABLE (cal_table), E_TABLE_MODEL (model), + extras, etspecfile, NULL); g_free (etspecfile); - table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); - g_signal_connect_swapped ( - table, "double-click", - G_CALLBACK (calendar_table_double_click_cb), cal_table); - g_signal_connect_swapped ( - table, "query-tooltip", - G_CALLBACK (calendar_table_query_tooltip_cb), cal_table); - g_signal_connect_swapped ( - table, "popup-menu", - G_CALLBACK (calendar_table_popup_menu_cb), cal_table); - g_signal_connect_swapped ( - table, "right-click", - G_CALLBACK (calendar_table_right_click_cb), cal_table); - gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE); + gtk_widget_set_has_tooltip (GTK_WIDGET (cal_table), TRUE); - a11y = gtk_widget_get_accessible (GTK_WIDGET (table)); + a11y = gtk_widget_get_accessible (GTK_WIDGET (cal_table)); if (a11y) atk_object_set_name (a11y, _("Tasks")); } +static gboolean +calendar_table_popup_menu (GtkWidget *widget) +{ + ECalendarTable *cal_table; + + cal_table = E_CALENDAR_TABLE (widget); + calendar_table_emit_popup_event (cal_table, NULL); + + return TRUE; +} + +static gboolean +calendar_table_query_tooltip (GtkWidget *widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip) +{ + ECalendarTable *cal_table; + ECalModel *model; + ECalModelComponent *comp_data; + gint row = -1, col = -1; + GtkWidget *box, *l, *w; + GtkStyle *style = gtk_widget_get_default_style (); + gchar *tmp; + const gchar *str; + GString *tmp2; + gchar buff[1001]; + gboolean free_text = FALSE; + gboolean use_24_hour_format; + ECalComponent *new_comp; + ECalComponentOrganizer organizer; + ECalComponentDateTime dtstart, dtdue; + icalcomponent *clone; + icaltimezone *zone, *default_zone; + GSList *desc, *p; + gint len; + ESelectionModel *esm; + struct tm tmp_tm; + + if (keyboard_mode) + return FALSE; + + cal_table = E_CALENDAR_TABLE (widget); + + e_table_get_mouse_over_cell (E_TABLE (cal_table), &row, &col); + if (row == -1) + return FALSE; + + /* Respect sorting option; the 'e_table_get_mouse_over_cell' + * returns sorted row, not the model one. */ + esm = e_table_get_selection_model (E_TABLE (cal_table)); + if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter)) + row = e_sorter_sorted_to_model (esm->sorter, row); + + model = e_calendar_table_get_model (cal_table); + comp_data = e_cal_model_get_component_at (model, row); + if (!comp_data || !comp_data->icalcomp) + return FALSE; + + new_comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + if (!e_cal_component_set_icalcomponent (new_comp, clone)) { + g_object_unref (new_comp); + return FALSE; + } + + box = gtk_vbox_new (FALSE, 0); + + str = e_calendar_view_get_icalcomponent_summary ( + comp_data->client, comp_data->icalcomp, &free_text); + if (!(str && *str)) { + if (free_text) + g_free ((gchar *)str); + free_text = FALSE; + str = _("* No Summary *"); + } + + l = gtk_label_new (NULL); + tmp = g_markup_printf_escaped ("<b>%s</b>", 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 ((gchar *)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) { + gchar *ptr; + ptr = strchr( organizer.value, ':'); + + if (ptr) { + ptr++; + /* To Translators: It will display "Organizer: NameOfTheUser <email@ofuser.com>" */ + 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 (model); + use_24_hour_format = e_cal_model_get_use_24_hour_format (model); + + if (dtstart.tzid) { + zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid); + if (!zone) + e_cal_get_timezone ( + comp_data->client, dtstart.tzid, &zone, NULL); + if (!zone) + zone = default_zone; + } else { + zone = NULL; + } + + tmp2 = g_string_new (""); + + if (dtstart.value) { + buff[0] = 0; + + tmp_tm = icaltimetype_to_tm_with_zone ( + dtstart.value, zone, default_zone); + e_time_format_date_and_time ( + &tmp_tm, use_24_hour_format, + FALSE, FALSE, buff, 1000); + + if (buff [0]) { + g_string_append (tmp2, _("Start: ")); + g_string_append (tmp2, buff); + } + } + + if (dtdue.value) { + buff[0] = 0; + + tmp_tm = icaltimetype_to_tm_with_zone ( + dtdue.value, zone, default_zone); + e_time_format_date_and_time ( + &tmp_tm, use_24_hour_format, + FALSE, FALSE, 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); + + tmp = e_calendar_view_get_attendees_status_info ( + new_comp, comp_data->client); + if (tmp) { + l = gtk_label_new (tmp); + 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); + tmp = NULL; + } + + 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_label_set_line_wrap (GTK_LABEL (l), TRUE); + 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 +calendar_table_double_click (ETable *table, + gint row, + gint col, + GdkEvent *event) +{ + ECalendarTable *cal_table; + ECalModel *model; + ECalModelComponent *comp_data; + + cal_table = E_CALENDAR_TABLE (table); + model = e_calendar_table_get_model (cal_table); + comp_data = e_cal_model_get_component_at (model, row); + calendar_table_emit_open_component (cal_table, comp_data); +} + +static gint +calendar_table_right_click (ETable *table, + gint row, + gint col, + GdkEvent *event) +{ + ECalendarTable *cal_table; + + cal_table = E_CALENDAR_TABLE (table); + calendar_table_emit_popup_event (cal_table, event); + + return TRUE; +} + static void calendar_table_class_init (ECalendarTableClass *class) { GObjectClass *object_class; + GtkWidgetClass *widget_class; + ETableClass *table_class; parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (ECalendarTablePrivate)); @@ -869,6 +861,14 @@ calendar_table_class_init (ECalendarTableClass *class) object_class->dispose = calendar_table_dispose; object_class->constructed = calendar_table_constructed; + widget_class = GTK_WIDGET_CLASS (class); + widget_class->popup_menu = calendar_table_popup_menu; + widget_class->query_tooltip = calendar_table_query_tooltip; + + table_class = E_TABLE_CLASS (class); + table_class->double_click = calendar_table_double_click; + table_class->right_click = calendar_table_right_click; + g_object_class_install_property ( object_class, PROP_MODEL, @@ -957,7 +957,7 @@ e_calendar_table_get_type (void) }; type = g_type_register_static ( - GTK_TYPE_TABLE, "ECalendarTable", &type_info, 0); + E_TABLE_TYPE, "ECalendarTable", &type_info, 0); } return type; @@ -1000,27 +1000,6 @@ e_calendar_table_get_model (ECalendarTable *cal_table) return cal_table->priv->model; } -/** - * e_calendar_table_get_table: - * @cal_table: A calendar table. - * - * Queries the #ETable widget that the calendar table is using. - * - * Return value: The #ETable widget that the calendar table uses to display its - * data. - **/ -ETable * -e_calendar_table_get_table (ECalendarTable *cal_table) -{ - ETableScrolled *table_scrolled; - - g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); - - table_scrolled = E_TABLE_SCROLLED (cal_table->etable); - - return e_table_scrolled_get_table (table_scrolled); -} - EShellView * e_calendar_table_get_shell_view (ECalendarTable *cal_table) { @@ -1049,18 +1028,15 @@ static ECalModelComponent * get_selected_comp (ECalendarTable *cal_table) { ECalModel *model; - ETable *etable; gint row; model = e_calendar_table_get_model (cal_table); - etable = e_calendar_table_get_table (cal_table); - if (e_table_selected_count (etable) != 1) + if (e_table_selected_count (E_TABLE (cal_table)) != 1) return NULL; row = -1; - e_table_selected_row_foreach (etable, - get_selected_row_cb, - &row); + e_table_selected_row_foreach ( + E_TABLE (cal_table), get_selected_row_cb, &row); g_return_val_if_fail (row != -1, NULL); return e_cal_model_get_component_at (model, row); @@ -1158,19 +1134,16 @@ check_for_retract (ECalComponent *comp, ECal *client) void e_calendar_table_delete_selected (ECalendarTable *cal_table) { - ETable *etable; gint n_selected; ECalModelComponent *comp_data; ECalComponent *comp = NULL; - gboolean delete = FALSE; + gboolean delete = FALSE; GError *error = NULL; g_return_if_fail (cal_table != NULL); g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - etable = e_calendar_table_get_table (cal_table); - - n_selected = e_table_selected_count (etable); + n_selected = e_table_selected_count (E_TABLE (cal_table)); if (n_selected <= 0) return; @@ -1240,13 +1213,12 @@ GSList * e_calendar_table_get_selected (ECalendarTable *cal_table) { struct get_selected_uids_closure closure; - ETable *etable; closure.cal_table = cal_table; closure.objects = NULL; - etable = e_calendar_table_get_table (cal_table); - e_table_selected_row_foreach (etable, add_uid_cb, &closure); + e_table_selected_row_foreach ( + E_TABLE (cal_table), add_uid_cb, &closure); return closure.objects; } @@ -1308,7 +1280,6 @@ copy_row_cb (gint model_row, gpointer data) void e_calendar_table_copy_clipboard (ECalendarTable *cal_table) { - ETable *etable; GtkClipboard *clipboard; gchar *comp_str; @@ -1317,8 +1288,8 @@ e_calendar_table_copy_clipboard (ECalendarTable *cal_table) /* create temporary VCALENDAR object */ cal_table->tmp_vcal = e_cal_util_new_top_level (); - etable = e_calendar_table_get_table (cal_table); - e_table_selected_row_foreach (etable, copy_row_cb, cal_table); + e_table_selected_row_foreach ( + E_TABLE (cal_table), copy_row_cb, cal_table); comp_str = icalcomponent_as_ical_string_r (cal_table->tmp_vcal); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); @@ -1423,18 +1394,18 @@ e_calendar_table_paste_clipboard (ECalendarTable *cal_table) { GtkClipboard *clipboard; GnomeCanvasItem *item; - ETable *etable; + GnomeCanvas *table_canvas; g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - etable = e_calendar_table_get_table (cal_table); - item = GNOME_CANVAS (etable->table_canvas)->focused_item; + table_canvas = E_TABLE (cal_table)->table_canvas; + item = table_canvas->focused_item; /* Paste text into a cell being edited. */ if (gtk_clipboard_wait_is_text_available (clipboard) && - GTK_WIDGET_HAS_FOCUS (etable->table_canvas) && + GTK_WIDGET_HAS_FOCUS (table_canvas) && E_IS_TABLE_ITEM (item) && E_TABLE_ITEM (item)->editing_col >= 0 && E_TABLE_ITEM (item)->editing_row >= 0) { @@ -1546,34 +1517,6 @@ show_completed_rows (ECalModel *model, GList *clients_list, gchar *show_sexp, GP } } -/* Loads the state of the table (headers shown etc.) from the given file. */ -void -e_calendar_table_load_state (ECalendarTable *cal_table, - const gchar *filename) -{ - ETable *table; - - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - g_return_if_fail (filename != NULL); - - table = e_calendar_table_get_table (cal_table); - e_table_load_state (table, filename); -} - -/* Saves the state of the table (headers shown etc.) to the given file. */ -void -e_calendar_table_save_state (ECalendarTable *cal_table, - const gchar *filename) -{ - ETable *table; - - g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); - g_return_if_fail (filename != NULL); - - table = e_calendar_table_get_table (cal_table); - e_table_save_state (table, filename); -} - /* Returns the current time, for the ECellDateEdit items. FIXME: Should probably use the timezone of the item rather than the current timezone, though that may be difficult to get from here. */ diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index d2b376ba9d..aa98aee7fa 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -23,9 +23,9 @@ #ifndef _E_CALENDAR_TABLE_H_ #define _E_CALENDAR_TABLE_H_ -#include <shell/e-shell-view.h> -#include <table/e-table-scrolled.h> +#include <table/e-table.h> #include <table/e-cell-date-edit.h> +#include <shell/e-shell-view.h> #include "e-cal-model.h" /* @@ -59,9 +59,7 @@ typedef struct _ECalendarTableClass ECalendarTableClass; typedef struct _ECalendarTablePrivate ECalendarTablePrivate; struct _ECalendarTable { - GtkTable parent; - - GtkWidget *etable; + ETable parent; /* The ECell used to view & edit dates. */ ECellDateEdit *dates_cell; @@ -73,7 +71,7 @@ struct _ECalendarTable { }; struct _ECalendarTableClass { - GtkTableClass parent_class; + ETableClass parent_class; /* Signals */ void (*open_component) (ECalendarTable *cal_table, @@ -90,7 +88,6 @@ GType e_calendar_table_get_type (void); GtkWidget * e_calendar_table_new (EShellView *shell_view, ECalModel *model); ECalModel * e_calendar_table_get_model (ECalendarTable *cal_table); -ETable * e_calendar_table_get_table (ECalendarTable *cal_table); EShellView * e_calendar_table_get_shell_view (ECalendarTable *cal_table); void e_calendar_table_delete_selected(ECalendarTable *cal_table); GSList * e_calendar_table_get_selected (ECalendarTable *cal_table); @@ -100,13 +97,6 @@ void e_calendar_table_cut_clipboard (ECalendarTable *cal_table); void e_calendar_table_copy_clipboard (ECalendarTable *cal_table); void e_calendar_table_paste_clipboard(ECalendarTable *cal_table); -/* These load and save the state of the table (headers shown etc.) to/from - the given file. */ -void e_calendar_table_load_state (ECalendarTable *cal_table, - const gchar *filename); -void e_calendar_table_save_state (ECalendarTable *cal_table, - const gchar *filename); - ECalModelComponent * e_calendar_table_get_selected_comp (ECalendarTable *cal_table); diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index c60784912f..977715898e 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -163,20 +163,6 @@ memo_table_date_compare_cb (gconstpointer a, } static void -memo_table_double_click_cb (EMemoTable *memo_table, - gint row, - gint col, - GdkEvent *event) -{ - ECalModel *model; - ECalModelComponent *comp_data; - - model = e_memo_table_get_model (memo_table); - comp_data = e_cal_model_get_component_at (model, row); - memo_table_emit_open_component (memo_table, comp_data); -} - -static void memo_table_model_cal_view_progress_cb (EMemoTable *memo_table, const gchar *message, gint progress, @@ -195,13 +181,222 @@ memo_table_model_cal_view_done_cb (EMemoTable *memo_table, memo_table_emit_status_message (memo_table, NULL, -1.0); } +static void +memo_table_set_model (EMemoTable *memo_table, + ECalModel *model) +{ + g_return_if_fail (memo_table->priv->model == NULL); + + memo_table->priv->model = g_object_ref (model); + + g_signal_connect_swapped ( + model, "row-appended", + G_CALLBACK (memo_table_emit_user_created), memo_table); + + g_signal_connect_swapped ( + model, "cal-view-progress", + G_CALLBACK (memo_table_model_cal_view_progress_cb), + memo_table); + + g_signal_connect_swapped ( + model, "cal-view-done", + G_CALLBACK (memo_table_model_cal_view_done_cb), + memo_table); +} + +static void +memo_table_set_shell_view (EMemoTable *memo_table, + EShellView *shell_view) +{ + g_return_if_fail (memo_table->priv->shell_view == NULL); + + memo_table->priv->shell_view = shell_view; + + g_object_add_weak_pointer ( + G_OBJECT (shell_view), + &memo_table->priv->shell_view); +} + +static void +memo_table_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MODEL: + memo_table_set_model ( + E_MEMO_TABLE (object), + g_value_get_object (value)); + return; + + case PROP_SHELL_VIEW: + memo_table_set_shell_view ( + E_MEMO_TABLE (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_table_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MODEL: + g_value_set_object ( + value, e_memo_table_get_model ( + E_MEMO_TABLE (object))); + return; + + case PROP_SHELL_VIEW: + g_value_set_object ( + value, e_memo_table_get_shell_view ( + E_MEMO_TABLE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +memo_table_dispose (GObject *object) +{ + EMemoTablePrivate *priv; + + priv = E_MEMO_TABLE_GET_PRIVATE (object); + + if (priv->shell_view != NULL) { + g_object_remove_weak_pointer ( + G_OBJECT (priv->shell_view), &priv->shell_view); + priv->shell_view = NULL; + } + + if (priv->model != NULL) { + g_object_unref (priv->model); + priv->model = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +memo_table_constructed (GObject *object) +{ + EMemoTable *memo_table; + ECalModel *model; + ECell *cell, *popup_cell; + ETableExtras *extras; + gint i; + AtkObject *a11y; + gchar *etspecfile; + + memo_table = E_MEMO_TABLE (object); + model = e_memo_table_get_model (memo_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 (cell, "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 (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL); + + e_mutual_binding_new ( + model, "timezone", + cell, "timezone"); + + e_mutual_binding_new ( + model, "use-24-hour-format", + cell, "use-24-hour-format"); + + popup_cell = e_cell_date_edit_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + g_object_unref (cell); + + e_mutual_binding_new ( + model, "use-24-hour-format", + popup_cell, "use-24-hour-format"); + + e_table_extras_add_cell (extras, "dateedit", popup_cell); + memo_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); + + e_cell_date_edit_set_get_time_callback ( + E_CELL_DATE_EDIT (popup_cell), + e_memo_table_get_current_time, memo_table, NULL); + + /* Sorting */ + e_table_extras_add_compare ( + extras, "date-compare", memo_table_date_compare_cb); + + /* Create pixmaps */ + + if (!icon_pixbufs[0]) + for (i = 0; i < NUM_ICONS; i++) { + icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], GTK_ICON_SIZE_MENU); + } + + cell = e_cell_toggle_new (0, NUM_ICONS, icon_pixbufs); + e_table_extras_add_cell (extras, "icon", cell); + e_table_extras_add_pixbuf (extras, "icon", icon_pixbufs[0]); + + /* set proper format component for a default 'date' cell renderer */ + cell = e_table_extras_get_cell (extras, "date"); + e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); + + /* set proper format component for a default 'date' cell renderer */ + cell = e_table_extras_get_cell (extras, "date"); + e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); + + /* Construct the table */ + + etspecfile = g_build_filename ( + EVOLUTION_ETSPECDIR, "e-memo-table.etspec", NULL); + e_table_construct_from_spec_file ( + E_TABLE (memo_table), E_TABLE_MODEL (model), + extras, etspecfile, NULL); + g_free (etspecfile); + + gtk_widget_set_has_tooltip (GTK_WIDGET (memo_table), TRUE); + + a11y = gtk_widget_get_accessible (GTK_WIDGET (memo_table)); + if (a11y) + atk_object_set_name (a11y, _("Memos")); +} + +static gboolean +memo_table_popup_menu (GtkWidget *widget) +{ + EMemoTable *memo_table; + + memo_table = E_MEMO_TABLE (widget); + memo_table_emit_popup_event (memo_table, NULL); + + return TRUE; +} + static gboolean -memo_table_query_tooltip_cb (EMemoTable *memo_table, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip) +memo_table_query_tooltip (GtkWidget *widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip) { + EMemoTable *memo_table; ECalModel *model; ECalModelComponent *comp_data; gint row = -1, col = -1; @@ -220,21 +415,21 @@ memo_table_query_tooltip_cb (EMemoTable *memo_table, icaltimezone *zone, *default_zone; GSList *desc, *p; gint len; - ETable *etable; ESelectionModel *esm; struct tm tmp_tm; if (keyboard_mode) return FALSE; - etable = e_memo_table_get_table (memo_table); - e_table_get_mouse_over_cell (etable, &row, &col); - if (row == -1 || !etable) + memo_table = E_MEMO_TABLE (widget); + + e_table_get_mouse_over_cell (E_TABLE (memo_table), &row, &col); + if (row == -1) return FALSE; /* Respect sorting option; the 'e_table_get_mouse_over_cell' * returns sorted row, not the model one. */ - esm = e_table_get_selection_model (etable); + esm = e_table_get_selection_model (E_TABLE (memo_table)); if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter)) row = e_sorter_sorted_to_model (esm->sorter, row); @@ -403,245 +598,42 @@ memo_table_query_tooltip_cb (EMemoTable *memo_table, return TRUE; } -static gboolean -memo_table_popup_menu_cb (EMemoTable *memo_table) -{ - memo_table_emit_popup_event (memo_table, NULL); - - return TRUE; -} - -static gint -memo_table_right_click_cb (EMemoTable *memo_table, - gint row, - gint col, - GdkEvent *event) -{ - memo_table_emit_popup_event (memo_table, event); - - return TRUE; -} - -static void -memo_table_set_model (EMemoTable *memo_table, - ECalModel *model) -{ - g_return_if_fail (memo_table->priv->model == NULL); - - memo_table->priv->model = g_object_ref (model); - - g_signal_connect_swapped ( - model, "row-appended", - G_CALLBACK (memo_table_emit_user_created), memo_table); - - g_signal_connect_swapped ( - model, "cal-view-progress", - G_CALLBACK (memo_table_model_cal_view_progress_cb), - memo_table); - - g_signal_connect_swapped ( - model, "cal-view-done", - G_CALLBACK (memo_table_model_cal_view_done_cb), - memo_table); -} - -static void -memo_table_set_shell_view (EMemoTable *memo_table, - EShellView *shell_view) -{ - g_return_if_fail (memo_table->priv->shell_view == NULL); - - memo_table->priv->shell_view = shell_view; - - g_object_add_weak_pointer ( - G_OBJECT (shell_view), - &memo_table->priv->shell_view); -} - -static void -memo_table_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_MODEL: - memo_table_set_model ( - E_MEMO_TABLE (object), - g_value_get_object (value)); - return; - - case PROP_SHELL_VIEW: - memo_table_set_shell_view ( - E_MEMO_TABLE (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -memo_table_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_MODEL: - g_value_set_object ( - value, e_memo_table_get_model ( - E_MEMO_TABLE (object))); - return; - - case PROP_SHELL_VIEW: - g_value_set_object ( - value, e_memo_table_get_shell_view ( - E_MEMO_TABLE (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - static void -memo_table_dispose (GObject *object) -{ - EMemoTablePrivate *priv; - - priv = E_MEMO_TABLE_GET_PRIVATE (object); - - if (priv->shell_view != NULL) { - g_object_remove_weak_pointer ( - G_OBJECT (priv->shell_view), &priv->shell_view); - priv->shell_view = NULL; - } - - if (priv->model != NULL) { - g_object_unref (priv->model); - priv->model = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -memo_table_constructed (GObject *object) +memo_table_double_click (ETable *table, + gint row, + gint col, + GdkEvent *event) { EMemoTable *memo_table; - GtkWidget *widget; ECalModel *model; - ETable *table; - ECell *cell, *popup_cell; - ETableExtras *extras; - gint i; - AtkObject *a11y; - gchar *etspecfile; + ECalModelComponent *comp_data; - memo_table = E_MEMO_TABLE (object); + memo_table = E_MEMO_TABLE (table); model = e_memo_table_get_model (memo_table); + comp_data = e_cal_model_get_component_at (model, row); + memo_table_emit_open_component (memo_table, comp_data); +} - /* Create the header columns */ - - extras = e_table_extras_new (); - - /* - * Normal string fields. - */ - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set (cell, "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 (cell, "bg_color_column", E_CAL_MODEL_FIELD_COLOR, NULL); - - e_mutual_binding_new ( - model, "timezone", - cell, "timezone"); - - e_mutual_binding_new ( - model, "use-24-hour-format", - cell, "use-24-hour-format"); - - popup_cell = e_cell_date_edit_new (); - e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); - g_object_unref (cell); - - e_mutual_binding_new ( - model, "use-24-hour-format", - popup_cell, "use-24-hour-format"); - - e_table_extras_add_cell (extras, "dateedit", popup_cell); - memo_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); - - e_cell_date_edit_set_get_time_callback ( - E_CELL_DATE_EDIT (popup_cell), - e_memo_table_get_current_time, memo_table, NULL); - - /* Sorting */ - e_table_extras_add_compare ( - extras, "date-compare", memo_table_date_compare_cb); - - /* Create pixmaps */ - - if (!icon_pixbufs[0]) - for (i = 0; i < NUM_ICONS; i++) { - icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], GTK_ICON_SIZE_MENU); - } - - cell = e_cell_toggle_new (0, NUM_ICONS, icon_pixbufs); - e_table_extras_add_cell (extras, "icon", cell); - e_table_extras_add_pixbuf (extras, "icon", icon_pixbufs[0]); - - /* set proper format component for a default 'date' cell renderer */ - cell = e_table_extras_get_cell (extras, "date"); - e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); - - /* set proper format component for a default 'date' cell renderer */ - cell = e_table_extras_get_cell (extras, "date"); - e_cell_date_set_format_component (E_CELL_DATE (cell), "calendar"); - - /* Create the table */ - - etspecfile = g_build_filename ( - EVOLUTION_ETSPECDIR, "e-memo-table.etspec", NULL); - widget = e_table_scrolled_new_from_spec_file ( - E_TABLE_MODEL (model), extras, etspecfile, NULL); - gtk_table_attach ( - GTK_TABLE (memo_table), widget, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - memo_table->etable = widget; - gtk_widget_show (widget); - g_free (etspecfile); +static gint +memo_table_right_click (ETable *table, + gint row, + gint col, + GdkEvent *event) +{ + EMemoTable *memo_table; - table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); - g_signal_connect_swapped ( - table, "double-click", - G_CALLBACK (memo_table_double_click_cb), memo_table); - g_signal_connect_swapped ( - table, "query-tooltip", - G_CALLBACK (memo_table_query_tooltip_cb), memo_table); - g_signal_connect_swapped ( - table, "popup-menu", - G_CALLBACK (memo_table_popup_menu_cb), memo_table); - g_signal_connect_swapped ( - table, "right-click", - G_CALLBACK (memo_table_right_click_cb), memo_table); - gtk_widget_set_has_tooltip (GTK_WIDGET (table), TRUE); + memo_table = E_MEMO_TABLE (table); + memo_table_emit_popup_event (memo_table, event); - a11y = gtk_widget_get_accessible (GTK_WIDGET (table)); - if (a11y) - atk_object_set_name (a11y, _("Memos")); + return TRUE; } static void memo_table_class_init (EMemoTableClass *class) { GObjectClass *object_class; + GtkWidgetClass *widget_class; + ETableClass *table_class; parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMemoTablePrivate)); @@ -652,6 +644,14 @@ memo_table_class_init (EMemoTableClass *class) object_class->dispose = memo_table_dispose; object_class->constructed = memo_table_constructed; + widget_class = GTK_WIDGET_CLASS (class); + widget_class->popup_menu = memo_table_popup_menu; + widget_class->query_tooltip = memo_table_query_tooltip; + + table_class = E_TABLE_CLASS (class); + table_class->double_click = memo_table_double_click; + table_class->right_click = memo_table_right_click; + g_object_class_install_property ( object_class, PROP_MODEL, @@ -740,7 +740,7 @@ e_memo_table_get_type (void) }; type = g_type_register_static ( - GTK_TYPE_TABLE, "EMemoTable", &type_info, 0); + E_TABLE_TYPE, "EMemoTable", &type_info, 0); } return type; @@ -784,27 +784,6 @@ e_memo_table_get_model (EMemoTable *memo_table) return memo_table->priv->model; } -/** - * e_memo_table_get_table: - * @memo_table: A calendar table. - * - * Queries the #ETable widget that the calendar table is using. - * - * Return value: The #ETable widget that the calendar table uses to display its - * data. - **/ -ETable * -e_memo_table_get_table (EMemoTable *memo_table) -{ - ETableScrolled *table_scrolled; - - g_return_val_if_fail (E_IS_MEMO_TABLE (memo_table), NULL); - - table_scrolled = E_TABLE_SCROLLED (memo_table->etable); - - return e_table_scrolled_get_table (table_scrolled); -} - EShellView * e_memo_table_get_shell_view (EMemoTable *memo_table) { @@ -833,18 +812,15 @@ static ECalModelComponent * get_selected_comp (EMemoTable *memo_table) { ECalModel *model; - ETable *etable; gint row; model = e_memo_table_get_model (memo_table); - etable = e_memo_table_get_table (memo_table); - if (e_table_selected_count (etable) != 1) + if (e_table_selected_count (E_TABLE (memo_table)) != 1) return NULL; row = -1; - e_table_selected_row_foreach (etable, - get_selected_row_cb, - &row); + e_table_selected_row_foreach ( + E_TABLE (memo_table), get_selected_row_cb, &row); g_return_val_if_fail (row != -1, NULL); return e_cal_model_get_component_at (model, row); @@ -907,7 +883,6 @@ delete_selected_components (EMemoTable *memo_table) void e_memo_table_delete_selected (EMemoTable *memo_table) { - ETable *etable; gint n_selected; ECalModelComponent *comp_data; ECalComponent *comp = NULL; @@ -915,9 +890,7 @@ e_memo_table_delete_selected (EMemoTable *memo_table) g_return_if_fail (memo_table != NULL); g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - etable = e_memo_table_get_table (memo_table); - - n_selected = e_table_selected_count (etable); + n_selected = e_table_selected_count (E_TABLE (memo_table)); if (n_selected <= 0) return; @@ -955,13 +928,12 @@ GSList * e_memo_table_get_selected (EMemoTable *memo_table) { struct get_selected_uids_closure closure; - ETable *etable; closure.memo_table = memo_table; closure.objects = NULL; - etable = e_memo_table_get_table (memo_table); - e_table_selected_row_foreach (etable, add_uid_cb, &closure); + e_table_selected_row_foreach ( + E_TABLE (memo_table), add_uid_cb, &closure); return closure.objects; } @@ -1023,7 +995,6 @@ copy_row_cb (gint model_row, gpointer data) void e_memo_table_copy_clipboard (EMemoTable *memo_table) { - ETable *etable; GtkClipboard *clipboard; gchar *comp_str; @@ -1032,8 +1003,8 @@ e_memo_table_copy_clipboard (EMemoTable *memo_table) /* create temporary VCALENDAR object */ memo_table->tmp_vcal = e_cal_util_new_top_level (); - etable = e_memo_table_get_table (memo_table); - e_table_selected_row_foreach (etable, copy_row_cb, memo_table); + e_table_selected_row_foreach ( + E_TABLE (memo_table), copy_row_cb, memo_table); comp_str = icalcomponent_as_ical_string_r (memo_table->tmp_vcal); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); @@ -1138,18 +1109,18 @@ e_memo_table_paste_clipboard (EMemoTable *memo_table) { GtkClipboard *clipboard; GnomeCanvasItem *item; - ETable *etable; + GnomeCanvas *table_canvas; g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - etable = e_memo_table_get_table (memo_table); - item = GNOME_CANVAS (etable->table_canvas)->focused_item; + table_canvas = E_TABLE (memo_table)->table_canvas; + item = table_canvas->focused_item; /* Paste text into a cell being edited. */ if (gtk_clipboard_wait_is_text_available (clipboard) && - GTK_WIDGET_HAS_FOCUS (etable->table_canvas) && + GTK_WIDGET_HAS_FOCUS (table_canvas) && E_IS_TABLE_ITEM (item) && E_TABLE_ITEM (item)->editing_col >= 0 && E_TABLE_ITEM (item)->editing_row >= 0) { @@ -1171,34 +1142,6 @@ e_memo_table_paste_clipboard (EMemoTable *memo_table) } } -/* Loads the state of the table (headers shown etc.) from the given file. */ -void -e_memo_table_load_state (EMemoTable *memo_table, - const gchar *filename) -{ - ETable *table; - - g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - g_return_if_fail (filename != NULL); - - table = e_memo_table_get_table (memo_table); - e_table_load_state (table, filename); -} - -/* Saves the state of the table (headers shown etc.) to the given file. */ -void -e_memo_table_save_state (EMemoTable *memo_table, - const gchar *filename) -{ - ETable *table; - - g_return_if_fail (E_IS_MEMO_TABLE (memo_table)); - g_return_if_fail (filename != NULL); - - table = e_memo_table_get_table (memo_table); - e_table_save_state (table, filename); -} - /* Returns the current time, for the ECellDateEdit items. FIXME: Should probably use the timezone of the item rather than the current timezone, though that may be difficult to get from here. */ diff --git a/calendar/gui/e-memo-table.h b/calendar/gui/e-memo-table.h index d7f1857374..4d4347db4a 100644 --- a/calendar/gui/e-memo-table.h +++ b/calendar/gui/e-memo-table.h @@ -25,9 +25,9 @@ #ifndef _E_MEMO_TABLE_H_ #define _E_MEMO_TABLE_H_ -#include <shell/e-shell-view.h> -#include <table/e-table-scrolled.h> +#include <table/e-table.h> #include <table/e-cell-date-edit.h> +#include <shell/e-shell-view.h> #include "e-cal-model.h" /* @@ -65,9 +65,7 @@ typedef struct _EMemoTableClass EMemoTableClass; typedef struct _EMemoTablePrivate EMemoTablePrivate; struct _EMemoTable { - GtkTable parent; - - GtkWidget *etable; + ETable parent; /* The ECell used to view & edit dates. */ ECellDateEdit *dates_cell; @@ -79,7 +77,7 @@ struct _EMemoTable { }; struct _EMemoTableClass { - GtkTableClass parent_class; + ETableClass parent_class; /* Signals */ void (*open_component) (EMemoTable *memo_table, @@ -96,7 +94,6 @@ GType e_memo_table_get_type (void); GtkWidget * e_memo_table_new (EShellView *shell_view, ECalModel *model); ECalModel * e_memo_table_get_model (EMemoTable *memo_table); -ETable * e_memo_table_get_table (EMemoTable *memo_table); EShellView * e_memo_table_get_shell_view (EMemoTable *memo_table); icaltimezone * e_memo_table_get_timezone (EMemoTable *memo_table); void e_memo_table_set_timezone (EMemoTable *memo_table, @@ -114,13 +111,6 @@ void e_memo_table_cut_clipboard (EMemoTable *memo_table); void e_memo_table_copy_clipboard (EMemoTable *memo_table); void e_memo_table_paste_clipboard (EMemoTable *memo_table); -/* These load and save the state of the table (headers shown etc.) to/from - the given file. */ -void e_memo_table_load_state (EMemoTable *memo_table, - const gchar *filename); -void e_memo_table_save_state (EMemoTable *memo_table, - const gchar *filename); - G_END_DECLS #endif /* _E_MEMO_TABLE_H_ */ |