[gnome-calendar/ui-rewrite] edit-dialog: show events description, minor tweaks



commit 328ee4b0d4484ae44cec79bd781cf738a7bfefe3
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Mon Oct 27 23:16:06 2014 -0400

    edit-dialog: show events description, minor tweaks

 data/ui/edit-dialog.ui |    4 ++--
 src/gcal-edit-dialog.c |   17 ++++++++++++-----
 src/gcal-utils.c       |   45 +++++++++++++++++++++++++++++++++++++++++++++
 src/gcal-utils.h       |    4 ++++
 4 files changed, 63 insertions(+), 7 deletions(-)
---
diff --git a/data/ui/edit-dialog.ui b/data/ui/edit-dialog.ui
index d3b2fdc..e84939b 100644
--- a/data/ui/edit-dialog.ui
+++ b/data/ui/edit-dialog.ui
@@ -118,6 +118,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="halign">end</property>
+                <property name="valign">start</property>
                 <property name="label" translatable="yes">Notes</property>
                 <style>
                   <class name="dim-label" />
@@ -215,11 +216,10 @@
             </child>
             <child>
               <object class="GtkScrolledWindow" id="scrolled_window">
-                <property name="height_request">80</property>
+                <property name="height_request">120</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="vexpand">True</property>
-                <property name="hscrollbar_policy">never</property>
                 <property name="shadow_type">in</property>
                 <child>
                   <object class="GtkTextView" id="notes_text">
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index a34692c..1626a0d 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -703,12 +703,19 @@ gcal_edit_dialog_set_event_data (GcalEditDialog *dialog,
   priv->ev_store->location = const_text != NULL ? g_strdup (const_text) : "";
 
   /* notes */
-  priv->ev_store->description = "";
+  if (priv->ev_store->description != NULL)
+    g_free (priv->ev_store->description);
 
-  gtk_text_buffer_set_text (
-      gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->notes_text)),
-      priv->ev_store->description,
-      -1);
+  priv->ev_store->description =
+    get_desc_from_component (priv->component,
+                             "\n");
+  if (priv->ev_store->description != NULL)
+    {
+      gtk_text_buffer_set_text (
+          gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->notes_text)),
+          priv->ev_store->description,
+          -1);
+    }
 
   gcal_edit_dialog_set_writable (
       dialog,
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index 9bbe094..5e2137b 100644
--- a/src/gcal-utils.c
+++ b/src/gcal-utils.c
@@ -304,6 +304,51 @@ void print_date (const gchar*        prefix,
   g_free (temp);
 }
 
+/**
+ * get_desc_from_component:
+ * @component:
+ *
+ * Utility method to handle the extraction of the description from an
+ * #ECalComponent. This cycle through the list of #ECalComponentText
+ * and concatenate each string into one.
+ *
+ * Returns: (Transfer full) a new allocated string with the description
+ **/
+gchar*
+get_desc_from_component (ECalComponent *component,
+                         const gchar   *joint_char)
+{
+  GSList *text_list;
+  GSList *l;
+
+  gchar *desc = NULL;
+  e_cal_component_get_description_list (component, &text_list);
+
+  for (l = text_list; l != NULL; l = l->next)
+    {
+      if (l->data != NULL)
+        {
+          ECalComponentText *text;
+          gchar *carrier;
+          text = l->data;
+
+          if (desc != NULL)
+            {
+              carrier = g_strconcat (desc, joint_char, text->value, NULL);
+              g_free (desc);
+              desc = carrier;
+            }
+          else
+            {
+              desc = g_strdup (text->value);
+            }
+        }
+    }
+
+  e_cal_component_free_text_list (text_list);
+  return desc;
+}
+
 /* Function to do a last minute fixup of the AM/PM stuff if the locale
  * and gettext haven't done it right. Most English speaking countries
  * except the USA use the 24 hour clock (UK, Australia etc). However
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
index 6fa0d6d..11e0381 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -21,6 +21,7 @@
 #define __GCAL_UTILS_H__
 
 #include <gtk/gtk.h>
+#include <libecal/libecal.h>
 #include <libical/icaltime.h>
 
 #define ICAL_TIME_TYPE (icaltime_get_type ())
@@ -77,6 +78,9 @@ gint            gcal_compare_event_widget_by_date               (gconstpointer
 void            print_date                                      (const gchar*           prefix,
                                                                  const icaltimetype*    icaltime);
 
+gchar*          get_desc_from_component                         (ECalComponent         *component,
+                                                                 const gchar           *joint_char);
+
 /* code brought from evolution */
 gsize           e_strftime_fix_am_pm                            (gchar                 *str,
                                                                  gsize                  max,


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