/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Author : * Damon Chaplin * * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ /* * ECellDateEditText - a subclass of ECellText used to show and edit the text * representation of the date, from a CalComponentDateTime* model value. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "e-cell-date-edit-text.h" #define PARENT_TYPE e_cell_text_get_type () static ECellTextClass *parent_class; void e_cell_date_edit_text_set_timezone (ECellDateEditText *ecd, icaltimezone *zone) { g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd)); ecd->zone = zone; } void e_cell_date_edit_text_set_use_24_hour_format (ECellDateEditText *ecd, gboolean use_24_hour) { g_return_if_fail (E_IS_CELL_DATE_EDIT_TEXT (ecd)); ecd->use_24_hour_format = use_24_hour; } static char * ecd_get_text (ECellText *cell, ETableModel *model, int col, int row) { ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell); ECellDateEditValue *dv = e_table_model_value_at (model, col, row); struct tm tmp_tm; char buffer[64]; if (!dv) return g_strdup (""); /* Note that although the property may be in a different timezone, we convert it to the current timezone to display it in the table. If the user actually edits the value, it will be set to the current timezone. See set_value(). */ tmp_tm = icaltimetype_to_tm_with_zone (&dv->tt, dv->zone, ecd->zone); e_time_format_date_and_time (&tmp_tm, ecd->use_24_hour_format, !dv->tt.is_date, FALSE, buffer, sizeof (buffer)); return e_utf8_from_locale_string (buffer); } static void ecd_free_text (ECellText *cell, char *text) { g_free (text); } /* FIXME: We need to set the "transient_for" property for the dialog. */ static void show_date_warning (ECellDateEditText *ecd) { GtkWidget *dialog; char buffer[64], message[256], *format; time_t t; struct tm *tmp_tm; t = time (NULL); /* We are only using this as an example, so the timezone doesn't matter. */ tmp_tm = localtime (&t); if (ecd->use_24_hour_format) /* strftime format of a weekday, a date and a time, 24-hour. */ format = _("%a %m/%d/%Y %H:%M:%S"); else /* strftime format of a weekday, a date and a time, 12-hour. */ format = _("%a %m/%d/%Y %I:%M:%S %p"); strftime (buffer, sizeof (buffer), format, tmp_tm); g_snprintf (message, 256, _("The date must be entered in the format: \n\n%s"), buffer); dialog = gnome_message_box_new (message, GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL); gtk_widget_show (dialog); } static void ecd_set_value (ECellText *cell, ETableModel *model, int col, int row, const char *text) { ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (cell); ETimeParseStatus status; struct tm tmp_tm; ECellDateEditValue *value; gboolean is_date = TRUE; /* Try to parse just a date first. If the value is only a date, we use a DATE value. */ status = e_time_parse_date (text, &tmp_tm); if (status == E_TIME_PARSE_INVALID) { is_date = FALSE; status = e_time_parse_date_and_time (text, &tmp_tm); if (status == E_TIME_PARSE_INVALID) { show_date_warning (ecd); return; } } if (status == E_TIME_PARSE_NONE) { value = NULL; } else { ECellDateEditValue dv; dv.tt = icaltime_null_time (); dv.tt.year = tmp_tm.tm_year + 1900; dv.tt.month = tmp_tm.tm_mon + 1; dv.tt.day = tmp_tm.tm_mday; dv.tt.hour = tmp_tm.tm_hour; dv.tt.minute = tmp_tm.tm_min; dv.tt.second = tmp_tm.tm_sec; dv.tt.is_date = is_date; /* FIXME: We assume it is being set to the current timezone. Is that OK? */ if (is_date) { dv.zone = NULL; } else { dv.zone = ecd->zone; } value = &dv; } e_table_model_set_value_at (model, col, row, value); } static void e_cell_date_edit_text_class_init (GtkObjectClass *object_class) { ECellTextClass *ectc = (ECellTextClass *) object_class; parent_class = gtk_type_class (PARENT_TYPE); ectc->get_text = ecd_get_text; ectc->free_text = ecd_free_text; ectc->set_value = ecd_set_value; } static void e_cell_date_edit_text_init (GtkObject *object) { ECellDateEditText *ecd = E_CELL_DATE_EDIT_TEXT (object); ecd->zone = icaltimezone_get_utc_timezone (); ecd->use_24_hour_format = TRUE; } /** * e_cell_date_edit_text_new: * * Creates a new ECell renderer that can be used to render and edit dates that * that come from the model. The value returned from the model is * interpreted as being a CalComponentDateTime*. * * Returns: an ECell object that can be used to render dates. */ ECell * e_cell_date_edit_text_new (const char *fontname, GtkJustification justify) { ECellDateEditText *ecd = g_object_new (e_cell_date_edit_text_get_type (), NULL); e_cell_text_construct (E_CELL_TEXT (ecd), fontname, justify); return (ECell *) ecd; } E_MAKE_TYPE (e_cell_date_edit_text, "ECellDateEditText", ECellDateEditText, e_cell_date_edit_text_class_init, e_cell_date_edit_text_init, PARENT_TYPE); select name='qt'>
Commit message (Expand)AuthorAgeFilesLines
* sysutils/tlsdate: Cosmetic changePo-Chuan Hsieh2021-04-181-3/+3
* sysutils/parallel: Update to 20210322Po-Chuan Hsieh2021-04-182-5/+5
* sysutils/gdisk: Update to 1.0.7Po-Chuan Hsieh2021-04-182-5/+4
* sysutils/debhelper: Update to 13.3.4Po-Chuan Hsieh2021-04-182-4/+4
* sysutils/R-cran-processx: Update to 3.5.1Guangyuan Yang2021-04-182-6/+7
* sysutils/bpytop: Fix pkg-plistLi-Wen Hsu2021-04-181-0/+1
* sysutils/shuf: Use release tarball and switch to HAS_CONFIGUREMateusz Piotrowski2021-04-172-7/+5
* sysutils/shuf: Update to 3.0Mateusz Piotrowski2021-04-173-8/+15
* sysutils/linux-miniconda-installer: Aid for installing and using minicondaJason W. Bacon2021-04-174-0/+48
* sysutils/desktop-installer: Fix accidentally silenced user promptJason W. Bacon2021-04-162-5/+6
* sysutils/vagrant: Enable Bash and Zsh completionsMateusz Piotrowski2021-04-161-1/+15
* sysutils/ansible-{kld,sysrc}: Update to latest commit and convert to slave portsLewis Cook2021-04-164-47/+19
* sysutils/jail_exporter: fix build on ARM / POWERPiotr Kubaj2021-04-163-0/+87
* x11-toolkits/wxgtk31: Update 3.1.4 -> 3.1.5Yuri Victorovich2021-04-161-0/+1
* graphics/poppler: update to 21.04.0Tobias C. Berner2021-04-161-1/+1
* sysutils/rubygem-choria-mcorpc-support: Update to 2.24.2Romain Tartière2021-04-162-4/+4
* sysutils/choria: Update to 0.21.0Romain Tartière2021-04-162-116/+101
* sysutils/rubygem-bolt: Update to 3.6.1Romain Tartière2021-04-162-4/+4
* lang/v8 sysutils/e2fsprogs: Set PORTSCOUT ignore correctlyMateusz Piotrowski2021-04-161-1/+1
* sysutils/ansible-sshjail: Switch to better versioning schemeGuido Falsi2021-04-162-5/+6
* sysutils/dsbmd: Update to 1.11.4Lewis Cook2021-04-162-4/+4
* sysutils/py-py-cpuinfo: Update 7.0.0 -> 8.0.0Yuri Victorovich2021-04-162-4/+4
* Correct MAINTAINER address.Guido Falsi2021-04-161-1/+1
* sysutils/ansible-sshjail: New portGuido Falsi2021-04-164-0/+38
* sysutils/bsdisks: Update to 0.26Gleb Popov2021-04-152-6/+6
* sysutils/py-qmk: Update to 0.0.45Mateusz Piotrowski2021-04-152-6/+9
* Clean up some thingsTobias Kortkamp2021-04-151-1/+1
* sysutils/doctl: Update to 1.59.0Joseph Mingrone2021-04-152-4/+4
* sysutils/graylog: update to 4.0.6Charles Goncalves2021-04-152-7/+6
* New port: sysutils/helmfile: declarative spec for deploying helm chartsNeel Chauhan2021-04-154-0/+395
* sysutils/conan: Update 1.35.0 -> 1.35.1Yuri Victorovich2021-04-152-4/+4
* sysutils/libdnf: Update 0.60.0 -> 0.60.1Yuri Victorovich2021-04-154-29/+17
* Update KDE Frameworks to 5.81.0Tobias C. Berner2021-04-152-6/+6
* sysutils/tenshi: Configure Portscout to ignore invalid versionsMateusz Piotrowski2021-04-141-0/+3
* sysutils/intel-pcm-devel: update g20210326 (9c4f43e) to g20210414 (c047a2c)Vinícius Zavam2021-04-142-6/+6
* Take back some useful portsTobias Kortkamp2021-04-144-4/+4
* sysutils/py-borgmatic: update 1.5.12 to 1.5.13Vinícius Zavam2021-04-142-4/+4
* sysutils/passwordsafe: fix build on powerpc64lePiotr Kubaj2021-04-141-5/+8
* sysutils/tmux: Update to 3.2.Mathieu Arnold2021-04-142-5/+4
* sysutils/tmux: Update bash completion.Mathieu Arnold2021-04-142-7/+11
* sysutils/tmux: Remove obsolete BACKSPACE option.Jan Beich2021-04-142-15/+2
* sysutils/bpytop: Update to 1.0.63Li-Wen Hsu2021-04-142-4/+4
* sysutils/mcfly: Update 0.5.5 -> 0.5.6Yuri Victorovich2021-04-142-5/+4
* sysutils/bareos-server: fix fs_violationsAdriaan de Groot2021-04-142-1/+37
* sysutils/bareos19-server: fix fs_violationsAdriaan de Groot2021-04-142-1/+39
* sysutils/bareos18-server: fix library symlinksAdriaan de Groot2021-04-142-1/+23
* sysutils/bareos18-server: fix plistAdriaan de Groot2021-04-141-1/+0
* devel/sd-mux-ctrl: Rename to match upstreamSofian Brabez2021-04-144-34/+0
* sysutils/bfs: Fix check-sanityKevin Bowling2021-04-141-2/+0
* sysutils/beats6: Update to 6.8.15Juraj Lutter2021-04-132-4/+4
* sysutils/logstash6: Update to 6.8.15Juraj Lutter2021-04-132-4/+4
* sysutils/cbsd: Update to 13.0.4Kirill Ponomarev2021-04-132-17/+16
* sysutils/py-google-compute-engine: Fix google_set_hostname script.Xin LI2021-04-133-65/+5
* sysutils/nut-devel: Update to the latest networkupstools/nut github commit.Cy Schubert2021-04-132-5/+5
* sysutils/cfengine-devel: Update to latest GH commit.Cy Schubert2021-04-132-8/+8
* sysutils/xfce4-settings: Update to 4.16.1Guido Falsi2021-04-134-22/+10
* sysutils/zoxide: Update to 0.6.0Kevin Bowling2021-04-132