aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-calendar-table.c
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2005-10-03 14:16:51 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2005-10-03 14:16:51 +0800
commit7a102381acf224110cfe32fcc0905a103268abde (patch)
tree3797369272088bdacc8706e1abff2eca92e1bdfe /calendar/gui/e-calendar-table.c
parent263e728c125f4312867084d9b85b41caabec6a4f (diff)
downloadgsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.gz
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.bz2
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.lz
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.xz
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.zst
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.zip
fixes #264449.
svn path=/trunk/; revision=30467
Diffstat (limited to 'calendar/gui/e-calendar-table.c')
-rw-r--r--calendar/gui/e-calendar-table.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index f789fe40d8..d339ccaf8b 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -55,6 +55,7 @@
#include "print.h"
#include <e-util/e-icon-factory.h>
#include "e-cal-popup.h"
+#include "misc.h"
extern ECompEditorRegistry *comp_editor_registry;
@@ -89,6 +90,9 @@ static struct tm e_calendar_table_get_current_time (ECellDateEdit *ecde,
gpointer data);
static void mark_row_complete_cb (int model_row, gpointer data);
+static void hide_completed_rows (ECalModel *model, GList *clients_list, char *hide_sexp, GPtrArray *comp_objects);
+static void show_completed_rows (ECalModel *model, GList *clients_list, char *show_sexp, GPtrArray *comp_objects);
+
/* Signal IDs */
enum {
USER_CREATED,
@@ -1274,6 +1278,74 @@ e_calendar_table_on_key_press (ETable *table,
return FALSE;
}
+static void
+hide_completed_rows (ECalModel *model, GList *clients_list, char *hide_sexp, GPtrArray *comp_objects)
+{
+ GList *l, *m, *objects;
+ ECal *client;
+ int pos;
+
+ for (l = clients_list; l != NULL; l = l->next) {
+ client = l->data;
+
+ if (!e_cal_get_object_list (client, hide_sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+
+ if ((comp_data = e_cal_model_get_component_for_uid (model, icalcomponent_get_uid (m->data)))) {
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ pos = get_position_in_array (comp_objects, comp_data);
+ e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
+
+ g_ptr_array_remove (comp_objects, comp_data);
+ }
+ }
+
+ g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_list_free (objects);
+ }
+}
+
+static void
+show_completed_rows (ECalModel *model, GList *clients_list, char *show_sexp, GPtrArray *comp_objects)
+{
+ GList *l, *m, *objects;
+ ECal *client;
+
+ for (l = clients_list; l != NULL; l = l->next) {
+ client = l->data;
+
+ if (!e_cal_get_object_list (client, show_sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+
+ if (!(e_cal_model_get_component_for_uid (model, icalcomponent_get_uid (m->data)))) {
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ comp_data = g_new0 (ECalModelComponent, 1);
+ comp_data->client = client;
+ comp_data->icalcomp = icalcomponent_new_clone (m->data);
+ e_cal_model_set_instance_times (comp_data,
+ e_cal_model_get_timezone (model));
+ comp_data->dtstart = comp_data->dtend = comp_data->due = comp_data->completed = NULL;
+ comp_data->color = NULL;
+
+ g_ptr_array_add (comp_objects, comp_data);
+ e_table_model_row_inserted (E_TABLE_MODEL (model), comp_objects->len - 1);
+ }
+ }
+ }
+}
+
/* Loads the state of the table (headers shown etc.) from the given file. */
void
e_calendar_table_load_state (ECalendarTable *cal_table,
@@ -1385,3 +1457,48 @@ e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *mes
e_activity_handler_operation_progressing (cal_table->activity_handler, cal_table->activity_id, message, progress);
}
}
+
+/**
+ * e_calendar_table_hide_completed_tasks:
+ * @table: A calendar table model.
+ * @client_list: Clients List
+ *
+ * Hide completed tasks.
+ */
+void
+e_calendar_table_process_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed)
+{
+ ECalModel *model;
+ static GMutex *mutex = NULL;
+ char *hide_sexp, *show_sexp;
+ GPtrArray *comp_objects = NULL;
+
+ if (!mutex)
+ mutex = g_mutex_new ();
+
+ g_mutex_lock (mutex);
+
+ model = e_calendar_table_get_model (table);
+ comp_objects = e_cal_model_get_object_array (model);
+
+ hide_sexp = calendar_config_get_hide_completed_tasks_sexp (TRUE);
+ show_sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE);
+
+ /* If hide option is unchecked */
+ if (!(hide_sexp && show_sexp))
+ show_sexp = g_strdup ("(is-completed?)");
+
+ /* Delete rows from model*/
+ if (hide_sexp) {
+ hide_completed_rows (model, clients_list, hide_sexp, comp_objects);
+ }
+
+ /* Insert rows into model */
+ if (config_changed) {
+ show_completed_rows (model, clients_list, show_sexp, comp_objects);
+ }
+
+ g_free (hide_sexp);
+ g_free (show_sexp);
+ g_mutex_unlock (mutex);
+}