[gnome-calendar] window: wait for callbacks execution



commit 158523bb6b3f887e5d8d2fb78d13cb9492019833
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Thu Feb 5 17:06:57 2015 -0500

    window: wait for callbacks execution
    
    When the date has been just moved, the ECalDataModel callbacks has not
    had time to execute so the vie wis empty. Schedule a request to allow
    the callbacks execution.

 src/gcal-window.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 8f28ec3..dc2adec 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -44,6 +44,11 @@ struct _NewEventData
 };
 
 typedef struct _NewEventData NewEventData;
+typedef struct
+{
+  GcalWindow *window;
+  gchar *uuid;
+} OpenEditDialogData;
 
 typedef struct
 {
@@ -1154,6 +1159,28 @@ undo_remove_event (GtkButton *button,
 
 }
 
+static gboolean
+schedule_open_edit_dialog_by_uuid (OpenEditDialogData *edit_dialog_data)
+{
+  GcalWindowPrivate *priv;
+  GList *widgets;
+
+  priv = gcal_window_get_instance_private (edit_dialog_data->window);
+  widgets = gcal_view_get_children_by_uuid (GCAL_VIEW (priv->month_view), edit_dialog_data->uuid);
+  if (widgets != NULL)
+    {
+      event_activated (NULL, widgets->data, edit_dialog_data->window);
+      g_list_free (widgets);
+      g_free (edit_dialog_data->uuid);
+      g_free (edit_dialog_data);
+      return FALSE;
+    }
+  else
+    {
+      return TRUE;
+    }
+}
+
 static void
 gcal_window_class_init(GcalWindowClass *klass)
 {
@@ -1576,4 +1603,11 @@ gcal_window_open_event_by_uuid (GcalWindow  *window,
       event_activated (NULL, widgets->data, window);
       g_list_free (widgets);
     }
+  else
+    {
+      OpenEditDialogData *edit_dialog_data = g_new0 (OpenEditDialogData, 1);
+      edit_dialog_data->window = window;
+      edit_dialog_data->uuid = g_strdup (uuid);
+      g_timeout_add_seconds (2, (GSourceFunc) schedule_open_edit_dialog_by_uuid, edit_dialog_data);
+    }
 }


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