r3224 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src

thomas at sita.openmoko.org thomas at sita.openmoko.org
Thu Oct 18 18:01:24 CEST 2007


Author: thomas
Date: 2007-10-18 18:01:23 +0200 (Thu, 18 Oct 2007)
New Revision: 3224

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer-textview.c
Log:
* src/moko-dialer-textview.c: (moko_dialer_textview_set_color): Don't
try to format a blank string


Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-10-18 16:00:21 UTC (rev 3223)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-10-18 16:01:23 UTC (rev 3224)
@@ -1,5 +1,10 @@
 2007-10-18  Thomas Wood  <thomas at openedhand.com>
 
+	* src/moko-dialer-textview.c: (moko_dialer_textview_set_color): Don't
+	try to format a blank string
+
+2007-10-18  Thomas Wood  <thomas at openedhand.com>
+
 	* src/moko-talking.c: (moko_talking_init): Use stock items for
 	talking/incoming/outgoing page toolbars
 

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer-textview.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer-textview.c	2007-10-18 16:00:21 UTC (rev 3223)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer-textview.c	2007-10-18 16:01:23 UTC (rev 3224)
@@ -19,8 +19,11 @@
  
  */
 
+#include <string.h>
+
 #include "moko-dialer-textview.h"
 #include "error.h"
+
 G_DEFINE_TYPE (MokoDialerTextview, moko_dialer_textview, GTK_TYPE_TEXT_VIEW)
      enum
      {
@@ -164,6 +167,12 @@
   GtkTextIter end;
   gint small = 10, medium = 10, large = 10;
 
+  PangoLayout *pl;
+  gchar *text;
+  int pl_w, pl_h, textview_w, textview_h;
+  GdkWindow *textview_window;
+  gboolean centre_v = TRUE;
+
   /* Obtaining the buffer associated with the widget. */
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
 
@@ -174,6 +183,14 @@
   gtk_text_buffer_get_start_iter (buffer, &start);
   gtk_text_buffer_get_end_iter (buffer, &end);
 
+  text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
+  /* no need to continue if we don't have any text */
+  if (!text)
+    return;
+  if (text && (strlen (text) < 1))
+    return;
+
   gint cur = gtk_text_iter_get_offset (&cursoriter);
 
   if (cur > 0)
@@ -203,14 +220,6 @@
   gtk_widget_style_get (GTK_WIDGET (moko_dialer_textview), "medium_font", &medium, NULL);
   gtk_widget_style_get (GTK_WIDGET (moko_dialer_textview), "large_font", &large, NULL);
 
-  PangoLayout *pl;
-  gchar *text;
-  int pl_w, pl_h, textview_w, textview_h;
-  GdkWindow *textview_window;
-  gboolean centre_v = TRUE;
-
-  g_object_get (G_OBJECT (buffer), "text", &text, NULL);
-
   /* create a pango layout to try different text sizes on */
   pl = pango_layout_new (gtk_widget_get_pango_context (GTK_WIDGET (moko_dialer_textview)));
   pango_layout_set_text (pl, text, -1);





More information about the commitlog mailing list