[evolution/gnome-3-32] I#484 - Edit Memo's Start date in-table as DATE by default



commit de243d2e127457cd5f65940259b892dd11ea290d
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jun 13 17:36:23 2019 +0200

    I#484 - Edit Memo's Start date in-table as DATE by default
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/484

 src/calendar/gui/e-memo-table.c | 52 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
---
diff --git a/src/calendar/gui/e-memo-table.c b/src/calendar/gui/e-memo-table.c
index 2415ffff55..07e6dc5bda 100644
--- a/src/calendar/gui/e-memo-table.c
+++ b/src/calendar/gui/e-memo-table.c
@@ -137,6 +137,55 @@ memo_table_get_current_time (ECellDateEdit *ecde,
        return tmp_tm;
 }
 
+static void
+memo_table_date_edit_before_popup_cb (ECellDateEdit *cell_date_edit,
+                                     gint row,
+                                     gint view_col,
+                                     gpointer user_data)
+{
+       EMemoTable *memo_table = user_data;
+       ECellPopup *ecp;
+       ETableItem *eti;
+       ETableCol *ecol;
+       gint col;
+       gboolean date_only;
+
+       g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
+
+       ecp = E_CELL_POPUP (cell_date_edit);
+       eti = E_TABLE_ITEM (ecp->popup_cell_view->cell_view.e_table_item_view);
+       ecol = e_table_header_get_column (eti->header, view_col);
+       col = ecol->spec->model_col;
+
+       date_only = col == E_CAL_MODEL_FIELD_DTSTART;
+
+       if (date_only && e_table_get_cursor_row (E_TABLE (memo_table)) != -1) {
+               ECalModel *model;
+               ECalModelComponent *comp_data;
+               ESelectionModel *esm;
+
+               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);
+
+               model = e_memo_table_get_model (memo_table);
+               comp_data = e_cal_model_get_component_at (model, row);
+               if (comp_data && comp_data->icalcomp) {
+                       icalproperty *prop;
+
+                       prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
+                       if (prop) {
+                               struct icaltimetype dtstart;
+
+                               dtstart = icalproperty_get_dtstart (prop);
+                               date_only = icaltime_is_null_time (dtstart) || icaltime_is_date (dtstart);
+                       }
+               }
+       }
+
+       g_object_set (G_OBJECT (cell_date_edit), "show-time", !date_only, NULL);
+}
+
 /* Deletes all of the selected components in the table */
 static void
 delete_selected_components (EMemoTable *memo_table)
@@ -321,6 +370,9 @@ memo_table_constructed (GObject *object)
                G_BINDING_BIDIRECTIONAL |
                G_BINDING_SYNC_CREATE);
 
+       g_signal_connect (popup_cell, "before-popup",
+               G_CALLBACK (memo_table_date_edit_before_popup_cb), memo_table);
+
        e_table_extras_add_cell (extras, "dateedit", popup_cell);
        g_object_unref (popup_cell);
        memo_table->dates_cell = E_CELL_DATE_EDIT (popup_cell);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]