r648 - trunk/src/target/OM-2007/applications/openmoko-dialer/src

thomas at sita.openmoko.org thomas at sita.openmoko.org
Thu Feb 1 13:21:52 CET 2007


Author: thomas
Date: 2007-02-01 13:21:39 +0100 (Thu, 01 Feb 2007)
New Revision: 648

Modified:
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h
Log:
Fix indenting


Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,208 +1,218 @@
-/*  ALSA.C -USED TO CONTROL VOLUME
- *  Copyright (C) 2007 Li Jiang
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  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
- */
-
-#include "alsa.h"
-#include <ctype.h>
-#include <glib.h>
-
-/* Set/Get volume */
-static snd_mixer_elem_t *pcm_element = NULL;
-static snd_mixer_t *mixer = NULL;
-
-static mixer_start = TRUE;;
-
-static guint mixer_timeout;
-
-/*
- * mixer stuff
- */
-static void
-parse_mixer_name(char *str, char **name, int *index)
-{
-    char *end;
-
-    while (isspace(*str))
-        str++;
-
-    if ((end = strchr(str, ',')) != NULL) {
-        *name = g_strndup(str, end - str);
-        end++;
-        *index = atoi(end);
-    }
-    else {
-        *name = g_strdup(str);
-        *index = 0;
-    }
-}
-
-int
-alsa_get_mixer(snd_mixer_t ** mixer, int card)
-{
-    char *dev;
-    int err;
-
-    g_debug("alsa_get_mixer");
-
-    dev = g_strdup_printf("hw:%i", card);
-
-    if ((err = snd_mixer_open(mixer, 0)) < 0) {
-        g_warning("alsa_get_mixer(): Failed to open empty mixer: %s",
-                  snd_strerror(-err));
-        mixer = NULL;
-        return -1;
-    }
-    if ((err = snd_mixer_attach(*mixer, dev)) < 0) {
-        g_warning("alsa_get_mixer(): Attaching to mixer %s failed: %s",
-                  dev, snd_strerror(-err));
-        return -1;
-    }
-    if ((err = snd_mixer_selem_register(*mixer, NULL, NULL)) < 0) {
-        g_warning("alsa_get_mixer(): Failed to register mixer: %s",
-                  snd_strerror(-err));
-        return -1;
-    }
-    if ((err = snd_mixer_load(*mixer)) < 0) {
-        g_warning("alsa_get_mixer(): Failed to load mixer: %s",
-                  snd_strerror(-err));
-        return -1;
-    }
-
-    g_free(dev);
-
-    return (*mixer != NULL);
-}
-
-
-static snd_mixer_elem_t* alsa_get_mixer_elem(snd_mixer_t *mixer, char *name, int index)
-{
-    snd_mixer_selem_id_t *selem_id;
-    snd_mixer_elem_t *elem;
-    snd_mixer_selem_id_alloca(&selem_id);
-
-    if (index != -1)
-        snd_mixer_selem_id_set_index(selem_id, index);
-    if (name != NULL)
-        snd_mixer_selem_id_set_name(selem_id, name);
-
-    elem = snd_mixer_find_selem(mixer, selem_id);
-
-    return elem;
-}
-
-static int
-alsa_setup_mixer(void)
-{
-    char *name;
-    long int a, b;
-    long alsa_min_vol, alsa_max_vol;
-    int err, index;
-
-    g_debug("alsa_setup_mixer");
-
-    if ((err = alsa_get_mixer(&mixer, 0)) < 0)
-        return err;
-
-    parse_mixer_name("Master", &name, &index);
-
-    pcm_element = alsa_get_mixer_elem(mixer, name, index);
-
-    g_free(name);
-
-    if (!pcm_element) {
-        g_warning("alsa_setup_mixer(): Failed to find mixer element: Master");
-        return -1;
-    }
-
-    /*
-     * Work around a bug in alsa-lib up to 1.0.0rc2 where the
-     * new range don't take effect until the volume is changed.
-     * This hack should be removed once we depend on Alsa 1.0.0.
-     */
-    snd_mixer_selem_get_playback_volume(pcm_element,
-                                        SND_MIXER_SCHN_FRONT_LEFT, &a);
-    snd_mixer_selem_get_playback_volume(pcm_element,
-                                        SND_MIXER_SCHN_FRONT_RIGHT, &b);
-
-    snd_mixer_selem_get_playback_volume_range(pcm_element,
-                                              &alsa_min_vol, &alsa_max_vol);
-    snd_mixer_selem_set_playback_volume_range(pcm_element, 0, 100);
-
-    if (alsa_max_vol == 0) {
-        pcm_element = NULL;
-        return -1;
-    }
-
-    g_debug("alsa_setup_mixer: end");
-
-    return 0;
-}
-
-static int
-alsa_mixer_timeout(void *data)
-{
-    if (mixer) {
-        snd_mixer_close(mixer);
-        mixer = NULL;
-        pcm_element = NULL;
-    }
-    mixer_timeout = 0;
-    mixer_start = TRUE;
-
-    g_message("alsa mixer timed out");
-    return FALSE;
-}
-
-void
-alsa_get_volume(int *l, int *r)
-{
-    long ll = *l, lr = *r;
-
-    if (mixer_start) {
-        alsa_setup_mixer();
-        mixer_start = FALSE;
-    }
-
-    if (!pcm_element)
-        return;
-
-    snd_mixer_handle_events(mixer);
-
-    snd_mixer_selem_get_playback_volume(pcm_element,
-                                            SND_MIXER_SCHN_FRONT_LEFT, &ll);
-    snd_mixer_selem_get_playback_volume(pcm_element,
-                                            SND_MIXER_SCHN_FRONT_RIGHT, &lr);
-    *l = ll;
-    *r = lr;
-
-    if (mixer_timeout)
-        gtk_timeout_remove(mixer_timeout);
-    mixer_timeout = gtk_timeout_add(5000, alsa_mixer_timeout, NULL);
-}
-
-
-void
-alsa_set_volume(int l, int r)
-{
-    if (!pcm_element)
-        return;
-
-    snd_mixer_selem_set_playback_volume(pcm_element,
-                                            SND_MIXER_SCHN_FRONT_LEFT, l);
-    snd_mixer_selem_set_playback_volume(pcm_element,
-                                            SND_MIXER_SCHN_FRONT_RIGHT, r);
-}
-
+/*  ALSA.C -USED TO CONTROL VOLUME
+ *  Copyright (C) 2007 Li Jiang
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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
+ */
+
+#include "alsa.h"
+#include <ctype.h>
+#include <glib.h>
+
+/* Set/Get volume */
+static snd_mixer_elem_t *pcm_element = NULL;
+static snd_mixer_t *mixer = NULL;
+
+static mixer_start = TRUE;;
+
+static guint mixer_timeout;
+
+/*
+ * mixer stuff
+ */
+static void
+parse_mixer_name (char *str, char **name, int *index)
+{
+  char *end;
+
+  while (isspace (*str))
+    str++;
+
+  if ((end = strchr (str, ',')) != NULL)
+  {
+    *name = g_strndup (str, end - str);
+    end++;
+    *index = atoi (end);
+  }
+  else
+  {
+    *name = g_strdup (str);
+    *index = 0;
+  }
+}
+
+int
+alsa_get_mixer (snd_mixer_t ** mixer, int card)
+{
+  char *dev;
+  int err;
+
+  g_debug ("alsa_get_mixer");
+
+  dev = g_strdup_printf ("hw:%i", card);
+
+  if ((err = snd_mixer_open (mixer, 0)) < 0)
+  {
+    g_warning ("alsa_get_mixer(): Failed to open empty mixer: %s",
+               snd_strerror (-err));
+    mixer = NULL;
+    return -1;
+  }
+  if ((err = snd_mixer_attach (*mixer, dev)) < 0)
+  {
+    g_warning ("alsa_get_mixer(): Attaching to mixer %s failed: %s",
+               dev, snd_strerror (-err));
+    return -1;
+  }
+  if ((err = snd_mixer_selem_register (*mixer, NULL, NULL)) < 0)
+  {
+    g_warning ("alsa_get_mixer(): Failed to register mixer: %s",
+               snd_strerror (-err));
+    return -1;
+  }
+  if ((err = snd_mixer_load (*mixer)) < 0)
+  {
+    g_warning ("alsa_get_mixer(): Failed to load mixer: %s",
+               snd_strerror (-err));
+    return -1;
+  }
+
+  g_free (dev);
+
+  return (*mixer != NULL);
+}
+
+
+static snd_mixer_elem_t *
+alsa_get_mixer_elem (snd_mixer_t * mixer, char *name, int index)
+{
+  snd_mixer_selem_id_t *selem_id;
+  snd_mixer_elem_t *elem;
+  snd_mixer_selem_id_alloca (&selem_id);
+
+  if (index != -1)
+    snd_mixer_selem_id_set_index (selem_id, index);
+  if (name != NULL)
+    snd_mixer_selem_id_set_name (selem_id, name);
+
+  elem = snd_mixer_find_selem (mixer, selem_id);
+
+  return elem;
+}
+
+static int
+alsa_setup_mixer (void)
+{
+  char *name;
+  long int a, b;
+  long alsa_min_vol, alsa_max_vol;
+  int err, index;
+
+  g_debug ("alsa_setup_mixer");
+
+  if ((err = alsa_get_mixer (&mixer, 0)) < 0)
+    return err;
+
+  parse_mixer_name ("Master", &name, &index);
+
+  pcm_element = alsa_get_mixer_elem (mixer, name, index);
+
+  g_free (name);
+
+  if (!pcm_element)
+  {
+    g_warning ("alsa_setup_mixer(): Failed to find mixer element: Master");
+    return -1;
+  }
+
+  /*
+   * Work around a bug in alsa-lib up to 1.0.0rc2 where the
+   * new range don't take effect until the volume is changed.
+   * This hack should be removed once we depend on Alsa 1.0.0.
+   */
+  snd_mixer_selem_get_playback_volume (pcm_element,
+                                       SND_MIXER_SCHN_FRONT_LEFT, &a);
+  snd_mixer_selem_get_playback_volume (pcm_element,
+                                       SND_MIXER_SCHN_FRONT_RIGHT, &b);
+
+  snd_mixer_selem_get_playback_volume_range (pcm_element,
+                                             &alsa_min_vol, &alsa_max_vol);
+  snd_mixer_selem_set_playback_volume_range (pcm_element, 0, 100);
+
+  if (alsa_max_vol == 0)
+  {
+    pcm_element = NULL;
+    return -1;
+  }
+
+  g_debug ("alsa_setup_mixer: end");
+
+  return 0;
+}
+
+static int
+alsa_mixer_timeout (void *data)
+{
+  if (mixer)
+  {
+    snd_mixer_close (mixer);
+    mixer = NULL;
+    pcm_element = NULL;
+  }
+  mixer_timeout = 0;
+  mixer_start = TRUE;
+
+  g_message ("alsa mixer timed out");
+  return FALSE;
+}
+
+void
+alsa_get_volume (int *l, int *r)
+{
+  long ll = *l, lr = *r;
+
+  if (mixer_start)
+  {
+    alsa_setup_mixer ();
+    mixer_start = FALSE;
+  }
+
+  if (!pcm_element)
+    return;
+
+  snd_mixer_handle_events (mixer);
+
+  snd_mixer_selem_get_playback_volume (pcm_element,
+                                       SND_MIXER_SCHN_FRONT_LEFT, &ll);
+  snd_mixer_selem_get_playback_volume (pcm_element,
+                                       SND_MIXER_SCHN_FRONT_RIGHT, &lr);
+  *l = ll;
+  *r = lr;
+
+  if (mixer_timeout)
+    gtk_timeout_remove (mixer_timeout);
+  mixer_timeout = gtk_timeout_add (5000, alsa_mixer_timeout, NULL);
+}
+
+
+void
+alsa_set_volume (int l, int r)
+{
+  if (!pcm_element)
+    return;
+
+  snd_mixer_selem_set_playback_volume (pcm_element,
+                                       SND_MIXER_SCHN_FRONT_LEFT, l);
+  snd_mixer_selem_set_playback_volume (pcm_element,
+                                       SND_MIXER_SCHN_FRONT_RIGHT, r);
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/alsa.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,36 +1,36 @@
-/*  ALSA.H -USED TO CONTROL VOLUME
- *  Copyright (C) 2007 Li Jiang 
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  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
- */
-#ifndef ALSA_H
-#define ALSA_H
-
-#define ALSA_PCM_NEW_HW_PARAMS_API
-#define ALSA_PCM_NEW_SW_PARAMS_API
-#include <alsa/asoundlib.h>
-#include <alsa/pcm_plugin.h>
-
-#include <gtk/gtk.h>
-
-#ifdef WORDS_BIGENDIAN
-# define IS_BIG_ENDIAN TRUE
-#else
-# define IS_BIG_ENDIAN FALSE
-#endif
-
-void alsa_get_volume(int *l, int *r);
-void alsa_set_volume(int l, int r);
-
-#endif
+/*  ALSA.H -USED TO CONTROL VOLUME
+ *  Copyright (C) 2007 Li Jiang 
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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
+ */
+#ifndef ALSA_H
+#define ALSA_H
+
+#define ALSA_PCM_NEW_HW_PARAMS_API
+#define ALSA_PCM_NEW_SW_PARAMS_API
+#include <alsa/asoundlib.h>
+#include <alsa/pcm_plugin.h>
+
+#include <gtk/gtk.h>
+
+#ifdef WORDS_BIGENDIAN
+# define IS_BIG_ENDIAN TRUE
+#else
+# define IS_BIG_ENDIAN FALSE
+#endif
+
+void alsa_get_volume (int *l, int *r);
+void alsa_set_volume (int l, int r);
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,194 +1,204 @@
-/*  common.c
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-#include "moko-dialer-declares.h"
- #include "common.h"
- #include "error.h"
-/**
- * @brief Create a pixbuf by the filename from the PKGDATADIR
- * @param filename The filename of the pixbuf file
- * @return The GdkPixbuf. If can not find the file, it will return NULL.
- */
-GdkPixbuf *
-create_pixbuf (const gchar *filename)
-{
-  gchar     *pathname;
-  GdkPixbuf *pixbuf = NULL;
-  GError    *error = NULL;
-
-  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
-                              filename);
-  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-    {
-      pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
-      if (!pixbuf)
-        {
-          fprintf (stderr, "Fail to load pixbuf file %s: %s\n", 
-                   pathname, error->message);
-          g_error_free (error);
-        }
-    }
-  else
-    {
-      g_debug ("Can not find the file %s", pathname);
-    }
-  g_free (pathname);
-  return pixbuf;
-}
-
-/**
- * @brief Create a filepath by the filename from the PKGDATADIR
- * @param filename The filename of the pixbuf file
- * @return TURE, FALSE
- */
-
-gboolean file_create_data_path_for_the_file(const gchar* filename, gchar* path)
-{
-  gchar     *pathname;
-
-  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
-                              filename);
-  
-  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-    {
-    strcpy(path,pathname);
-    g_free (pathname);
-    return TRUE;
-    
-    }
-  else
-    {
-      g_debug ("Can not find the file %s", pathname);
-      g_free (pathname);
-      return FALSE;
-    }
-
-
-}
-
-
-/**
- * @brief load the person's image file by the filename from the PKGDATADIR
- * @param rela_path The filename of the pixbuf file
- * @param widget, the gtkImage to load the file.
- * @return TURE, FALSE
- */
-gboolean file_load_person_image_from_relative_path(GtkWidget *widget,char * rela_path)
-{
-
-  gchar     *pathname;
-  GtkImage *image=GTK_IMAGE(widget);	  
-
-  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
-                              rela_path);
-
-
-  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-    {
-	    gtk_image_set_from_file(image,pathname);   	
-	    g_free (pathname);
-	    return TRUE;
-    }
-  else
-    {
-    //first we load the default picture 
- 	  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
-                              MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
-	  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-	    {
-	    gtk_image_set_from_file(image,pathname);   	
-	    g_free (pathname);
-	    return TRUE;
-	    }
-	  else
-	  	{
-	      g_debug ("Can not find the file %s", pathname);
-	       gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-	      g_free (pathname);
-	      return FALSE;
-	  	}
-    }
-}
-
-
-GtkWidget * file_new_image_from_relative_path(char * rela_path)
-{
-
- 
-  gchar     *pathname;
-  GtkImage *image=0;	  
-
-  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
-                              rela_path);
-
-
-  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-    {
-	   image= gtk_image_new_from_file(pathname);   	
-    }
-  else
-    {
-//	      g_debug ("Can not find the file %s", pathname);
-	   image=  gtk_image_new_from_stock("gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-
-    }
-	      g_free (pathname);
-	      return image;
-}
-
-
-/**
- * @brief load the person's image file by the filename from the PKGDATADIR, and strech it.
- * @param rela_path The filename of the pixbuf file
- * @param widget, the gtkImage to load the file.
- * @return TURE, FALSE
- */
-gboolean file_load_person_image_scalable_from_relative_path(GtkWidget *widget,char * rela_path)
-{
-
-  gchar     *pathname;
-  GtkImage *image=GTK_IMAGE(widget);	  
-
-  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
-                              rela_path);
-
-
-  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-    {
-	//    gtk_image_set_from_file(image,pathname);   	
-	    GError* err = NULL;
-	    GdkPixbuf *src_pixbuf, *dest_pixbuf;
-	    src_pixbuf = gdk_pixbuf_new_from_file ( pathname, &err );
-	    DBG_MESSAGE("file_load_person_image_scalable_from_relative_path,width=%d,height=%d",widget->allocation.width, widget->allocation.height);
-	    
-//	    dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, widget->requisition.width, widget->requisition.height, GDK_INTERP_NEAREST);
-	    dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, widget->allocation.width, widget->allocation.height, GDK_INTERP_NEAREST);
-	     gtk_image_set_from_pixbuf (image,dest_pixbuf);
-	    g_free (pathname);
-	    return TRUE;
-    }
-  else
-    {
-	      g_debug ("Can not find the file %s", pathname);
-	       gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-	      g_free (pathname);
-	      return FALSE;
-    }
-
-
-}
-
+/*  common.c
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-declares.h"
+#include "common.h"
+#include "error.h"
+/**
+ * @brief Create a pixbuf by the filename from the PKGDATADIR
+ * @param filename The filename of the pixbuf file
+ * @return The GdkPixbuf. If can not find the file, it will return NULL.
+ */
+GdkPixbuf *
+create_pixbuf (const gchar * filename)
+{
+  gchar *pathname;
+  GdkPixbuf *pixbuf = NULL;
+  GError *error = NULL;
+
+  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S,
+                              filename);
+  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+  {
+    pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+    if (!pixbuf)
+    {
+      fprintf (stderr, "Fail to load pixbuf file %s: %s\n",
+               pathname, error->message);
+      g_error_free (error);
+    }
+  }
+  else
+  {
+    g_debug ("Can not find the file %s", pathname);
+  }
+  g_free (pathname);
+  return pixbuf;
+}
+
+/**
+ * @brief Create a filepath by the filename from the PKGDATADIR
+ * @param filename The filename of the pixbuf file
+ * @return TURE, FALSE
+ */
+
+gboolean
+file_create_data_path_for_the_file (const gchar * filename, gchar * path)
+{
+  gchar *pathname;
+
+  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S,
+                              filename);
+
+  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+  {
+    strcpy (path, pathname);
+    g_free (pathname);
+    return TRUE;
+
+  }
+  else
+  {
+    g_debug ("Can not find the file %s", pathname);
+    g_free (pathname);
+    return FALSE;
+  }
+
+
+}
+
+
+/**
+ * @brief load the person's image file by the filename from the PKGDATADIR
+ * @param rela_path The filename of the pixbuf file
+ * @param widget, the gtkImage to load the file.
+ * @return TURE, FALSE
+ */
+gboolean
+file_load_person_image_from_relative_path (GtkWidget * widget,
+                                           char *rela_path)
+{
+
+  gchar *pathname;
+  GtkImage *image = GTK_IMAGE (widget);
+
+  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S,
+                              rela_path);
+
+
+  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+  {
+    gtk_image_set_from_file (image, pathname);
+    g_free (pathname);
+    return TRUE;
+  }
+  else
+  {
+    //first we load the default picture 
+    pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S,
+                                MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+    if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+    {
+      gtk_image_set_from_file (image, pathname);
+      g_free (pathname);
+      return TRUE;
+    }
+    else
+    {
+      g_debug ("Can not find the file %s", pathname);
+      gtk_image_set_from_stock (image, "gtk-yes",
+                                GTK_ICON_SIZE_LARGE_TOOLBAR);
+      g_free (pathname);
+      return FALSE;
+    }
+  }
+}
+
+
+GtkWidget *
+file_new_image_from_relative_path (char *rela_path)
+{
+
+
+  gchar *pathname;
+  GtkImage *image = 0;
+
+  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S,
+                              rela_path);
+
+
+  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+  {
+    image = gtk_image_new_from_file (pathname);
+  }
+  else
+  {
+//            g_debug ("Can not find the file %s", pathname);
+    image = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+
+  }
+  g_free (pathname);
+  return image;
+}
+
+
+/**
+ * @brief load the person's image file by the filename from the PKGDATADIR, and strech it.
+ * @param rela_path The filename of the pixbuf file
+ * @param widget, the gtkImage to load the file.
+ * @return TURE, FALSE
+ */
+gboolean
+file_load_person_image_scalable_from_relative_path (GtkWidget * widget,
+                                                    char *rela_path)
+{
+
+  gchar *pathname;
+  GtkImage *image = GTK_IMAGE (widget);
+
+  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S,
+                              rela_path);
+
+
+  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+  {
+    //    gtk_image_set_from_file(image,pathname);          
+    GError *err = NULL;
+    GdkPixbuf *src_pixbuf, *dest_pixbuf;
+    src_pixbuf = gdk_pixbuf_new_from_file (pathname, &err);
+    DBG_MESSAGE
+      ("file_load_person_image_scalable_from_relative_path,width=%d,height=%d",
+       widget->allocation.width, widget->allocation.height);
+
+//          dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, widget->requisition.width, widget->requisition.height, GDK_INTERP_NEAREST);
+    dest_pixbuf =
+      gdk_pixbuf_scale_simple (src_pixbuf, widget->allocation.width,
+                               widget->allocation.height, GDK_INTERP_NEAREST);
+    gtk_image_set_from_pixbuf (image, dest_pixbuf);
+    g_free (pathname);
+    return TRUE;
+  }
+  else
+  {
+    g_debug ("Can not find the file %s", pathname);
+    gtk_image_set_from_stock (image, "gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+    g_free (pathname);
+    return FALSE;
+  }
+
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,29 +1,29 @@
-/*  common.h
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _DIALER_COMMON_H
-#define _DIALER_COMMON_H
-
-#include <gtk/gtk.h>
-
-GdkPixbuf *create_pixbuf (const gchar *filename);
-gboolean file_create_data_path_for_the_file(const gchar* filename, gchar* path);
-gboolean file_load_person_image_from_relative_path(GtkWidget *widget,char * rela_path);
-GtkWidget * file_new_image_from_relative_path(char * rela_path);
-#endif
-
-
+/*  common.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _DIALER_COMMON_H
+#define _DIALER_COMMON_H
+
+#include <gtk/gtk.h>
+
+GdkPixbuf *create_pixbuf (const gchar * filename);
+gboolean file_create_data_path_for_the_file (const gchar * filename,
+                                             gchar * path);
+gboolean file_load_person_image_from_relative_path (GtkWidget * widget,
+                                                    char *rela_path);
+GtkWidget *file_new_image_from_relative_path (char *rela_path);
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -15,27 +15,29 @@
  *
  *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
  */
-#include "contacts.h" 
+#include "contacts.h"
 
 /**
  * @brief initialze the contact list, this will be called from outside, contactlist
 */
-int contact_init_contact_data(DIALER_CONTACTS_LIST_HEAD   *p_contactlist)
-{ 
-	
+int
+contact_init_contact_data (DIALER_CONTACTS_LIST_HEAD * p_contactlist)
+{
 
-  DBG_ENTER();
 
+  DBG_ENTER ();
+
   int res = contact_init_contact_list (p_contactlist);
 
-  if(res == -1)
+  if (res == -1)
   {
     res = contact_init_from_cmd (p_contactlist);
   }
-  DBG_MESSAGE("CONTACTS:%d,list at 0x%x,first at 0x%x",p_contactlist->length,p_contactlist,p_contactlist->contacts);
-  
-  DBG_LEAVE();
-  
+  DBG_MESSAGE ("CONTACTS:%d,list at 0x%x,first at 0x%x", p_contactlist->length,
+               p_contactlist, p_contactlist->contacts);
+
+  DBG_LEAVE ();
+
   return res;
 }
 
@@ -53,10 +55,11 @@
 
 
 
-int contact_init_contact_list(DIALER_CONTACTS_LIST_HEAD * head)
+int
+contact_init_contact_list (DIALER_CONTACTS_LIST_HEAD * head)
 {
-	
-	return -1;
+
+  return -1;
 }
 
 /**
@@ -68,23 +71,25 @@
  * @return the number of the contacts. 
  * @retval 1
  */
-int contact_release_contact_entry(DIALER_CONTACT_ENTRY* contactentry)
+int
+contact_release_contact_entry (DIALER_CONTACT_ENTRY * contactentry)
 {
-	if(contactentry==0) return 1;
-		if(contactentry->desc)
-		{
-		free(contactentry->desc);
-		contactentry->desc=0;	
-		}
-		if(contactentry->content)
-		{
-			free(contactentry->content);
-			contactentry->content=0;
-		}
-		contactentry->next=0;
-		free(contactentry);
-	
-		return 1;
+  if (contactentry == 0)
+    return 1;
+  if (contactentry->desc)
+  {
+    free (contactentry->desc);
+    contactentry->desc = 0;
+  }
+  if (contactentry->content)
+  {
+    free (contactentry->content);
+    contactentry->content = 0;
+  }
+  contactentry->next = 0;
+  free (contactentry);
+
+  return 1;
 }
 
 /**
@@ -96,37 +101,39 @@
  * @return 
  * @retval 1
  */
-int contact_release_contact(DIALER_CONTACT *contact)
+int
+contact_release_contact (DIALER_CONTACT * contact)
 {
-	DIALER_CONTACT_ENTRY * entry=0;
-	DIALER_CONTACT_ENTRY * nextentry=0;
-	if(contact==0)return 1;
-	entry=contact->entry;
-	//free every entry
-	while(entry)
-	{
-		nextentry=entry->next;
-		contact_release_contact_entry(entry);
-		entry=nextentry;
-	}
-	contact->entry=0;
-	
-	//free name
-	if(contact->name)
-	{
-	free(contact->name);
-	contact->name=0;
-	}
-	//free picpath
-	if(contact->picpath)
-	{
-		free(contact->picpath);
-		contact->picpath=0;
-	}
-	//free contact itself
-	contact->entry=0;
-	free(contact);
-	return 1;
+  DIALER_CONTACT_ENTRY *entry = 0;
+  DIALER_CONTACT_ENTRY *nextentry = 0;
+  if (contact == 0)
+    return 1;
+  entry = contact->entry;
+  //free every entry
+  while (entry)
+  {
+    nextentry = entry->next;
+    contact_release_contact_entry (entry);
+    entry = nextentry;
+  }
+  contact->entry = 0;
+
+  //free name
+  if (contact->name)
+  {
+    free (contact->name);
+    contact->name = 0;
+  }
+  //free picpath
+  if (contact->picpath)
+  {
+    free (contact->picpath);
+    contact->picpath = 0;
+  }
+  //free contact itself
+  contact->entry = 0;
+  free (contact);
+  return 1;
 }
 
 /**
@@ -138,28 +145,30 @@
  * @return 
  * @retval 1
  */
-int contact_release_contact_list(DIALER_CONTACTS_LIST_HEAD * head)
+int
+contact_release_contact_list (DIALER_CONTACTS_LIST_HEAD * head)
 {
-//	g_printf("releasing %s\n",contact->name);
-	DIALER_CONTACT* contact=0;
-	DIALER_CONTACT* nextcontact=0;
-	if(head==0)return 1;
-	contact=head->contacts;
-	if(contact==0)
-		return 1;
-	
-	while(contact)
-	{
-	//	g_printf("releasing %s\n",contact->name);
-		nextcontact=contact->next;
-		contact_release_contact(contact);
-		contact=nextcontact;
-	}
-	head->length=0;
-	head->contacts=0;
-	return 1;
-	
-	
+//      g_printf("releasing %s\n",contact->name);
+  DIALER_CONTACT *contact = 0;
+  DIALER_CONTACT *nextcontact = 0;
+  if (head == 0)
+    return 1;
+  contact = head->contacts;
+  if (contact == 0)
+    return 1;
+
+  while (contact)
+  {
+    //      g_printf("releasing %s\n",contact->name);
+    nextcontact = contact->next;
+    contact_release_contact (contact);
+    contact = nextcontact;
+  }
+  head->length = 0;
+  head->contacts = 0;
+  return 1;
+
+
 }
 
 /**
@@ -174,30 +183,35 @@
  */
 
 
-int contact_add_contact_to_list(DIALER_CONTACTS_LIST_HEAD * head,DIALER_CONTACT*   contact)
+int
+contact_add_contact_to_list (DIALER_CONTACTS_LIST_HEAD * head,
+                             DIALER_CONTACT * contact)
 {
-if(head==0)return 0;
-if(contact==0)return 0;
+  if (head == 0)
+    return 0;
+  if (contact == 0)
+    return 0;
 
-if(head->contacts==0)
-{
-	//we are the first
-	head->length=1;
-	head->contacts=contact;
-	contact->next=0;
-	contact->ID=0;
-}else
-{
-	contact->ID=head->length;
-	contact->next=head->contacts;
-	head->contacts=contact;
-	head->length++;
-	
-}
+  if (head->contacts == 0)
+  {
+    //we are the first
+    head->length = 1;
+    head->contacts = contact;
+    contact->next = 0;
+    contact->ID = 0;
+  }
+  else
+  {
+    contact->ID = head->length;
+    contact->next = head->contacts;
+    head->contacts = contact;
+    head->length++;
 
-	return contact->ID;
-	
-	
+  }
+
+  return contact->ID;
+
+
 }
 
 /**
@@ -212,19 +226,20 @@
  */
 
 
-DIALER_CONTACT*  contact_new_contact(char* name, char* picpath)
+DIALER_CONTACT *
+contact_new_contact (char *name, char *picpath)
 {
-	DIALER_CONTACT* nextcontact;
+  DIALER_CONTACT *nextcontact;
 
-	nextcontact=(DIALER_CONTACT* )calloc(1,sizeof(DIALER_CONTACT));
-	nextcontact->ID=0;
-	nextcontact->name=(char *)calloc(1,30);
-	strcpy(nextcontact->name,name);
-	
-	nextcontact->picpath=(char *)calloc(1,128);
-	strcpy(nextcontact->picpath,picpath);
-	
-	return nextcontact;
+  nextcontact = (DIALER_CONTACT *) calloc (1, sizeof (DIALER_CONTACT));
+  nextcontact->ID = 0;
+  nextcontact->name = (char *) calloc (1, 30);
+  strcpy (nextcontact->name, name);
+
+  nextcontact->picpath = (char *) calloc (1, 128);
+  strcpy (nextcontact->picpath, picpath);
+
+  return nextcontact;
 }
 
 /**
@@ -240,26 +255,32 @@
  */
 
 
-DIALER_CONTACT_ENTRY* contact_add_entry(DIALER_CONTACT* contact, char* desc,char* content)
+DIALER_CONTACT_ENTRY *
+contact_add_entry (DIALER_CONTACT * contact, char *desc, char *content)
 {
-	
-	DIALER_CONTACT_ENTRY* nextentry;
-	
-	if(contact==0)return 0;
-	if(desc==0)return 0;
-	if(content==0)return 0;
-	nextentry=(DIALER_CONTACT_ENTRY*)calloc(1,sizeof(DIALER_CONTACT_ENTRY));
-	nextentry->desc=(char *)calloc(1,30);
-	strcpy(nextentry->desc,desc);
-	nextentry->content=(char *)calloc(1,30);
-	strcpy(nextentry->content,content);
-	
-	
-	nextentry->next=contact->entry;
-	contact->entry=nextentry;
-	
-	return nextentry;
+
+  DIALER_CONTACT_ENTRY *nextentry;
+
+  if (contact == 0)
+    return 0;
+  if (desc == 0)
+    return 0;
+  if (content == 0)
+    return 0;
+  nextentry =
+    (DIALER_CONTACT_ENTRY *) calloc (1, sizeof (DIALER_CONTACT_ENTRY));
+  nextentry->desc = (char *) calloc (1, 30);
+  strcpy (nextentry->desc, desc);
+  nextentry->content = (char *) calloc (1, 30);
+  strcpy (nextentry->content, content);
+
+
+  nextentry->next = contact->entry;
+  contact->entry = nextentry;
+
+  return nextentry;
 }
+
 /**
  * @brief initialize the contact list from the inner information,only for use tempararily
  * in the case that contact API returns NULL, we will call this function for debug.
@@ -271,41 +292,43 @@
  * @retval 
  */
 
-int contact_init_from_cmd(DIALER_CONTACTS_LIST_HEAD * head)
+int
+contact_init_from_cmd (DIALER_CONTACTS_LIST_HEAD * head)
 {
-	DIALER_CONTACT* contact;
-	if(head==0)return 0;
-	contact=contact_new_contact("Tony Guan","tony.png");
-	contact_add_entry(contact,"cell","13917209523");
-	contact_add_entry(contact,"work","02162495726");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Sally Xu","sally.png");
-	contact_add_entry(contact,"cell","13361900551");
-	contact_add_entry(contact,"work","02165538452");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Chaowei Song","chaowei.png");
-	contact_add_entry(contact,"work1","02162495727");
-	contact_add_entry(contact,"work4","02162495730");
-	contact_add_entry(contact,"work5","02162495731");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Ken Zhao","ken.png");
-	contact_add_entry(contact,"work2","02162495728");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Steven Chen","steven.png");
-	contact_add_entry(contact,"work3","02162495729");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("10086","10086.png");
-	contact_add_entry(contact,"work","10086");
-	contact_add_contact_to_list(head,contact);
+  DIALER_CONTACT *contact;
+  if (head == 0)
+    return 0;
+  contact = contact_new_contact ("Tony Guan", "tony.png");
+  contact_add_entry (contact, "cell", "13917209523");
+  contact_add_entry (contact, "work", "02162495726");
+  contact_add_contact_to_list (head, contact);
 
-	return head->length;	
-	
-	
+  contact = contact_new_contact ("Sally Xu", "sally.png");
+  contact_add_entry (contact, "cell", "13361900551");
+  contact_add_entry (contact, "work", "02165538452");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("Chaowei Song", "chaowei.png");
+  contact_add_entry (contact, "work1", "02162495727");
+  contact_add_entry (contact, "work4", "02162495730");
+  contact_add_entry (contact, "work5", "02162495731");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("Ken Zhao", "ken.png");
+  contact_add_entry (contact, "work2", "02162495728");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("Steven Chen", "steven.png");
+  contact_add_entry (contact, "work3", "02162495729");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("10086", "10086.png");
+  contact_add_entry (contact, "work", "10086");
+  contact_add_contact_to_list (head, contact);
+
+  return head->length;
+
+
 }
 
 /**
@@ -321,42 +344,46 @@
  * @retval 
  */
 
-int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number)
+int
+contact_get_info_from_number (DIALER_CONTACT * contacts, char *name,
+                              char *picpath, const char *number)
 {
 
 
-	strcpy(name,"");
-	strcpy(picpath,MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
-	if(number==0)return 0;
-	if(strlen(number)==0)return 0;
-	
+  strcpy (name, "");
+  strcpy (picpath, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+  if (number == 0)
+    return 0;
+  if (strlen (number) == 0)
+    return 0;
+
 //  DIALER_CONTACT* contacts=g_contactlist.contacts;
 
-DIALER_CONTACT_ENTRY* entry;
- 
-   while(contacts!= 0)
-   {
-     entry=contacts->entry;
+  DIALER_CONTACT_ENTRY *entry;
 
-	 while(entry)
-	 {
-	
-	 //judge if the entry includes the string
-		 
-	 if(strcmp(entry->content,number)==0)
-	 {	
-	 strcpy(picpath,contacts->picpath);
-     strcpy(name,contacts->name);
-	// DBG_MESSAGE("Yeah, we know the owner is %s.",name);
-	 
-	 return 1;
-	 }
-     entry=entry->next;
-	 }
-    
-	 
-	 contacts= contacts->next;
-	
+  while (contacts != 0)
+  {
+    entry = contacts->entry;
+
+    while (entry)
+    {
+
+      //judge if the entry includes the string
+
+      if (strcmp (entry->content, number) == 0)
+      {
+        strcpy (picpath, contacts->picpath);
+        strcpy (name, contacts->name);
+        // DBG_MESSAGE("Yeah, we know the owner is %s.",name);
+
+        return 1;
+      }
+      entry = entry->next;
+    }
+
+
+    contacts = contacts->next;
+
   }
   //DBG_MESSAGE("Can not find the number.");
   return 0;
@@ -374,44 +401,48 @@
  * @retval 
  */
 
-int contact_get_peer_info_from_number(DIALER_CONTACT* contacts, DIALER_CONTACT_PEER_INFO * peer)
+int
+contact_get_peer_info_from_number (DIALER_CONTACT * contacts,
+                                   DIALER_CONTACT_PEER_INFO * peer)
 {
 
-	peer->hasname=0;
-	peer->searched=1;
-	peer->name=0;
-	peer->picpath=0;
+  peer->hasname = 0;
+  peer->searched = 1;
+  peer->name = 0;
+  peer->picpath = 0;
 
-	if(peer->number==0)return 0;
-	if(strlen(peer->number)==0)return 0;
-	
+  if (peer->number == 0)
+    return 0;
+  if (strlen (peer->number) == 0)
+    return 0;
+
 //  DIALER_CONTACT* contacts=g_contactlist.contacts;
 
-	DIALER_CONTACT_ENTRY* entry;
- 
-   while(contacts!= 0)
-   {
-     entry=contacts->entry;
+  DIALER_CONTACT_ENTRY *entry;
 
-	 while(entry)
-	 {
-	
-	 //judge if the entry includes the string
-		 
-	 if(strcmp(entry->content,peer->number)==0)
-	 {	
-	 peer->picpath=contacts->picpath;
-	 peer->name=contacts->name;
-	// DBG_MESSAGE("Yeah, we know the owner is %s.",name);
- 	peer->hasname=1;
-	 return 1;
-	 }
-     entry=entry->next;
-	 }
-    
-	 
-	 contacts= contacts->next;
-	
+  while (contacts != 0)
+  {
+    entry = contacts->entry;
+
+    while (entry)
+    {
+
+      //judge if the entry includes the string
+
+      if (strcmp (entry->content, peer->number) == 0)
+      {
+        peer->picpath = contacts->picpath;
+        peer->name = contacts->name;
+        // DBG_MESSAGE("Yeah, we know the owner is %s.",name);
+        peer->hasname = 1;
+        return 1;
+      }
+      entry = entry->next;
+    }
+
+
+    contacts = contacts->next;
+
   }
   //DBG_MESSAGE("Can not find the number.");
   return 0;
@@ -428,52 +459,55 @@
  * @return 0-no 1-yes
  */
 
-int contact_string_has_sensentive (char * content, char *string)
+int
+contact_string_has_sensentive (char *content, char *string)
 {
-	int i;
-//	g_printf("hassensentive:%s,%s\n",content,string);
-	if(content==0) 
-	return 0;
-	
-	if(string==0) 
-	return 1;
-	
-	if(strlen(string)==0)
-		return 1;
-	if(strlen(string)>strlen(content))
-		return 0;
-	for(i=0;string[i];i++)
-	{
-		if(content[i]==0)
-			return 1;
-		if(string[i]==content[i])
-			continue;
-		return 0;
-		
-	}
-	return 1;
+  int i;
+//      g_printf("hassensentive:%s,%s\n",content,string);
+  if (content == 0)
+    return 0;
+
+  if (string == 0)
+    return 1;
+
+  if (strlen (string) == 0)
+    return 1;
+  if (strlen (string) > strlen (content))
+    return 0;
+  for (i = 0; string[i]; i++)
+  {
+    if (content[i] == 0)
+      return 1;
+    if (string[i] == content[i])
+      continue;
+    return 0;
+
+  }
+  return 1;
 }
-int contact_print_contact_list(DIALER_CONTACTS_LIST_HEAD * head)
+
+int
+contact_print_contact_list (DIALER_CONTACTS_LIST_HEAD * head)
 {
-DIALER_CONTACT* contacts;
-DIALER_CONTACT_ENTRY* entry;
- contacts=head->contacts;
+  DIALER_CONTACT *contacts;
+  DIALER_CONTACT_ENTRY *entry;
+  contacts = head->contacts;
 
-DBG_MESSAGE("\n\nThere are %d contacts here:",head->length);
+  DBG_MESSAGE ("\n\nThere are %d contacts here:", head->length);
 
-   while(contacts!= 0)
-   {
-   DBG_MESSAGE("%s",contacts->name);
-     entry=contacts->entry;
+  while (contacts != 0)
+  {
+    DBG_MESSAGE ("%s", contacts->name);
+    entry = contacts->entry;
 
-	 while(entry)
-	 {
-	
-	 DBG_MESSAGE("--%s:%s",entry->desc,entry->content);
-        entry=entry->next;
-	 }
+    while (entry)
+    {
 
-      contacts= contacts->next;
+      DBG_MESSAGE ("--%s:%s", entry->desc, entry->content);
+      entry = entry->next;
+    }
+
+    contacts = contacts->next;
   }
   return 0;
 

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -21,8 +21,8 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
- 
+
+
 #ifndef _CONTACTS_H
 #define _CONTACTS_H
 
@@ -35,75 +35,80 @@
 
 
 
-	
+
 /**
  * @brief phone number entry for the contact  structure in open dialer.
  */
-typedef struct dialer_contact_entry {
-  int ID;///<the unique ID for an contact entry
-  char *desc; ///<the description of this entry,such as homenumber
-  char *content; ///<the content of this entry, such as 62495726
-  struct dialer_contact_entry* next;
-}DIALER_CONTACT_ENTRY;
+  typedef struct dialer_contact_entry
+  {
+    int ID;                     ///<the unique ID for an contact entry
+    char *desc;                 ///<the description of this entry,such as homenumber
+    char *content;              ///<the content of this entry, such as 62495726
+    struct dialer_contact_entry *next;
+  } DIALER_CONTACT_ENTRY;
 
 
 /**
  * @brief contact  structure for open dialer.
  */
-typedef struct dialer_contact {
-  int ID;///<the unique ID for an contact entry
-  char *name;       	///<person name
-  char *picpath;  ///<the picture file path for the person
-  DIALER_CONTACT_ENTRY * entry;                    ///<first number entry for the person
-  
-  struct dialer_contact* next;         ///<pointer to next contact
-}DIALER_CONTACT;
+  typedef struct dialer_contact
+  {
+    int ID;                     ///<the unique ID for an contact entry
+    char *name;                 ///<person name
+    char *picpath;              ///<the picture file path for the person
+    DIALER_CONTACT_ENTRY *entry;        ///<first number entry for the person
 
+    struct dialer_contact *next;        ///<pointer to next contact
+  } DIALER_CONTACT;
 
+
 /**
  * @brief contact  structure for open dialer.
  */
-typedef struct peer_info_
-{
+  typedef struct peer_info_
+  {
 //we should at least have the number called.
-  char number[MOKO_DIALER_MAX_NUMBER_LEN+1];        ///<the number of the peer
-  char *name;       	///<person name
-  char *picpath;  ///<the picture file path for the person
-  int searched; ///<if true; no need to search for the name 
-  int hasname; ///<if true, we the picpath & name can be used.
-}DIALER_CONTACT_PEER_INFO;
+    char number[MOKO_DIALER_MAX_NUMBER_LEN + 1];        ///<the number of the peer
+    char *name;                 ///<person name
+    char *picpath;              ///<the picture file path for the person
+    int searched;               ///<if true; no need to search for the name 
+    int hasname;                ///<if true, we the picpath & name can be used.
+  } DIALER_CONTACT_PEER_INFO;
 
 
 /**
  * @brief the structure for intelligent search results.
- */	
-typedef struct dialer_ready_contact
-{
-	DIALER_CONTACT_ENTRY* p_entry;
-	DIALER_CONTACT* p_contact;
-}DIALER_READY_CONTACT;
+ */
+  typedef struct dialer_ready_contact
+  {
+    DIALER_CONTACT_ENTRY *p_entry;
+    DIALER_CONTACT *p_contact;
+  } DIALER_READY_CONTACT;
 
 /**
  * @brief contacts list head structure.
  */
-typedef struct dialer_contacts_list_head {
-  int length;                   ///<the number of contacts
-  DIALER_CONTACT *contacts;        ///<package list head pointer
-}DIALER_CONTACTS_LIST_HEAD;
+  typedef struct dialer_contacts_list_head
+  {
+    int length;                 ///<the number of contacts
+    DIALER_CONTACT *contacts;   ///<package list head pointer
+  } DIALER_CONTACTS_LIST_HEAD;
 
 
-int contact_init_contact_list(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_release_contact_entry(DIALER_CONTACT_ENTRY* contactentry);
-int contact_release_contact(DIALER_CONTACT *contact);
-int contact_release_contact_list(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_init_from_cmd(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number);
-int contact_get_peer_info_from_number(DIALER_CONTACT* contacts, DIALER_CONTACT_PEER_INFO * peer);
-int contact_init_contact_data(DIALER_CONTACTS_LIST_HEAD   *p_contactlist);
-int contact_print_contact_list(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_string_has_sensentive (char * content, char *string);
+  int contact_init_contact_list (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_release_contact_entry (DIALER_CONTACT_ENTRY * contactentry);
+  int contact_release_contact (DIALER_CONTACT * contact);
+  int contact_release_contact_list (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_init_from_cmd (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_get_info_from_number (DIALER_CONTACT * contacts, char *name,
+                                    char *picpath, const char *number);
+  int contact_get_peer_info_from_number (DIALER_CONTACT * contacts,
+                                         DIALER_CONTACT_PEER_INFO * peer);
+  int contact_init_contact_data (DIALER_CONTACTS_LIST_HEAD * p_contactlist);
+  int contact_print_contact_list (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_string_has_sensentive (char *content, char *string);
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _CONTACTS_H */
+#endif                          /* _CONTACTS_H */

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -30,7 +30,7 @@
 
 //pthread_t thread;///<the gsm_monitor_thread thread handler
 
-static struct lgsm_handle *lgsmh; ///< the handle of the libgsmd
+static struct lgsm_handle *lgsmh;       ///< the handle of the libgsmd
 
 static GPollFD GPfd;
 
@@ -46,40 +46,40 @@
  */
  /*
 
-void *gsm_monitor_thread(struct lgsm_handle *lgsmh)
-{
-	int rc;
-	char buf[STDIN_BUF_SIZE+1];
-	//char rbuf[STDIN_BUF_SIZE+1];
-	//int rlen = sizeof(rbuf);
-	fd_set readset;
-//	lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
+    void *gsm_monitor_thread(struct lgsm_handle *lgsmh)
+    {
+    int rc;
+    char buf[STDIN_BUF_SIZE+1];
+    //char rbuf[STDIN_BUF_SIZE+1];
+    //int rlen = sizeof(rbuf);
+    fd_set readset;
+    //  lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
 
-	FD_ZERO(&readset);
+    FD_ZERO(&readset);
 
-	while (1) {
-		int gsm_fd = lgsm_fd(lgsmh);
-//		FD_SET(0, &readset);
-		FD_SET(gsm_fd, &readset);
+    while (1) {
+    int gsm_fd = lgsm_fd(lgsmh);
+    //          FD_SET(0, &readset);
+    FD_SET(gsm_fd, &readset);
 
-		rc = select(gsm_fd+1, &readset, NULL, NULL, NULL);
-		if (rc <= 0)	
-			break;
-		/ we've received something on the gsmd socket, pass it on to the library 
-			rc = read(gsm_fd, buf, sizeof(buf));
-			if (rc <= 0) {
-				printf("ERROR reding from gsm_fd\n");
-				break;
-			}
-			rc = lgsm_handle_packet(lgsmh, buf, rc);
-	}
-	
-	
-		printf("you know what? i quit!");
-        pthread_exit(NULL);
-}
+    rc = select(gsm_fd+1, &readset, NULL, NULL, NULL);
+    if (rc <= 0)        
+    break;
+    / we've received something on the gsmd socket, pass it on to the library 
+    rc = read(gsm_fd, buf, sizeof(buf));
+    if (rc <= 0) {
+    printf("ERROR reding from gsm_fd\n");
+    break;
+    }
+    rc = lgsm_handle_packet(lgsmh, buf, rc);
+    }
 
-*/
+
+    printf("you know what? i quit!");
+    pthread_exit(NULL);
+    }
+
+  */
 /**
  * @brief create the thread to monitor events from libgsmd
  *
@@ -91,22 +91,22 @@
  * @retval 0  success
  */
  /*
-int gsm_start_loop()
-{
-        
-        //pthread_mutex_init(&mut,NULL);
-	    memset(&thread, 0, sizeof(thread));          //comment1
-        
-        if(pthread_create(&thread, NULL, gsm_monitor_thread, lgsmh) != 0)       //comment2
-		{  printf("failed to create libgsmd monitor thread\n");
-			return -1;
-		}
-        
-        return 0;
-}
+    int gsm_start_loop()
+    {
 
-*/
+    //pthread_mutex_init(&mut,NULL);
+    memset(&thread, 0, sizeof(thread));          //comment1
 
+    if(pthread_create(&thread, NULL, gsm_monitor_thread, lgsmh) != 0)       //comment2
+    {  printf("failed to create libgsmd monitor thread\n");
+    return -1;
+    }
+
+    return 0;
+    }
+
+  */
+
 /**
  * @brief this is the handler for receiving passthrough responses 
  *
@@ -119,11 +119,12 @@
  * @retval 0  success
  */
 
-static int pt_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
+static int
+pt_msghandler (struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
 {
-	char *payload = (char *)gmh + sizeof(*gmh);
-	printf("RSTR=`%s'\n", payload);
-	return 0;
+  char *payload = (char *) gmh + sizeof (*gmh);
+  printf ("RSTR=`%s'\n", payload);
+  return 0;
 }
 
 
@@ -133,25 +134,27 @@
  * @retval 1 failed, and the whole app will exit too.
  * @retval 0  success
  */
-	
-int gsm_lgsm_start(GMainLoop* mainloop)
+
+int
+gsm_lgsm_start (GMainLoop * mainloop)
 {
 
-	char *pin = NULL;
-	lgsmh = lgsm_init(LGSMD_DEVICE_GSMD);
-	if (!lgsmh) {
-		fprintf(stderr, "Can't connect to gsmd\n");
-		exit(1);
-		}
-	pin_init(lgsmh, pin);
-	event_init(lgsmh);
-	lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
-	lgsm_netreg_register(lgsmh, 0);
-	
-	gsm_watcher_install(mainloop);
-	//gsm_start_loop();
-	return 0;
+  char *pin = NULL;
+  lgsmh = lgsm_init (LGSMD_DEVICE_GSMD);
+  if (!lgsmh)
+  {
+    fprintf (stderr, "Can't connect to gsmd\n");
+    exit (1);
+  }
+  pin_init (lgsmh, pin);
+  event_init (lgsmh);
+  lgsm_register_handler (lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
+  lgsm_netreg_register (lgsmh, 0);
 
+  gsm_watcher_install (mainloop);
+  //gsm_start_loop();
+  return 0;
+
 }
 
 
@@ -162,14 +165,15 @@
  * @retval 0  success 
  * @retval other failed
  */
-int gsm_dial(const char * number)
+int
+gsm_dial (const char *number)
 {
-				struct lgsm_addr addr;
-				addr.type = 129;
-				strncpy(addr.addr, number, strlen(number));
-				addr.addr[strlen(number)] = '\0';
-				return lgsm_voice_out_init(lgsmh, &addr);
-				
+  struct lgsm_addr addr;
+  addr.type = 129;
+  strncpy (addr.addr, number, strlen (number));
+  addr.addr[strlen (number)] = '\0';
+  return lgsm_voice_out_init (lgsmh, &addr);
+
 }
 
 /**
@@ -177,10 +181,11 @@
  * @retval 0  success 
  * @retval other failed
  */
-int gsm_answer()
+int
+gsm_answer ()
 {
-	return lgsm_voice_in_accept(lgsmh);
-	
+  return lgsm_voice_in_accept (lgsmh);
+
 }
 
 /**
@@ -188,93 +193,96 @@
  * @retval 0  success 
  * @retval other failed
  */
-int gsm_hangup()
+int
+gsm_hangup ()
 {
-	
-return lgsm_voice_hangup(lgsmh);
-	
+
+  return lgsm_voice_hangup (lgsmh);
+
 }
 
 
 static gboolean
-gsm_watcher_prepare (GSource * source,
-		       gint * timeout)
+gsm_watcher_prepare (GSource * source, gint * timeout)
 {
-	//DBG_ENTER();
-	*timeout = -1;
+  //DBG_ENTER();
+  *timeout = -1;
 
-	return FALSE;
+  return FALSE;
 }
-static gboolean gsm_watcher_check (GSource * source)
+static gboolean
+gsm_watcher_check (GSource * source)
 {
 
-	//DBG_ENTER();
-	//|G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI;
-	if(GPfd.revents&(G_IO_IN|G_IO_PRI))
-	{	
+  //DBG_ENTER();
+  //|G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI;
+  if (GPfd.revents & (G_IO_IN | G_IO_PRI))
+  {
 
-		//GPfd.revents=0;
-		return TRUE;
-	}
-	else
-	{
-		//DBG_MESSAGE("FALSE");
-		return FALSE;
-	}
-	
+    //GPfd.revents=0;
+    return TRUE;
+  }
+  else
+  {
+    //DBG_MESSAGE("FALSE");
+    return FALSE;
+  }
+
 }
 static gboolean
-gsm_watcher_dispatch (GSource     * source,
-                        GSourceFunc   callback,
-                        gpointer      user_data)
+gsm_watcher_dispatch (GSource * source,
+                      GSourceFunc callback, gpointer user_data)
 {
 
 
-	int rc;
-	char buf[STDIN_BUF_SIZE+1];
-	int gsm_fd = lgsm_fd(lgsmh);
-	/* we've received something on the gsmd socket, pass it
-			 * on to the library */
+  int rc;
+  char buf[STDIN_BUF_SIZE + 1];
+  int gsm_fd = lgsm_fd (lgsmh);
+  /* we've received something on the gsmd socket, pass it
+   * on to the library */
 
-	rc = read(gsm_fd, buf, sizeof(buf));
-			if (rc <= 0) {
-				DBG_MESSAGE("ERROR reding from gsm_fd");
-				return FALSE;
-			}
-			else
-			{
-				rc = lgsm_handle_packet(lgsmh, buf, rc);
-			}
-	return TRUE;
+  rc = read (gsm_fd, buf, sizeof (buf));
+  if (rc <= 0)
+  {
+    DBG_MESSAGE ("ERROR reding from gsm_fd");
+    return FALSE;
+  }
+  else
+  {
+    rc = lgsm_handle_packet (lgsmh, buf, rc);
+  }
+  return TRUE;
 }
-void gsm_watcher_install (GMainLoop* mainloop)
+
+void
+gsm_watcher_install (GMainLoop * mainloop)
 {
-	DBG_ENTER();
-	static GSourceFuncs gsm_watcher_funcs = {
-		gsm_watcher_prepare,
-		gsm_watcher_check,
-		gsm_watcher_dispatch,
-		NULL
-	};
-	/* FIXME: we never unref the watcher. */
-	GSource * gsm_watcher =
-		g_source_new (&gsm_watcher_funcs, sizeof (GSource));
-	GPfd.fd=lgsm_fd(lgsmh);
-	GPfd.events=G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI;
-	GPfd.revents=0;
-	
-	g_source_add_poll(gsm_watcher,&GPfd);
+  DBG_ENTER ();
+  static GSourceFuncs gsm_watcher_funcs = {
+    gsm_watcher_prepare,
+    gsm_watcher_check,
+    gsm_watcher_dispatch,
+    NULL
+  };
+  /* FIXME: we never unref the watcher. */
+  GSource *gsm_watcher = g_source_new (&gsm_watcher_funcs, sizeof (GSource));
+  GPfd.fd = lgsm_fd (lgsmh);
+  GPfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI;
+  GPfd.revents = 0;
 
-	DBG_MESSAGE("ATACH");
-	g_source_attach(gsm_watcher,NULL);
-	DBG_MESSAGE("ATACH OUT");
-	DBG_LEAVE();
-	return;
+  g_source_add_poll (gsm_watcher, &GPfd);
 
+  DBG_MESSAGE ("ATACH");
+  g_source_attach (gsm_watcher, NULL);
+  DBG_MESSAGE ("ATACH OUT");
+  DBG_LEAVE ();
+  return;
+
 }
 
-void gsm_dtmf_send(char dtmf)
+void
+gsm_dtmf_send (char dtmf)
 {
-	DBG_MESSAGE("lgsm_voice_dtmf");
-	lgsm_voice_dtmf(lgsmh, dtmf);
+  DBG_MESSAGE ("lgsm_voice_dtmf");
+  lgsm_voice_dtmf (lgsmh, dtmf);
 }

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -46,9 +46,9 @@
 	
 int pin_init(struct lgsm_handle *lh, const char *pin_preset);
 */
-	
+
 //#include "lgsm_internals.h"
-	
+
 //#include "dialer.h"
 
 #define STDIN_BUF_SIZE	1024
@@ -62,33 +62,33 @@
  * @retval -1 failed
  * @retval 0  success
  */
-int gsm_start_loop();
+  int gsm_start_loop ();
 /**
  * @brief take care the early initialization of libgsmd,this must be called before any physical phone operations such as dialing out.
  * @retval 1 failed, and the whole app will exit too.
  * @retval 0  success
  */
-int gsm_lgsm_start(GMainLoop* mainloop);
+  int gsm_lgsm_start (GMainLoop * mainloop);
 /**
  * @brief hangup an outgoing call or incoming call or talking call
  * @retval 0  success 
  * @retval other failed
  */
-int gsm_hangup();
+  int gsm_hangup ();
 
 /**
  * @brief accept an incoming call
  * @retval 0  success 
  * @retval other failed
  */
-int gsm_answer();
+  int gsm_answer ();
 /**
  * @brief calls a number out
  * @param number the number to be called
  * @retval 0  success 
  * @retval other failed
  */
-int gsm_dial(const char * number);
+  int gsm_dial (const char *number);
 /**
  * @brief monitor the connection with libgsmd, dispatch the event handler when needed.
  *
@@ -99,13 +99,13 @@
  * @retval
  */
 
-void *gsm_monitor_thread(struct lgsm_handle *lgsmh);
+  void *gsm_monitor_thread (struct lgsm_handle *lgsmh);
 
 
-void gsm_watcher_install (GMainLoop* mainloop);
+  void gsm_watcher_install (GMainLoop * mainloop);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _DIALERGSM_H */
+#endif                          /* _DIALERGSM_H */

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -21,7 +21,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
 #ifndef _ERROR_H
 #define _ERROR_H
 
@@ -31,18 +31,18 @@
 #endif
 
 #ifndef  _FIC_DEBUG
-	#define _FIC_DEBUG 1
+#define _FIC_DEBUG 1
 #endif
 
-	#define DBG_ERROR_ON 1
-	#define DBG_WARNING_ON 1
-	#define DBG_FUN_ENTER_ON 1
-	#define DBG_FUN_LEAVE_ON 1
-	#define DBG_MESSAGE_ON 1
-	#define DBG_TRACE_ON 1
-	
-	
-	
+#define DBG_ERROR_ON 1
+#define DBG_WARNING_ON 1
+#define DBG_FUN_ENTER_ON 1
+#define DBG_FUN_LEAVE_ON 1
+#define DBG_MESSAGE_ON 1
+#define DBG_TRACE_ON 1
+
+
+
 #ifdef  _FIC_DEBUG
 /** @brief Define a debug message output */
 #define DBG_MESSAGE(x...)   {if(DBG_MESSAGE_ON) {g_print(x);g_print("\n");}}
@@ -76,4 +76,4 @@
 }
 #endif
 
-#endif /* _ERROR_H */
+#endif                          /* _ERROR_H */

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -4,218 +4,240 @@
 #include <libgsmd/libgsmd.h>
 #include <libgsmd/event.h>
 //#include "../include/dialer.h"
-static int IncomingSignaled; ///<to keep communication with GUI
-static int ClipSignaled;///<to keep communication with GUI
+static int IncomingSignaled;    ///<to keep communication with GUI
+static int ClipSignaled;        ///<to keep communication with GUI
 static int KeepCalling;
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif
 
-int event_get_incoming_signaled()
+int
+event_get_incoming_signaled ()
 {
-	return IncomingSignaled;
+  return IncomingSignaled;
 }
 
-int event_set_incoming_signaled()
+int
+event_set_incoming_signaled ()
 {
-	IncomingSignaled=1;
-	return IncomingSignaled;
+  IncomingSignaled = 1;
+  return IncomingSignaled;
 }
 
-int event_reset_incoming_signaled()
+int
+event_reset_incoming_signaled ()
 {
-	IncomingSignaled=0;
-	return 1;
+  IncomingSignaled = 0;
+  return 1;
 }
-int event_get_clip_signaled()
+
+int
+event_get_clip_signaled ()
 {
-	return ClipSignaled;
-	
+  return ClipSignaled;
+
 }
-int event_set_clip_signaled()
+
+int
+event_set_clip_signaled ()
 {
-	ClipSignaled=1;
-	return 1;
-	
+  ClipSignaled = 1;
+  return 1;
+
 }
-int event_reset_clip_signaled()
+
+int
+event_reset_clip_signaled ()
 {
-	ClipSignaled=0;
-	return 1;
-	
+  ClipSignaled = 0;
+  return 1;
+
 }
-int event_get_keep_calling()
+
+int
+event_get_keep_calling ()
 {
-	return KeepCalling;
+  return KeepCalling;
 }
-int event_set_keep_calling()
+
+int
+event_set_keep_calling ()
 {
-	KeepCalling=1;
-	return 1;
+  KeepCalling = 1;
+  return 1;
 }
-int event_reset_keep_calling()
+
+int
+event_reset_keep_calling ()
 {
-	KeepCalling=0;
-	return 1;
+  KeepCalling = 0;
+  return 1;
 }
 
-static int incall_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+incall_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	printf("EVENT: Incoming call type = %u\n", aux->u.call.type);
-	
-	if(event_get_incoming_signaled())
-	{
-		printf("already signaled, just set keep_calling");
-		event_set_keep_calling();
-	}
-	else
-	{
-		printf("set incoming signaled");
-		event_set_incoming_signaled();
-		//PhoneIncoming(0);	
-	}
-	return 0;
+  printf ("EVENT: Incoming call type = %u\n", aux->u.call.type);
+
+  if (event_get_incoming_signaled ())
+  {
+    printf ("already signaled, just set keep_calling");
+    event_set_keep_calling ();
+  }
+  else
+  {
+    printf ("set incoming signaled");
+    event_set_incoming_signaled ();
+    //PhoneIncoming(0);     
+  }
+  return 0;
 }
 
 
-static int clip_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+clip_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	printf("EVENT: Incoming call clip = %s\n", aux->u.clip.addr.number);
-	if(event_get_clip_signaled())
-	{
-		printf("already signaled, just set keep_calling");
-		event_set_keep_calling();
-	}
-	else
-	{
-		event_set_clip_signaled();
-		printf("set clip signaled and call phoneincoming");
-		gdk_threads_enter();
-		//here!
-		gsm_incoming_call(aux->u.clip.addr.number);
-//		PhoneIncomingClip(aux->u.clip.addr.number);
-		gdk_threads_leave();
-	}
-	return 0;
+  printf ("EVENT: Incoming call clip = %s\n", aux->u.clip.addr.number);
+  if (event_get_clip_signaled ())
+  {
+    printf ("already signaled, just set keep_calling");
+    event_set_keep_calling ();
+  }
+  else
+  {
+    event_set_clip_signaled ();
+    printf ("set clip signaled and call phoneincoming");
+    gdk_threads_enter ();
+    //here!
+    gsm_incoming_call (aux->u.clip.addr.number);
+//              PhoneIncomingClip(aux->u.clip.addr.number);
+    gdk_threads_leave ();
+  }
+  return 0;
 }
 
-static int netreg_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+netreg_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	printf("EVENT: Netreg ");
+  printf ("EVENT: Netreg ");
 
-	switch (aux->u.netreg.state) {
-	case 0:
-		printf("not searching for network ");
-		break;
-	case 1:
-		printf("registered (home network) ");
-		break;
-	case 2:
-		printf("searching for network ");
-		break;
-	case 3:
-		printf("registration denied ");
-		break;
-	case 5:
-		printf("registered (roaming) ");
-		break;
-	}
+  switch (aux->u.netreg.state)
+  {
+    case 0:
+      printf ("not searching for network ");
+      break;
+    case 1:
+      printf ("registered (home network) ");
+      break;
+    case 2:
+      printf ("searching for network ");
+      break;
+    case 3:
+      printf ("registration denied ");
+      break;
+    case 5:
+      printf ("registered (roaming) ");
+      break;
+  }
 
-	if (aux->u.netreg.lac)
-		printf("LocationAreaCode = 0x%04X ", aux->u.netreg.lac);
-	if (aux->u.netreg.ci)
-		printf("CellID = 0x%04X ", aux->u.netreg.ci);
-	
-	printf("\n");
+  if (aux->u.netreg.lac)
+    printf ("LocationAreaCode = 0x%04X ", aux->u.netreg.lac);
+  if (aux->u.netreg.ci)
+    printf ("CellID = 0x%04X ", aux->u.netreg.ci);
 
-	return 0;
+  printf ("\n");
+
+  return 0;
 }
 
-static int sigq_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+sigq_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	printf("EVENT: Signal Quality: %u\n", aux->u.signal.sigq.rssi);
-	return 0;
+  printf ("EVENT: Signal Quality: %u\n", aux->u.signal.sigq.rssi);
+  return 0;
 }
 static const char *cprog_names[] = {
-	[GSMD_CALLPROG_SETUP]		= "SETUP",
-	[GSMD_CALLPROG_DISCONNECT]	= "DISCONNECT",
-	[GSMD_CALLPROG_ALERT]		= "ALERT",
-	[GSMD_CALLPROG_CALL_PROCEED]	= "PROCEED",
-	[GSMD_CALLPROG_SYNC]		= "SYNC",
-	[GSMD_CALLPROG_PROGRESS]	= "PROGRESS",
-	[GSMD_CALLPROG_CONNECTED]	= "CONNECTED",
-	[GSMD_CALLPROG_RELEASE]		= "RELEASE",
-	[GSMD_CALLPROG_REJECT]		= "REJECT",
-	[GSMD_CALLPROG_UNKNOWN]		= "UNKNOWN",
+  [GSMD_CALLPROG_SETUP] = "SETUP",
+  [GSMD_CALLPROG_DISCONNECT] = "DISCONNECT",
+  [GSMD_CALLPROG_ALERT] = "ALERT",
+  [GSMD_CALLPROG_CALL_PROCEED] = "PROCEED",
+  [GSMD_CALLPROG_SYNC] = "SYNC",
+  [GSMD_CALLPROG_PROGRESS] = "PROGRESS",
+  [GSMD_CALLPROG_CONNECTED] = "CONNECTED",
+  [GSMD_CALLPROG_RELEASE] = "RELEASE",
+  [GSMD_CALLPROG_REJECT] = "REJECT",
+  [GSMD_CALLPROG_UNKNOWN] = "UNKNOWN",
 };
 
 static const char *cdir_names[] = {
-	[GSMD_CALL_DIR_MO]		= "Outgoing",
-	[GSMD_CALL_DIR_MT]		= "Incoming",
-	[GSMD_CALL_DIR_CCBS]		= "CCBS",
-	[GSMD_CALL_DIR_MO_REDIAL]	= "Outgoing Redial",
+  [GSMD_CALL_DIR_MO] = "Outgoing",
+  [GSMD_CALL_DIR_MT] = "Incoming",
+  [GSMD_CALL_DIR_CCBS] = "CCBS",
+  [GSMD_CALL_DIR_MO_REDIAL] = "Outgoing Redial",
 };
 
-static int cprog_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+cprog_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	const char *name, *dir;
+  const char *name, *dir;
 
-	if (aux->u.call_status.prog >= ARRAY_SIZE(cprog_names))
-		name = "UNDEFINED";
-	else
-		name = cprog_names[aux->u.call_status.prog];
+  if (aux->u.call_status.prog >= ARRAY_SIZE (cprog_names))
+    name = "UNDEFINED";
+  else
+    name = cprog_names[aux->u.call_status.prog];
 
-	if (aux->u.call_status.dir >= ARRAY_SIZE(cdir_names))
-		dir = "";
-	else
-		dir = cdir_names[aux->u.call_status.dir];
+  if (aux->u.call_status.dir >= ARRAY_SIZE (cdir_names))
+    dir = "";
+  else
+    dir = cdir_names[aux->u.call_status.dir];
 
-	printf("EVENT: %s Call Progress: %s\n", dir, name);
+  printf ("EVENT: %s Call Progress: %s\n", dir, name);
 
-	if(aux->u.call_status.prog==GSMD_CALLPROG_CONNECTED)
-		{
-		
-		if(aux->u.call_status.dir==GSMD_CALL_DIR_MO)
-			gsm_peer_accept();
-		}
+  if (aux->u.call_status.prog == GSMD_CALLPROG_CONNECTED)
+  {
 
-	if(aux->u.call_status.prog==GSMD_CALLPROG_REJECT)
-		{
-		if(aux->u.call_status.dir==GSMD_CALL_DIR_MO)
-			gsm_peer_refuse();
-		}
+    if (aux->u.call_status.dir == GSMD_CALL_DIR_MO)
+      gsm_peer_accept ();
+  }
 
-	if(aux->u.call_status.prog==GSMD_CALLPROG_DISCONNECT)
-		{
-		if(aux->u.call_status.dir==GSMD_CALL_DIR_MO)
-					gsm_peer_disconnect();
+  if (aux->u.call_status.prog == GSMD_CALLPROG_REJECT)
+  {
+    if (aux->u.call_status.dir == GSMD_CALL_DIR_MO)
+      gsm_peer_refuse ();
+  }
 
-		}
+  if (aux->u.call_status.prog == GSMD_CALLPROG_DISCONNECT)
+  {
+    if (aux->u.call_status.dir == GSMD_CALL_DIR_MO)
+      gsm_peer_disconnect ();
 
+  }
 
-	return 0;
+
+  return 0;
 }
 
-static int colp_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+colp_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	printf("EVENT: Outgoing call colp = %s\n", aux->u.colp.addr.number);
+  printf ("EVENT: Outgoing call colp = %s\n", aux->u.colp.addr.number);
 
-	return 0;
+  return 0;
 }
 
 
-int event_init(struct lgsm_handle *lh)
+int
+event_init (struct lgsm_handle *lh)
 {
-	int rc;
+  int rc;
 
-	rc  = lgsm_evt_handler_register(lh, GSMD_EVT_IN_CALL, &incall_handler);
-	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_IN_CLIP, &clip_handler);
-	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_OUT_COLP, &colp_handler);
-	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_NETREG, &netreg_handler);
-	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_SIGNAL, &sigq_handler);
-	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_OUT_STATUS, &cprog_handler);
+  rc = lgsm_evt_handler_register (lh, GSMD_EVT_IN_CALL, &incall_handler);
+  rc |= lgsm_evt_handler_register (lh, GSMD_EVT_IN_CLIP, &clip_handler);
+  rc |= lgsm_evt_handler_register (lh, GSMD_EVT_OUT_COLP, &colp_handler);
+  rc |= lgsm_evt_handler_register (lh, GSMD_EVT_NETREG, &netreg_handler);
+  rc |= lgsm_evt_handler_register (lh, GSMD_EVT_SIGNAL, &sigq_handler);
+  rc |= lgsm_evt_handler_register (lh, GSMD_EVT_OUT_STATUS, &cprog_handler);
 
-	return rc;
+  return rc;
 }
-

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,14 +1,14 @@
 
-extern int event_init(struct lgsm_handle *lh);
-extern int event_get_incoming_signaled();
+extern int event_init (struct lgsm_handle *lh);
+extern int event_get_incoming_signaled ();
 
-extern int event_set_incoming_signaled();
+extern int event_set_incoming_signaled ();
 
-extern int event_reset_incoming_signaled();
-extern int event_get_clip_signaled();
-extern int event_set_clip_signaled();
-extern int event_reset_clip_signaled();
+extern int event_reset_incoming_signaled ();
+extern int event_get_clip_signaled ();
+extern int event_set_clip_signaled ();
+extern int event_reset_clip_signaled ();
 
-extern int event_get_keep_calling();
-extern int event_set_keep_calling();
-extern int event_reset_keep_calling();
+extern int event_get_keep_calling ();
+extern int event_set_keep_calling ();
+extern int event_reset_keep_calling ();

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -21,9 +21,9 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
-#include "history.h" 
-#include "error.h" 
+
+#include "history.h"
+#include "error.h"
 #include <stdlib.h>
 /**
  * @brief initialze the contact list by calling the external APIs.
@@ -34,9 +34,10 @@
  * @return the number of the contacts. 
  * @retval
  */
-int history_read_list(HISTORY_LIST_HEAD* historyhead)
+int
+history_read_list (HISTORY_LIST_HEAD * historyhead)
 {
-	return 0;
+  return 0;
 }
 
 
@@ -50,37 +51,39 @@
  * @retval 0 failed 
  * @retval other success
  */
-int history_read_list_cmd(HISTORY_LIST_HEAD* historyhead)
+int
+history_read_list_cmd (HISTORY_LIST_HEAD * historyhead)
 {
-	
-historyhead->length=0;
-historyhead->first=0;
-historyhead->last=0;
-	history_add_entry(historyhead,MISSED,"","1391721112",
-	"","17:58","12/20",100);
 
-	history_add_entry(historyhead,INCOMING,"tony","13917309523",
-	"./tony.png","13:58","12/20",10);
-history_add_entry(historyhead,OUTGOING,"sally","13361900551",
-	"./sally.png","10:58","12/20",106);
-history_add_entry(historyhead,MISSED,"chaowei","1391110923",
-	"./chaowei.png","11:58","12/20",120);
-	history_add_entry(historyhead,OUTGOING,"","1395721111",
-	"","17:58","12/20",100);
+  historyhead->length = 0;
+  historyhead->first = 0;
+  historyhead->last = 0;
+  history_add_entry (historyhead, MISSED, "", "1391721112",
+                     "", "17:58", "12/20", 100);
 
-	history_add_entry(historyhead,INCOMING,"steven","1391721111",
-	"./steven.png","17:58","12/20",100);
-history_add_entry(historyhead,INCOMING,"ken","1381720923",
-	"./ken.png","18:58","12/20",200);
-	history_add_entry(historyhead,MISSED,"","1391721113",
-	"","17:58","12/20",100);
-	history_add_entry(historyhead,MISSED,"","1394721111",
-	"","17:58","12/20",100);
-	history_add_entry(historyhead,MISSED,"","1396721111",
-	"","17:58","12/20",100);
-return historyhead->length;
+  history_add_entry (historyhead, INCOMING, "tony", "13917309523",
+                     "./tony.png", "13:58", "12/20", 10);
+  history_add_entry (historyhead, OUTGOING, "sally", "13361900551",
+                     "./sally.png", "10:58", "12/20", 106);
+  history_add_entry (historyhead, MISSED, "chaowei", "1391110923",
+                     "./chaowei.png", "11:58", "12/20", 120);
+  history_add_entry (historyhead, OUTGOING, "", "1395721111",
+                     "", "17:58", "12/20", 100);
 
+  history_add_entry (historyhead, INCOMING, "steven", "1391721111",
+                     "./steven.png", "17:58", "12/20", 100);
+  history_add_entry (historyhead, INCOMING, "ken", "1381720923",
+                     "./ken.png", "18:58", "12/20", 200);
+  history_add_entry (historyhead, MISSED, "", "1391721113",
+                     "", "17:58", "12/20", 100);
+  history_add_entry (historyhead, MISSED, "", "1394721111",
+                     "", "17:58", "12/20", 100);
+  history_add_entry (historyhead, MISSED, "", "1396721111",
+                     "", "17:58", "12/20", 100);
+  return historyhead->length;
+
 }
+
 /* 
 typedef struct historyentry
 {
@@ -106,37 +109,41 @@
  * @retval 0 failed
  * @retval 1 success
  */
-int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry)
+int
+history_delete_entry (HISTORY_LIST_HEAD * historyhead, HISTORY_ENTRY * entry)
 {
-	DBG_ENTER();
-	if(entry==0)return 0;
-	if(entry->number==0)return 0;
-	if(entry->prev==0&&entry->next==0)return 0;
-		
-	DBG_MESSAGE("deleting %s",entry->number);
-	
-	if(entry->prev)
-	{
-		entry->prev->next=entry->next;
-	}
-	else
-	{//entry is the first one.
-		historyhead->first=entry->next;
-	}
-	
-	if(entry->next)
-	{
-		entry->next->prev=entry->prev;
-	}
-	else
-	{
-		historyhead->last=entry->prev;
-	}
+  DBG_ENTER ();
+  if (entry == 0)
+    return 0;
+  if (entry->number == 0)
+    return 0;
+  if (entry->prev == 0 && entry->next == 0)
+    return 0;
 
-	history_release_entry(entry);
+  DBG_MESSAGE ("deleting %s", entry->number);
 
-	historyhead->length--;
-	return historyhead->length;
+  if (entry->prev)
+  {
+    entry->prev->next = entry->next;
+  }
+  else
+  {                             //entry is the first one.
+    historyhead->first = entry->next;
+  }
+
+  if (entry->next)
+  {
+    entry->next->prev = entry->prev;
+  }
+  else
+  {
+    historyhead->last = entry->prev;
+  }
+
+  history_release_entry (entry);
+
+  historyhead->length--;
+  return historyhead->length;
 }
 
 
@@ -155,110 +162,116 @@
  * @return 
  * @retval the newly created entry pointer
  */
-HISTORY_ENTRY * history_add_entry(HISTORY_LIST_HEAD* historyhead, HISTORY_TYPE type,
-const char *name,const char *number,const char *picpath,  char *time,char *date,int durationsec)
+HISTORY_ENTRY *
+history_add_entry (HISTORY_LIST_HEAD * historyhead, HISTORY_TYPE type,
+                   const char *name, const char *number, const char *picpath,
+                   char *time, char *date, int durationsec)
 {
 
-	DBG_ENTER();
-	HISTORY_ENTRY * pentry=(HISTORY_ENTRY *)calloc(1,sizeof(HISTORY_ENTRY ));
+  DBG_ENTER ();
+  HISTORY_ENTRY *pentry =
+    (HISTORY_ENTRY *) calloc (1, sizeof (HISTORY_ENTRY));
 
-//	DBG_MESSAGE("pentry add:0X%x",pentry);
-	
-	if(name&&strlen(name)>0)
-	{	pentry->name=(char*)calloc(1,strlen(name)+1);
-		strcpy(pentry->name,name);
-		pentry->hasname=1;
-	}
-	else
-		{
-		pentry->name=0;
-		pentry->hasname=0;
-		}
+//      DBG_MESSAGE("pentry add:0X%x",pentry);
 
-	if(number&&strlen(number)>0)
-	{
-		pentry->number=(char*)calloc(1,strlen(number)+1);
-		strcpy(pentry->number,number);
-	}
-	else
-		{
-		//release memory, and return;
-		history_release_entry(pentry);
-		return 0;
-		}
+  if (name && strlen (name) > 0)
+  {
+    pentry->name = (char *) calloc (1, strlen (name) + 1);
+    strcpy (pentry->name, name);
+    pentry->hasname = 1;
+  }
+  else
+  {
+    pentry->name = 0;
+    pentry->hasname = 0;
+  }
 
-	//DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec);
-	
-	if(picpath&&strlen(picpath)>0)
-	{
-		pentry->picpath=(char*)calloc(1,strlen(picpath)+1);
-		strcpy(pentry->picpath,picpath);
-	}
-		if(time&&strlen(time)>0)
-	{
-		pentry->time=(char*)calloc(1,strlen(time)+1);
-		strcpy(pentry->time,time);
-	}
-		pentry->durationsec=durationsec;
-	
-	pentry->type=type;
-	historyhead->length++;
-	pentry->ID=historyhead->length;
-	
-	if(historyhead->first)
-	{	//DBG_TRACE();
-		//DBG_MESSAGE("first=0x%x",historyhead->first);
-		//DBG_MESSAGE("first=%s",historyhead->first->number);
-		historyhead->first->prev=pentry;
-		//DBG_TRACE();
-		pentry->next=historyhead->first;
-		//DBG_TRACE();
-		historyhead->first=pentry;
-		//DBG_TRACE();
-	}
-	else
-	{//DBG_TRACE();
-		historyhead->first=pentry;
-		historyhead->last=pentry;
-	}
-//	DBG_LEAVE();
-	return pentry;
+  if (number && strlen (number) > 0)
+  {
+    pentry->number = (char *) calloc (1, strlen (number) + 1);
+    strcpy (pentry->number, number);
+  }
+  else
+  {
+    //release memory, and return;
+    history_release_entry (pentry);
+    return 0;
+  }
+
+  //DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec);
+
+  if (picpath && strlen (picpath) > 0)
+  {
+    pentry->picpath = (char *) calloc (1, strlen (picpath) + 1);
+    strcpy (pentry->picpath, picpath);
+  }
+  if (time && strlen (time) > 0)
+  {
+    pentry->time = (char *) calloc (1, strlen (time) + 1);
+    strcpy (pentry->time, time);
+  }
+  pentry->durationsec = durationsec;
+
+  pentry->type = type;
+  historyhead->length++;
+  pentry->ID = historyhead->length;
+
+  if (historyhead->first)
+  {                             //DBG_TRACE();
+    //DBG_MESSAGE("first=0x%x",historyhead->first);
+    //DBG_MESSAGE("first=%s",historyhead->first->number);
+    historyhead->first->prev = pentry;
+    //DBG_TRACE();
+    pentry->next = historyhead->first;
+    //DBG_TRACE();
+    historyhead->first = pentry;
+    //DBG_TRACE();
+  }
+  else
+  {                             //DBG_TRACE();
+    historyhead->first = pentry;
+    historyhead->last = pentry;
+  }
+//      DBG_LEAVE();
+  return pentry;
 }
 
-int history_release_entry(HISTORY_ENTRY * pentry)
+int
+history_release_entry (HISTORY_ENTRY * pentry)
 {
-if(!pentry)return 1;
-if(pentry->name)
-{
-free(pentry->name);
-pentry->name=0;
-}
-if(pentry->number)
-{
-free(pentry->number);
-pentry->number=0;
-}
-if(pentry->picpath)
-{
-free(pentry->picpath);
-pentry->picpath=0;
-}
-if(pentry->time)
-{
-free(pentry->time);
-pentry->time=0;
-}
-if(pentry->date)
-{
-free(pentry->date);
-pentry->date=0;
-}
+  if (!pentry)
+    return 1;
+  if (pentry->name)
+  {
+    free (pentry->name);
+    pentry->name = 0;
+  }
+  if (pentry->number)
+  {
+    free (pentry->number);
+    pentry->number = 0;
+  }
+  if (pentry->picpath)
+  {
+    free (pentry->picpath);
+    pentry->picpath = 0;
+  }
+  if (pentry->time)
+  {
+    free (pentry->time);
+    pentry->time = 0;
+  }
+  if (pentry->date)
+  {
+    free (pentry->date);
+    pentry->date = 0;
+  }
 
-pentry->prev=0;
-pentry->next=0;
-free(pentry);
-pentry=0;
-return 1;
+  pentry->prev = 0;
+  pentry->next = 0;
+  free (pentry);
+  pentry = 0;
+  return 1;
 
 }
 
@@ -272,35 +285,36 @@
  * @retval 0 failed 
  * @retval 1 success
  */
-int history_release_history_list(HISTORY_LIST_HEAD* historyhead)
+int
+history_release_history_list (HISTORY_LIST_HEAD * historyhead)
 {
-	HISTORY_ENTRY * pentry;
-	HISTORY_ENTRY * next;
-	pentry=historyhead->first;
-	while(pentry)
-		{
-		next=pentry->next;
-		history_release_entry(pentry);
-		pentry=next;
-		}
-	historyhead->first=0;
-	historyhead->last=0;
-	historyhead->length=0;
-	return 1;
+  HISTORY_ENTRY *pentry;
+  HISTORY_ENTRY *next;
+  pentry = historyhead->first;
+  while (pentry)
+  {
+    next = pentry->next;
+    history_release_entry (pentry);
+    pentry = next;
+  }
+  historyhead->first = 0;
+  historyhead->last = 0;
+  historyhead->length = 0;
+  return 1;
 }
 
-int history_init_history_data(HISTORY_LIST_HEAD* historyhead)
+int
+history_init_history_data (HISTORY_LIST_HEAD * historyhead)
 {
 
- DBG_ENTER();
-  int res = history_read_list(historyhead);
+  DBG_ENTER ();
+  int res = history_read_list (historyhead);
 
-  if(res == 0)
+  if (res == 0)
   {
     res = history_read_list_cmd (historyhead);
   }
-  DBG_MESSAGE("History:%d",historyhead->length);
-  DBG_LEAVE();
+  DBG_MESSAGE ("History:%d", historyhead->length);
+  DBG_LEAVE ();
   return res;
 }
-

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -21,7 +21,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
 #ifndef _HISTORY_H
 #define _HISTORY_H
 
@@ -30,50 +30,51 @@
 
 
 extern "C"
-
 {
 #endif
 
-	
 
+
 /**
  * @brief enum of history type
  */
-	
-typedef enum _historytype{
-	INCOMING=0, ///<incoming calls
-	OUTGOING,///<outgoing calls
-	MISSED,///<missed calls 
-	ALL ///<all the types including the above
-}HISTORY_TYPE;
 
+  typedef enum _historytype
+  {
+    INCOMING = 0,               ///<incoming calls
+    OUTGOING,                   ///<outgoing calls
+    MISSED,                     ///<missed calls 
+    ALL                         ///<all the types including the above
+  } HISTORY_TYPE;
+
 /**
  * @brief history entry item structure
  */
-typedef struct historyentry
-{
-  int ID;///<the unique ID for an contact entry 
-  HISTORY_TYPE type;
-  char *name;       	///<person name
-  char *number;       	///<person number
-  char *picpath;  ///<the picture file path for the person
-  char *time;	///< start time of that talk 
-  char *date;///<start date  of that talk
-  int durationsec;///<seconds of the duaration 
-  struct historyentry* next;         ///<pointer to next entry
-  struct historyentry* prev;         ///<pointer to next entry
-  int hasname;
-}HISTORY_ENTRY;
+  typedef struct historyentry
+  {
+    int ID;                     ///<the unique ID for an contact entry 
+    HISTORY_TYPE type;
+    char *name;                 ///<person name
+    char *number;               ///<person number
+    char *picpath;              ///<the picture file path for the person
+    char *time;                 ///< start time of that talk 
+    char *date;                 ///<start date  of that talk
+    int durationsec;            ///<seconds of the duaration 
+    struct historyentry *next;  ///<pointer to next entry
+    struct historyentry *prev;  ///<pointer to next entry
+    int hasname;
+  } HISTORY_ENTRY;
 
 
 /**
  * @brief contacts list head structure.
  */
-typedef struct history_list_head {
-  int length;                   ///<the number of history
-  HISTORY_ENTRY *first;        ///<list head pointer
-  HISTORY_ENTRY *last;        ///<list head pointer
-}HISTORY_LIST_HEAD;
+  typedef struct history_list_head
+  {
+    int length;                 ///<the number of history
+    HISTORY_ENTRY *first;       ///<list head pointer
+    HISTORY_ENTRY *last;        ///<list head pointer
+  } HISTORY_LIST_HEAD;
 /**
  * @brief read the history list using the external APIs,currently only return 0
  * 
@@ -83,7 +84,7 @@
  * @retval 0 failed 
  * @retval other success
  */
-int history_read_list(HISTORY_LIST_HEAD* historyhead);
+  int history_read_list (HISTORY_LIST_HEAD * historyhead);
 
 /**
  * @brief read the history list using internal data,just for debug use
@@ -95,7 +96,7 @@
  * @retval 0 failed 
  * @retval other success
  */
-int history_read_list_cmd(HISTORY_LIST_HEAD* historyhead);
+  int history_read_list_cmd (HISTORY_LIST_HEAD * historyhead);
 
 /**
  * @brief release the momory by the list and it's entry
@@ -107,7 +108,7 @@
  * @retval 0 failed 
  * @retval 1 success
  */
-int history_release_history_list(HISTORY_LIST_HEAD* historyhead);
+  int history_release_history_list (HISTORY_LIST_HEAD * historyhead);
 
 /**
  * @brief create a history entry, and add this entry to the list.
@@ -122,7 +123,10 @@
  * @return 
  * @retval the newly created entry pointer
  */
-HISTORY_ENTRY * history_add_entry(HISTORY_LIST_HEAD* historyhead, HISTORY_TYPE type,const char *name,const char *number,const char *picpath,  char *time,char *date,int durationsec);
+  HISTORY_ENTRY *history_add_entry (HISTORY_LIST_HEAD * historyhead,
+                                    HISTORY_TYPE type, const char *name,
+                                    const char *number, const char *picpath,
+                                    char *time, char *date, int durationsec);
 /**
  * @brief delete the supplied entry from the list 
  * 
@@ -134,11 +138,12 @@
  * @retval 0 failed
  * @retval 1 success
  */
-int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry);
+  int history_delete_entry (HISTORY_LIST_HEAD * historyhead,
+                            HISTORY_ENTRY * entry);
 
-int history_init_history_data(HISTORY_LIST_HEAD* historyhead);
+  int history_init_history_data (HISTORY_LIST_HEAD * historyhead);
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _HISTORY_H */
+#endif                          /* _HISTORY_H */

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,415 +1,445 @@
-/* moko-dialer-autolist .c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
- #include "moko-dialer-autolist.h"
-  #include "error.h"
-#include "common.h" 
-G_DEFINE_TYPE (MokoDialerAutolist, moko_dialer_autolist, GTK_TYPE_HBOX)
-
-enum {
-  SELECTED_SIGNAL,
-  CONFIRMED_SIGNAL,
-  NOMATCH_SIGNAL,
-  LAST_SIGNAL
-};
-
-//forward definition
-
-gboolean on_tip_press_event (MokoDialerTip       *tip,GdkEventButton  *event,gpointer        user_data);
-
-static gint moko_dialer_autolist_signals[LAST_SIGNAL] = { 0 };
-
-static void
-moko_dialer_autolist_class_init (MokoDialerAutolistClass *class)
-{
-/*
-  GtkVBoxClass* vbox_class;
-
-  vbox_class= (GtkVBoxClass*) class;
-*/
-
-  GtkObjectClass *object_class;
-
-  object_class = (GtkObjectClass*) class;
-
- g_print("moko_dialer_autolist:start signal register\n");
-  
-  moko_dialer_autolist_signals[SELECTED_SIGNAL] = 
-  		g_signal_new ("user_selected",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_selected),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__POINTER,
-		G_TYPE_NONE, 1,g_type_from_name("gpointer"));
-
-
-
-
-
-  moko_dialer_autolist_signals[CONFIRMED_SIGNAL] = 
-  		g_signal_new ("user_confirmed",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_confirmed),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__POINTER,
-		G_TYPE_NONE, 1,g_type_from_name("gpointer"));
-
-//moko_dialer_autolist_nomatch
-  moko_dialer_autolist_signals[NOMATCH_SIGNAL] = 
-  		g_signal_new ("autolist_nomatch",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_nomatch),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__VOID,
-		G_TYPE_NONE, 0);
-
-
-
-}
-
-
-static void
-moko_dialer_autolist_init (MokoDialerAutolist *moko_dialer_autolist)
-{
-//DBG_ENTER();
-int i;
-for(i=0;i<MOKO_DIALER_MAX_TIPS;i++)
-	moko_dialer_autolist->tips[i]=0;
-moko_dialer_autolist->  tipscreated=FALSE;  
-moko_dialer_autolist->head=0;
-moko_dialer_autolist->g_alternatecount=0;
-moko_dialer_autolist->imagePerson=0;
-gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_autolist), 480, 40); 
-
-}
-/**
- * @brief please call this function first before the autolist start to work.
-*/
-gboolean moko_dialer_autolist_set_data (MokoDialerAutolist *moko_dialer_autolist,DIALER_CONTACTS_LIST_HEAD* head)
-{
-/*
-if(moko_dialer_autolist->head)
-	contact_release_contact_list(moko_dialer_autolist->head);
-	*/
-	
-moko_dialer_autolist->head=head;
-
-//contact_print_contact_list(moko_dialer_autolist->head);
-
-return TRUE;
-}
-
-gint moko_dialer_autolist_hide_all_tips(MokoDialerAutolist *moko_dialer_autolist)
-{
-
-if(moko_dialer_autolist->tipscreated)
-{
-		moko_dialer_autolist->selected=FALSE;
-			//no alternative, hide all 3 labels.
-			gint i;
-		for(i=0;i<MOKO_DIALER_MAX_TIPS;i++)
-		{
-		moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
-		gtk_widget_hide(moko_dialer_autolist->tips[i]);
-		}
-		//hide the imagePerson
-		gtk_widget_hide(moko_dialer_autolist->imagePerson);
-}
-		return 1;
-
-}
-
-/**
- * @brief initiate the font for widget of textviewCodes 
- *
- *
- *
- * @param text_view GtkWidget*, any widget which can help to lookup for labelcontactN
- * @param count gint, the count of the alternative, max set to MAXDISPNAMENUM.
- * @param selectdefault if selectdefault, then we will automatically emit the message to fill the sensed string,
- *  else, we only refresh our tip list.
- * @retval 
- */
-
-int moko_dialer_autolist_fill_alternative(MokoDialerAutolist *moko_dialer_autolist,gint count,gboolean selectdefault)
-{
-gint i;
-//DBG_ENTER();
-moko_dialer_autolist->selected=FALSE;
-
-moko_dialer_autolist->g_alternatecount=count;
-
-if(count>0)
-{
-	//init the labels.
-	for(i=0;i<count&&i<MOKO_DIALER_MAX_TIPS;i++)
-	{
-	moko_dialer_tip_set_label(moko_dialer_autolist->tips[i],moko_dialer_autolist->readycontacts[i].p_contact->name);
-	moko_dialer_tip_set_index(moko_dialer_autolist->tips[i],i);
-	moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
-	gtk_widget_show(moko_dialer_autolist->tips[i]);
-	}
-
-	for(;i<MOKO_DIALER_MAX_TIPS;i++)
-	{
-	moko_dialer_tip_set_index(moko_dialer_autolist->tips[i],-1);
-	moko_dialer_tip_set_label(moko_dialer_autolist->tips[i],"");
-	gtk_widget_hide(moko_dialer_autolist->tips[i]);
-	moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
-	}
-
-	if(selectdefault)
-	{
-		//we set the first one as defaultly selected
-		moko_dialer_autolist_set_select(moko_dialer_autolist, 0);
-	}
-}	
-else
-	{
-	moko_dialer_autolist_hide_all_tips(moko_dialer_autolist);	
-		//notify the client that no match has been foudn
-//		autolist_nomatch
-   g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[NOMATCH_SIGNAL],0,0);
-	}
-	return 1;
-}
-
-//if selectdefault, then we will automatically emit the message to fill the sensed string
-//else, we only refresh our tip list.
-gint  moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *moko_dialer_autolist,gchar * string,gboolean selectdefault)
-{
-//first, we fill the ready list
-
-  DIALER_CONTACT* contacts;//=moko_dialer_autolist->head->contacts;
-
-  DIALER_CONTACT_ENTRY* entry;
-
-  gint inserted=0;
-
-  
-  gint len;
-  
-  if(string)
-	  len=strlen(string);
-  else
-	  len=0;
-//  DBG_TRACE();
-  
-//insert the tips here to avoid the _show_all show it from the start.
-  GtkWidget * imagePerson;
-  GtkWidget * tip;
-
-if(!moko_dialer_autolist->tipscreated)
-{
-  gchar filepath[MOKO_DIALER_MAX_PATH_LEN+1];
-  if(file_create_data_path_for_the_file(MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH,filepath))
-  	{
-	  imagePerson = gtk_image_new_from_file(filepath);
-  	}
-  else
-  	{
-  	imagePerson=gtk_image_new_from_stock("gtk-yes",GTK_ICON_SIZE_DND);
-  	}
- gtk_widget_hide (imagePerson);
- gtk_widget_set_size_request (imagePerson, 40, 40);	
-//  gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0);
-//gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, FALSE, 0);
- gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, FALSE, FALSE, 0);
-  
-  moko_dialer_autolist->imagePerson=imagePerson;
-			gint i;
-  for(i=0;i<MOKO_DIALER_MAX_TIPS;i++)
-  	{
-  	tip=moko_dialer_tip_new();
-  	
-  	moko_dialer_tip_set_index(tip, i);
-  	
-  	moko_dialer_tip_set_label(tip,"tony guan");
-
-	moko_dialer_tip_set_selected(tip,FALSE);
-
-	 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, TRUE, 0);  	
-//	 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,FALSE, 0);  		
-//	 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,TRUE, 0);
-//			 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, FALSE,0);
-	
-	  g_signal_connect ((gpointer) tip, "button_press_event",G_CALLBACK (on_tip_press_event),moko_dialer_autolist);
-
-//	gtk_widget_set_size_request (tip, 20, 20);	
-
-	gtk_widget_hide(tip);
-
-  	moko_dialer_autolist-> tips[i]=tip;
-  	}
-	moko_dialer_autolist->  tipscreated=TRUE;
-}
-
- contacts=moko_dialer_autolist->head->contacts;
-
-//  DBG_MESSAGE("CONTACTS:%d,list at 0x%x,first at 0x%x",moko_dialer_autolist->head->length,moko_dialer_autolist->head,moko_dialer_autolist->head->contacts);
-
-//	  DBG_TRACE();  
-   while(contacts!= NULL&&inserted<MOKO_DIALER_MAX_TIPS)
-   {
-	//  DBG_TRACE();
-      entry=contacts->entry;
-	//  DBG_TRACE();
-	 while(entry!=NULL&&inserted<MOKO_DIALER_MAX_TIPS)
-	 {
-//	 DBG_TRACE();
-	 //judge if the entry includes the string
-	 if(contact_string_has_sensentive(entry->content,string))
-	 {	
-		//if the person not inserted, then insert first
-	moko_dialer_autolist->readycontacts[inserted].p_contact=contacts;
-	moko_dialer_autolist->readycontacts[inserted].p_entry=entry;
-       inserted++;
-		 //break;
-	 }
- 	    entry=entry->next;
-	 }
-	 
-	 contacts= contacts->next;
-	
-  }
-
-//DBG_MESSAGE("inserted=%d",inserted);
-moko_dialer_autolist_fill_alternative(moko_dialer_autolist,inserted,selectdefault);
-
-//DBG_LEAVE();
-  return inserted;
-}
-
-gboolean on_tip_press_event (MokoDialerTip       *tip,GdkEventButton  *event,gpointer         user_data)
-{
-
-//DBG_ENTER();
-MokoDialerAutolist *moko_dialer_autolist;
-moko_dialer_autolist=(MokoDialerAutolist *)user_data;
-
-gint selected=moko_dialer_tip_get_index(tip);
-
-
-if(selected!=-1&&selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount)
-{
-
-		return  moko_dialer_autolist_set_select(moko_dialer_autolist,selected);
-
-}
-else
-{
-//we notify the client that no match found!
-DBG_WARN("the selected index is out of range!");
-return FALSE;
-}
-
-
-}
-
-gboolean moko_dialer_autolist_has_selected(MokoDialerAutolist *moko_dialer_autolist)
-{
-	return moko_dialer_autolist->selected;
-}
-
-// selected ==-1 means there are no selected tips
-gboolean moko_dialer_autolist_set_select(MokoDialerAutolist *moko_dialer_autolist,gint selected)
-{
-gint i;
-		if(selected==-1)
-		{
-
-			//set the selected status to be false
-			for( i=0;i<moko_dialer_autolist->g_alternatecount;i++)
-			{
-			moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], FALSE);
-			}
-			//set
-			gtk_widget_hide(moko_dialer_autolist->imagePerson);	
-			moko_dialer_autolist->selected=FALSE;
-			return TRUE;
-		}
-
-
-if(selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount)
-	{
-	//first of all, determin if this tip is already selected previously.
-	if(moko_dialer_tip_is_selected(moko_dialer_autolist->tips[selected]))
-	{
-
-		//hide the others;
-		for( i=0;i<moko_dialer_autolist->g_alternatecount;i++)
-		{
-			if(i!=selected)
-			{//hide the others
-			gtk_widget_hide( moko_dialer_autolist->tips[i]);
-			}
-		}
-	moko_dialer_autolist->selected=FALSE;
-	//emit confirm message;
-//		DBG_MESSAGE("we confirm %s is right.",moko_dialer_autolist->readycontacts[selected].p_contact->name);			
-	g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[CONFIRMED_SIGNAL],0,&(moko_dialer_autolist->readycontacts[selected]));
-
-	}
-	else
-	{
-
-	//refresh the imagePerson widget
-//	file_load_person_image_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
-	file_load_person_image_scalable_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
-		gtk_widget_show(moko_dialer_autolist->imagePerson);	
-	//just change the selected attribute of the tips
-		for( i=0;i<moko_dialer_autolist->g_alternatecount;i++)
-		{
-			if(i!=selected)
-			{//set selected to false;
-			moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], FALSE);
-			}
-			else
-			moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], TRUE);
-		}
-	moko_dialer_autolist->selected=TRUE;
-		//emit selected message
-//		DBG_MESSAGE(" %s is selectd.",moko_dialer_autolist->readycontacts[selected].p_contact->name);
-		g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[SELECTED_SIGNAL],0,&(moko_dialer_autolist->readycontacts[selected]));	
-	}
-		return TRUE;
-	}
-else
-	{
-	DBG_WARN("the selected index is out of range!");
-	return FALSE;
-	}
-		
-}
-
-GtkWidget*      moko_dialer_autolist_new()
-{
-DBG_ENTER();
-
-MokoDialerAutolist * dp;
-
-dp=(MokoDialerAutolist * )g_object_new (MOKO_TYPE_DIALER_AUTOLIST, NULL);
-return GTK_WIDGET(dp);
-
-}
-
- 
-
+/* moko-dialer-autolist .c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include "moko-dialer-autolist.h"
+#include "error.h"
+#include "common.h"
+G_DEFINE_TYPE (MokoDialerAutolist, moko_dialer_autolist, GTK_TYPE_HBOX)
+     enum
+     {
+       SELECTED_SIGNAL,
+       CONFIRMED_SIGNAL,
+       NOMATCH_SIGNAL,
+       LAST_SIGNAL
+     };
+
+//forward definition
+
+     gboolean on_tip_press_event (MokoDialerTip * tip, GdkEventButton * event,
+                                  gpointer user_data);
+
+     static gint moko_dialer_autolist_signals[LAST_SIGNAL] = { 0 };
+
+static void
+moko_dialer_autolist_class_init (MokoDialerAutolistClass * class)
+{
+/*
+  GtkVBoxClass* vbox_class;
+
+  vbox_class= (GtkVBoxClass*) class;
+*/
+
+  GtkObjectClass *object_class;
+
+  object_class = (GtkObjectClass *) class;
+
+  g_print ("moko_dialer_autolist:start signal register\n");
+
+  moko_dialer_autolist_signals[SELECTED_SIGNAL] =
+    g_signal_new ("user_selected",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerAutolistClass,
+                                   moko_dialer_autolist_selected), NULL, NULL,
+                  g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+                  g_type_from_name ("gpointer"));
+
+
+
+
+
+  moko_dialer_autolist_signals[CONFIRMED_SIGNAL] =
+    g_signal_new ("user_confirmed",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerAutolistClass,
+                                   moko_dialer_autolist_confirmed), NULL,
+                  NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+                  g_type_from_name ("gpointer"));
+
+//moko_dialer_autolist_nomatch
+  moko_dialer_autolist_signals[NOMATCH_SIGNAL] =
+    g_signal_new ("autolist_nomatch",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerAutolistClass,
+                                   moko_dialer_autolist_nomatch), NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+
+
+}
+
+
+static void
+moko_dialer_autolist_init (MokoDialerAutolist * moko_dialer_autolist)
+{
+//DBG_ENTER();
+  int i;
+  for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++)
+    moko_dialer_autolist->tips[i] = 0;
+  moko_dialer_autolist->tipscreated = FALSE;
+  moko_dialer_autolist->head = 0;
+  moko_dialer_autolist->g_alternatecount = 0;
+  moko_dialer_autolist->imagePerson = 0;
+  gtk_widget_set_size_request (GTK_WIDGET (moko_dialer_autolist), 480, 40);
+
+}
+
+/**
+ * @brief please call this function first before the autolist start to work.
+*/
+gboolean
+moko_dialer_autolist_set_data (MokoDialerAutolist * moko_dialer_autolist,
+                               DIALER_CONTACTS_LIST_HEAD * head)
+{
+/*
+if(moko_dialer_autolist->head)
+	contact_release_contact_list(moko_dialer_autolist->head);
+	*/
+
+  moko_dialer_autolist->head = head;
+
+//contact_print_contact_list(moko_dialer_autolist->head);
+
+  return TRUE;
+}
+
+gint
+moko_dialer_autolist_hide_all_tips (MokoDialerAutolist * moko_dialer_autolist)
+{
+
+  if (moko_dialer_autolist->tipscreated)
+  {
+    moko_dialer_autolist->selected = FALSE;
+    //no alternative, hide all 3 labels.
+    gint i;
+    for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+      gtk_widget_hide (moko_dialer_autolist->tips[i]);
+    }
+    //hide the imagePerson
+    gtk_widget_hide (moko_dialer_autolist->imagePerson);
+  }
+  return 1;
+
+}
+
+/**
+ * @brief initiate the font for widget of textviewCodes 
+ *
+ *
+ *
+ * @param text_view GtkWidget*, any widget which can help to lookup for labelcontactN
+ * @param count gint, the count of the alternative, max set to MAXDISPNAMENUM.
+ * @param selectdefault if selectdefault, then we will automatically emit the message to fill the sensed string,
+ *  else, we only refresh our tip list.
+ * @retval 
+ */
+
+int
+moko_dialer_autolist_fill_alternative (MokoDialerAutolist *
+                                       moko_dialer_autolist, gint count,
+                                       gboolean selectdefault)
+{
+  gint i;
+//DBG_ENTER();
+  moko_dialer_autolist->selected = FALSE;
+
+  moko_dialer_autolist->g_alternatecount = count;
+
+  if (count > 0)
+  {
+    //init the labels.
+    for (i = 0; i < count && i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      moko_dialer_tip_set_label (moko_dialer_autolist->tips[i],
+                                 moko_dialer_autolist->readycontacts[i].
+                                 p_contact->name);
+      moko_dialer_tip_set_index (moko_dialer_autolist->tips[i], i);
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+      gtk_widget_show (moko_dialer_autolist->tips[i]);
+    }
+
+    for (; i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      moko_dialer_tip_set_index (moko_dialer_autolist->tips[i], -1);
+      moko_dialer_tip_set_label (moko_dialer_autolist->tips[i], "");
+      gtk_widget_hide (moko_dialer_autolist->tips[i]);
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+    }
+
+    if (selectdefault)
+    {
+      //we set the first one as defaultly selected
+      moko_dialer_autolist_set_select (moko_dialer_autolist, 0);
+    }
+  }
+  else
+  {
+    moko_dialer_autolist_hide_all_tips (moko_dialer_autolist);
+    //notify the client that no match has been foudn
+//              autolist_nomatch
+    g_signal_emit (moko_dialer_autolist,
+                   moko_dialer_autolist_signals[NOMATCH_SIGNAL], 0, 0);
+  }
+  return 1;
+}
+
+//if selectdefault, then we will automatically emit the message to fill the sensed string
+//else, we only refresh our tip list.
+gint
+moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *
+                                        moko_dialer_autolist, gchar * string,
+                                        gboolean selectdefault)
+{
+//first, we fill the ready list
+
+  DIALER_CONTACT *contacts;     //=moko_dialer_autolist->head->contacts;
+
+  DIALER_CONTACT_ENTRY *entry;
+
+  gint inserted = 0;
+
+
+  gint len;
+
+  if (string)
+    len = strlen (string);
+  else
+    len = 0;
+//  DBG_TRACE();
+
+//insert the tips here to avoid the _show_all show it from the start.
+  GtkWidget *imagePerson;
+  GtkWidget *tip;
+
+  if (!moko_dialer_autolist->tipscreated)
+  {
+    gchar filepath[MOKO_DIALER_MAX_PATH_LEN + 1];
+    if (file_create_data_path_for_the_file
+        (MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH, filepath))
+    {
+      imagePerson = gtk_image_new_from_file (filepath);
+    }
+    else
+    {
+      imagePerson = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_DND);
+    }
+    gtk_widget_hide (imagePerson);
+    gtk_widget_set_size_request (imagePerson, 40, 40);
+//  gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0);
+//gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, FALSE, 0);
+    gtk_box_pack_start (GTK_CONTAINER (moko_dialer_autolist), imagePerson,
+                        FALSE, FALSE, 0);
+
+    moko_dialer_autolist->imagePerson = imagePerson;
+    gint i;
+    for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      tip = moko_dialer_tip_new ();
+
+      moko_dialer_tip_set_index (tip, i);
+
+      moko_dialer_tip_set_label (tip, "tony guan");
+
+      moko_dialer_tip_set_selected (tip, FALSE);
+
+      gtk_box_pack_start (GTK_CONTAINER (moko_dialer_autolist), tip, TRUE,
+                          TRUE, 0);
+//       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,FALSE, 0);                  
+//       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,TRUE, 0);
+//                       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, FALSE,0);
+
+      g_signal_connect ((gpointer) tip, "button_press_event",
+                        G_CALLBACK (on_tip_press_event),
+                        moko_dialer_autolist);
+
+//      gtk_widget_set_size_request (tip, 20, 20);      
+
+      gtk_widget_hide (tip);
+
+      moko_dialer_autolist->tips[i] = tip;
+    }
+    moko_dialer_autolist->tipscreated = TRUE;
+  }
+
+  contacts = moko_dialer_autolist->head->contacts;
+
+//  DBG_MESSAGE("CONTACTS:%d,list at 0x%x,first at 0x%x",moko_dialer_autolist->head->length,moko_dialer_autolist->head,moko_dialer_autolist->head->contacts);
+
+//        DBG_TRACE();  
+  while (contacts != NULL && inserted < MOKO_DIALER_MAX_TIPS)
+  {
+    //  DBG_TRACE();
+    entry = contacts->entry;
+    //  DBG_TRACE();
+    while (entry != NULL && inserted < MOKO_DIALER_MAX_TIPS)
+    {
+//       DBG_TRACE();
+      //judge if the entry includes the string
+      if (contact_string_has_sensentive (entry->content, string))
+      {
+        //if the person not inserted, then insert first
+        moko_dialer_autolist->readycontacts[inserted].p_contact = contacts;
+        moko_dialer_autolist->readycontacts[inserted].p_entry = entry;
+        inserted++;
+        //break;
+      }
+      entry = entry->next;
+    }
+
+    contacts = contacts->next;
+
+  }
+
+//DBG_MESSAGE("inserted=%d",inserted);
+  moko_dialer_autolist_fill_alternative (moko_dialer_autolist, inserted,
+                                         selectdefault);
+
+//DBG_LEAVE();
+  return inserted;
+}
+
+gboolean
+on_tip_press_event (MokoDialerTip * tip, GdkEventButton * event,
+                    gpointer user_data)
+{
+
+//DBG_ENTER();
+  MokoDialerAutolist *moko_dialer_autolist;
+  moko_dialer_autolist = (MokoDialerAutolist *) user_data;
+
+  gint selected = moko_dialer_tip_get_index (tip);
+
+
+  if (selected != -1 && selected < MOKO_DIALER_MAX_TIPS
+      && moko_dialer_autolist->g_alternatecount)
+  {
+
+    return moko_dialer_autolist_set_select (moko_dialer_autolist, selected);
+
+  }
+  else
+  {
+//we notify the client that no match found!
+    DBG_WARN ("the selected index is out of range!");
+    return FALSE;
+  }
+
+
+}
+
+gboolean
+moko_dialer_autolist_has_selected (MokoDialerAutolist * moko_dialer_autolist)
+{
+  return moko_dialer_autolist->selected;
+}
+
+// selected ==-1 means there are no selected tips
+gboolean
+moko_dialer_autolist_set_select (MokoDialerAutolist * moko_dialer_autolist,
+                                 gint selected)
+{
+  gint i;
+  if (selected == -1)
+  {
+
+    //set the selected status to be false
+    for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++)
+    {
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+    }
+    //set
+    gtk_widget_hide (moko_dialer_autolist->imagePerson);
+    moko_dialer_autolist->selected = FALSE;
+    return TRUE;
+  }
+
+
+  if (selected < MOKO_DIALER_MAX_TIPS
+      && moko_dialer_autolist->g_alternatecount)
+  {
+    //first of all, determin if this tip is already selected previously.
+    if (moko_dialer_tip_is_selected (moko_dialer_autolist->tips[selected]))
+    {
+
+      //hide the others;
+      for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++)
+      {
+        if (i != selected)
+        {                       //hide the others
+          gtk_widget_hide (moko_dialer_autolist->tips[i]);
+        }
+      }
+      moko_dialer_autolist->selected = FALSE;
+      //emit confirm message;
+//              DBG_MESSAGE("we confirm %s is right.",moko_dialer_autolist->readycontacts[selected].p_contact->name);                   
+      g_signal_emit (moko_dialer_autolist,
+                     moko_dialer_autolist_signals[CONFIRMED_SIGNAL], 0,
+                     &(moko_dialer_autolist->readycontacts[selected]));
+
+    }
+    else
+    {
+
+      //refresh the imagePerson widget
+//      file_load_person_image_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
+      file_load_person_image_scalable_from_relative_path
+        (moko_dialer_autolist->imagePerson,
+         moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
+      gtk_widget_show (moko_dialer_autolist->imagePerson);
+      //just change the selected attribute of the tips
+      for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++)
+      {
+        if (i != selected)
+        {                       //set selected to false;
+          moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+        }
+        else
+          moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], TRUE);
+      }
+      moko_dialer_autolist->selected = TRUE;
+      //emit selected message
+//              DBG_MESSAGE(" %s is selectd.",moko_dialer_autolist->readycontacts[selected].p_contact->name);
+      g_signal_emit (moko_dialer_autolist,
+                     moko_dialer_autolist_signals[SELECTED_SIGNAL], 0,
+                     &(moko_dialer_autolist->readycontacts[selected]));
+    }
+    return TRUE;
+  }
+  else
+  {
+    DBG_WARN ("the selected index is out of range!");
+    return FALSE;
+  }
+
+}
+
+GtkWidget *
+moko_dialer_autolist_new ()
+{
+  DBG_ENTER ();
+
+  MokoDialerAutolist *dp;
+
+  dp = (MokoDialerAutolist *) g_object_new (MOKO_TYPE_DIALER_AUTOLIST, NULL);
+  return GTK_WIDGET (dp);
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,102 +1,103 @@
-/* moko-dialer-autolist.h
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _MOKO_DIALER_AUTOLIST_H_
-#define _MOKO_DIALER_AUTOLIST_H_
-
-
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkhbox.h>
-#include <glib-object.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtktextview.h>
-#include "moko-dialer-tip.h"
-#include "moko-dialer-declares.h"
-#include "contacts.h"
-#include "history.h"
-//#include "moko-dialer-includes.h"
-
-G_BEGIN_DECLS
-
-
-
-#define MOKO_TYPE_DIALER_AUTOLIST                (moko_dialer_autolist_get_type())
-#define MOKO_DIALER_AUTOLIST (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_AUTOLIST, MokoDialerAutolist))
-#define MOKO_DIALER_AUTOLIST_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_AUTOLIST,MokoDialerAutolistClass))
-#define MOKO_IS_DIALER_AUTOLIST(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_AUTOLIST))
-#define MOKO_IS_DIALER_AUTOLIST_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_AUTOLIST))
-#define MOKO_DIALER_AUTOLIST_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_AUTOLIST, MokoDialerAutolistClass))
-
-
-
-typedef struct _MokoDialerAutolistClass   MokoDialerAutolistClass;
-
-typedef struct _MokoDialerAutolist        MokoDialerAutolist;
-struct _MokoDialerAutolist
-{
-  GtkHBox hbox;
-  
-  DIALER_CONTACTS_LIST_HEAD* head;
-
-//  HISTORY_ENTRY * g_currentselected; ///<pointer to the history entry which in the GUI the user selects.
-
-//static PangoFontDescription *font_desc=NULL; ///<the PangoFontDescription which a lot of widget will use it.
-
- DIALER_READY_CONTACT readycontacts[MOKO_DIALER_MAX_TIPS]; ///<the prepared contact list which will display to the user when he/she inputs part of the digits he/she wants to dial out
-
- gboolean selected;///<indicates wether some tip is currently selected.
-
- gint g_alternatecount;///<indicates how many alternative is ready in the ready list array.
-
- gboolean tipscreated;///<gtk_widget_show_all disables the tips hide attribute, so we have to create the tips for the first time we use it.
-
-  GtkWidget *tips[MOKO_DIALER_MAX_TIPS];
-  GtkWidget *imagePerson;
-
-};
-
-struct _MokoDialerAutolistClass
-{
-  GtkHBoxClass parent_class;
-  void (* moko_dialer_autolist_selected) (MokoDialerAutolist *moko_dialer_autolist,gpointer para_pointer);
-  void (* moko_dialer_autolist_confirmed) (MokoDialerAutolist *moko_dialer_autolist,gpointer para_pointer);
-  void (* moko_dialer_autolist_nomatch) (MokoDialerAutolist *moko_dialer_autolist);
-};
-
-
-GType          moko_dialer_autolist_get_type         (void) ;
-
-GtkWidget*      moko_dialer_autolist_new();
-
-gboolean moko_dialer_autolist_set_select(MokoDialerAutolist *moko_dialer_autolist,gint selected);
-
-gboolean moko_dialer_autolist_has_selected(MokoDialerAutolist *moko_dialer_autolist);
-
-gint  moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *moko_dialer_autolist,gchar * string,gboolean selectdefault);
-
-gint moko_dialer_autolist_hide_all_tips(MokoDialerAutolist *moko_dialer_autolist);
-G_END_DECLS
-
-#endif // 
-
-
-
-
+/* moko-dialer-autolist.h
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_AUTOLIST_H_
+#define _MOKO_DIALER_AUTOLIST_H_
+
+
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkhbox.h>
+#include <glib-object.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkobject.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtktextview.h>
+#include "moko-dialer-tip.h"
+#include "moko-dialer-declares.h"
+#include "contacts.h"
+#include "history.h"
+//#include "moko-dialer-includes.h"
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIALER_AUTOLIST                (moko_dialer_autolist_get_type())
+#define MOKO_DIALER_AUTOLIST (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_AUTOLIST, MokoDialerAutolist))
+#define MOKO_DIALER_AUTOLIST_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_AUTOLIST,MokoDialerAutolistClass))
+#define MOKO_IS_DIALER_AUTOLIST(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_AUTOLIST))
+#define MOKO_IS_DIALER_AUTOLIST_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_AUTOLIST))
+#define MOKO_DIALER_AUTOLIST_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_AUTOLIST, MokoDialerAutolistClass))
+typedef struct _MokoDialerAutolistClass MokoDialerAutolistClass;
+
+typedef struct _MokoDialerAutolist MokoDialerAutolist;
+struct _MokoDialerAutolist
+{
+  GtkHBox hbox;
+
+  DIALER_CONTACTS_LIST_HEAD *head;
+
+//  HISTORY_ENTRY * g_currentselected; ///<pointer to the history entry which in the GUI the user selects.
+
+//static PangoFontDescription *font_desc=NULL; ///<the PangoFontDescription which a lot of widget will use it.
+
+  DIALER_READY_CONTACT readycontacts[MOKO_DIALER_MAX_TIPS];     ///<the prepared contact list which will display to the user when he/she inputs part of the digits he/she wants to dial out
+
+  gboolean selected;            ///<indicates wether some tip is currently selected.
+
+  gint g_alternatecount;        ///<indicates how many alternative is ready in the ready list array.
+
+  gboolean tipscreated;         ///<gtk_widget_show_all disables the tips hide attribute, so we have to create the tips for the first time we use it.
+
+  GtkWidget *tips[MOKO_DIALER_MAX_TIPS];
+  GtkWidget *imagePerson;
+
+};
+
+struct _MokoDialerAutolistClass
+{
+  GtkHBoxClass parent_class;
+  void (*moko_dialer_autolist_selected) (MokoDialerAutolist *
+                                         moko_dialer_autolist,
+                                         gpointer para_pointer);
+  void (*moko_dialer_autolist_confirmed) (MokoDialerAutolist *
+                                          moko_dialer_autolist,
+                                          gpointer para_pointer);
+  void (*moko_dialer_autolist_nomatch) (MokoDialerAutolist *
+                                        moko_dialer_autolist);
+};
+
+
+GType moko_dialer_autolist_get_type (void);
+
+GtkWidget *moko_dialer_autolist_new ();
+
+gboolean moko_dialer_autolist_set_select (MokoDialerAutolist *
+                                          moko_dialer_autolist,
+                                          gint selected);
+
+gboolean moko_dialer_autolist_has_selected (MokoDialerAutolist *
+                                            moko_dialer_autolist);
+
+gint moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *
+                                             moko_dialer_autolist,
+                                             gchar * string,
+                                             gboolean selectdefault);
+
+gint moko_dialer_autolist_hide_all_tips (MokoDialerAutolist *
+                                         moko_dialer_autolist);
+G_END_DECLS
+#endif //

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,31 +1,31 @@
-/*  moko-dialer-declares.h
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-#ifndef _MOKO_DIALER_DECLARES_H_
-#define _MOKO_DIALER_DECLARES_H_
-#define MOKO_DIALER_MAX_TIME_STATUS_LEN (128)  ///<TO HOLD THE STRINGS LIKE "CALL...(00:00:30)
-#define MOKO_DIALER_MAX_NUMBER_LEN	(64)          ///<TO HOLD THE PHONE NUMBERS
-#define MOKO_DIALER_MAX_DISP_NAME_LEN (20)   ///<THE MAXIMUM LENGTH OF THE DISPLAYED CONTACT NAME
-#define MOKO_DIALER_MAX_PATH_LEN (128)	 ///<THE MAX PATH LEN
-//MAXDISPNAMENUM MUST >=1 & <=9!
-
-#define MOKO_DIALER_MIN_SENSATIVE_LEN (1) ///<only when user inputs at least MINSENSATIVELEN, should we start to search.
-#define MOKO_DIALER_MAX_STATUS_ICONS (3) ///<THE NUMBERS OF THE ICONS WHEN OUTGOING CALL IS ON
-#define MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH ("unkown.png") ///<THE DEFAULT PERSON IMAGE
-#define MOKO_DIALER_MAX_TIPS (3)
-
-#endif
+/*  moko-dialer-declares.h
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_DECLARES_H_
+#define _MOKO_DIALER_DECLARES_H_
+#define MOKO_DIALER_MAX_TIME_STATUS_LEN (128)   ///<TO HOLD THE STRINGS LIKE "CALL...(00:00:30)
+#define MOKO_DIALER_MAX_NUMBER_LEN	(64)    ///<TO HOLD THE PHONE NUMBERS
+#define MOKO_DIALER_MAX_DISP_NAME_LEN (20)      ///<THE MAXIMUM LENGTH OF THE DISPLAYED CONTACT NAME
+#define MOKO_DIALER_MAX_PATH_LEN (128)  ///<THE MAX PATH LEN
+//MAXDISPNAMENUM MUST >=1 & <=9!
+
+#define MOKO_DIALER_MIN_SENSATIVE_LEN (1)       ///<only when user inputs at least MINSENSATIVELEN, should we start to search.
+#define MOKO_DIALER_MAX_STATUS_ICONS (3)        ///<THE NUMBERS OF THE ICONS WHEN OUTGOING CALL IS ON
+#define MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH ("unkown.png")    ///<THE DEFAULT PERSON IMAGE
+#define MOKO_DIALER_MAX_TIPS (3)
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,108 +1,114 @@
-/* moko-dialer-includes.h
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _MOKO_DIALER_INCLUDES_H
-#define _MOKO_DIALER_INCLUDES_H
-
-
-#include "moko-dialer-declares.h"
-#include "error.h"
-#include "contacts.h"
-#include "history.h"
-#include "moko-dialer-autolist.h"
-#include "moko-dialer-panel.h"
-#include "moko-dialer-textview.h"
-#include "moko-digit-button.h"
-#include "moko-dialer-status.h"
-#include <libmokoui/moko-dialog-window.h>
-#include <time.h>
-#include <gtk/gtkliststore.h>
-//
-
-
-typedef enum _state{
-  STATE_NON= 0,
-  STATE_CALLING,
-  STATE_INCOMING,
-  STATE_TALKING,
-  STATE_FINISHED,
-  STATE_FAILED,
-  STATE_REJECTED,
-  STATE_TIMEOUT,
-  STATE_IGNORED,
-  STATE_MISSED
-}CONNECTION_STATE;
-typedef enum _windowstate{
-	WINDOWS_TALKING=0,
-	WINDOWS_DTMF
-}WINDOW_STATE;	
-typedef enum _speakerstate{
-	SPEAKER_ON=0,
-	SPEAKER_OFF
-}SPEAKER_STATE;
-typedef enum _incomingstate{
-	NO_INCOMING_EVENT=0,
-	HAS_INCOMING_EVENT
-}INCOMINGSTATE;
-typedef enum _clipstate{
-	NO_CLIP_EVENT=0,
-	HAS_CLIP_EVENT
-}CLIPSTATE;
-
-typedef struct _globalstate
-{
-	CONNECTION_STATE callstate;
-	WINDOW_STATE talkingstate;
-	SPEAKER_STATE speakerstate;
-	HISTORY_TYPE historytype;
-	char starttime[24];
-	char startdate[24];
-	char lastnumber[MOKO_DIALER_MAX_NUMBER_LEN+1];
-}GLOBAL_STATE;
-
-typedef int (*TimeExpireCallback)();
-
-typedef struct _timerdata
-{
-	gint ptimer;
-	gint stopsec; ///<indicates when the ticks reaches stopsec, then this timer has to be stopped.
-	gint timeout; ///<indicates wether this timer has timeout to stopsec.
-
-	gint ticks; //seconds together
-	gint sec;   
-	gint min;
-	gint hour;
-	char timestring[MOKO_DIALER_MAX_TIME_STATUS_LEN+1] ;
-}TIMER_DATA;
-
-enum {
-	COLUMN_TYPE,
-	COLUMN_TYPEICON,
-	COLUMN_SEPRATE,
-	COLUMN_NAME_NUMBER,
-	COLUMN_TIME,
-	COLUMN_DURATION,
-	COLUMN_ENTRYPOINTER,
-	COLUMN_HASNAME,
-	N_COLUMN
-};
-void gsm_incoming_call(gchar * number);
-void gsm_peer_accept();
-void gsm_peer_abort();
-void gsm_peer_disconnect();
-void gsm_peer_refuse();
-#endif
+/* moko-dialer-includes.h
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_INCLUDES_H
+#define _MOKO_DIALER_INCLUDES_H
+
+
+#include "moko-dialer-declares.h"
+#include "error.h"
+#include "contacts.h"
+#include "history.h"
+#include "moko-dialer-autolist.h"
+#include "moko-dialer-panel.h"
+#include "moko-dialer-textview.h"
+#include "moko-digit-button.h"
+#include "moko-dialer-status.h"
+#include <libmokoui/moko-dialog-window.h>
+#include <time.h>
+#include <gtk/gtkliststore.h>
+//
+
+
+typedef enum _state
+{
+  STATE_NON = 0,
+  STATE_CALLING,
+  STATE_INCOMING,
+  STATE_TALKING,
+  STATE_FINISHED,
+  STATE_FAILED,
+  STATE_REJECTED,
+  STATE_TIMEOUT,
+  STATE_IGNORED,
+  STATE_MISSED
+} CONNECTION_STATE;
+typedef enum _windowstate
+{
+  WINDOWS_TALKING = 0,
+  WINDOWS_DTMF
+} WINDOW_STATE;
+typedef enum _speakerstate
+{
+  SPEAKER_ON = 0,
+  SPEAKER_OFF
+} SPEAKER_STATE;
+typedef enum _incomingstate
+{
+  NO_INCOMING_EVENT = 0,
+  HAS_INCOMING_EVENT
+} INCOMINGSTATE;
+typedef enum _clipstate
+{
+  NO_CLIP_EVENT = 0,
+  HAS_CLIP_EVENT
+} CLIPSTATE;
+
+typedef struct _globalstate
+{
+  CONNECTION_STATE callstate;
+  WINDOW_STATE talkingstate;
+  SPEAKER_STATE speakerstate;
+  HISTORY_TYPE historytype;
+  char starttime[24];
+  char startdate[24];
+  char lastnumber[MOKO_DIALER_MAX_NUMBER_LEN + 1];
+} GLOBAL_STATE;
+
+typedef int (*TimeExpireCallback) ();
+
+typedef struct _timerdata
+{
+  gint ptimer;
+  gint stopsec;                 ///<indicates when the ticks reaches stopsec, then this timer has to be stopped.
+  gint timeout;                 ///<indicates wether this timer has timeout to stopsec.
+
+  gint ticks;                   //seconds together
+  gint sec;
+  gint min;
+  gint hour;
+  char timestring[MOKO_DIALER_MAX_TIME_STATUS_LEN + 1];
+} TIMER_DATA;
+
+enum
+{
+  COLUMN_TYPE,
+  COLUMN_TYPEICON,
+  COLUMN_SEPRATE,
+  COLUMN_NAME_NUMBER,
+  COLUMN_TIME,
+  COLUMN_DURATION,
+  COLUMN_ENTRYPOINTER,
+  COLUMN_HASNAME,
+  N_COLUMN
+};
+void gsm_incoming_call (gchar * number);
+void gsm_peer_accept ();
+void gsm_peer_abort ();
+void gsm_peer_disconnect ();
+void gsm_peer_refuse ();
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,209 +1,218 @@
-/*  moko-dialer-pannel.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-#include "moko-dialer-panel.h"
-#include "error.h"
-G_DEFINE_TYPE (MokoDialerPanel, moko_dialer_panel, GTK_TYPE_VBOX)
-
-enum {
-  CLICKED_SIGNAL,
-  HOLD_SIGNAL,
-  LAST_SIGNAL
-};
-
-//forward definition
-static void  moko_dialer_panel_pressed  (MokoDigitButton * button, GdkEventButton  *event,gpointer data);
-//static void moko_dialer_panel_pressed (MokoDigitButton * button, gpointer data);
-
-static gint moko_dialer_panel_signals[LAST_SIGNAL] = { 0 };
-
-static void
-moko_dialer_panel_class_init (MokoDialerPanelClass *class)
-{
-/*
-  GtkVBoxClass* vbox_class;
-
-  vbox_class= (GtkVBoxClass*) class;
-*/
-
-  GtkObjectClass *object_class;
-
-  object_class = (GtkObjectClass*) class;
-  class->moko_dialer_panel_input = NULL;
-  class->moko_dialer_panel_hold= NULL;  
-
-g_print("moko_dialer_panel:start signal register\n");
-  
-  moko_dialer_panel_signals[CLICKED_SIGNAL] = 
-  		g_signal_new ("user_input",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerPanelClass, moko_dialer_panel_input),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__CHAR,
-		G_TYPE_NONE, 1,g_type_from_name("gchar"));
-
-  //                G_TYPE_NONE, 0);
-
-g_print("moko_dialer_panel:signal register end,got the id :%d\n", moko_dialer_panel_signals[CLICKED_SIGNAL]);
-
-  moko_dialer_panel_signals[HOLD_SIGNAL] = 
-  		g_signal_new ("user_hold",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerPanelClass, moko_dialer_panel_hold),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__CHAR,
-		G_TYPE_NONE, 1,g_type_from_name("gchar"));
-
-  //                G_TYPE_NONE, 0);
-
-g_print("moko_dialer_panel:signal register end,got the id :%d\n", moko_dialer_panel_signals[HOLD_SIGNAL]);
-
-}
-
-
-static void
-moko_dialer_panel_init (MokoDialerPanel *moko_dialer_panel)
-{
-DBG_ENTER();
-
- gchar* left[4][3]=
- 	{
- 	{"1","2","3"},
- 	{"4","5","6"},
-	{"7","8","9"},
-	{"*","0","#"} 	
- 	};
- 
-gchar* right[4][3]=
-{
-{"","ABC","DEF"},
-{"GHI","JKL","MNO"},
-{"PQRS","TUV","WXYZ"},
-{"+","p","w"}
-};
-
- gchar leftchar[4][3]=
- 	{
- 	{'1','2','3'},
- 	{'4','5','6'},
-	{'7','8','9'},
-	{'*','0','#'} 	
- 	};
-
-gchar rightchar[4][3]=
- 	{
- 	{-1,-1,-1},
- 	{-1,-1,-1},
- 	{-1,-1,-1},
-	{'+','p','w'} 	
- 	};	
-
- 
-  GtkWidget *table;
-  gint i,j;
-  
-  table = gtk_table_new (4, 3, TRUE);
-  gtk_container_add (GTK_CONTAINER(moko_dialer_panel), table);
-  gtk_widget_show (table);
-
-  
-
-  for (i=0;i<4; i++)
-    for (j=0;j<3; j++)
-      {
-      
-	moko_dialer_panel->buttons[i][j] = moko_digit_button_new_with_labels(left[i][j],right[i][j]);
-	
-	moko_digit_button_set_numbers(moko_dialer_panel->buttons[i][j], leftchar[i][j],rightchar[i][j]);
-
-	gtk_table_attach_defaults (GTK_TABLE(table), moko_dialer_panel->buttons[i][j], j, j+1, i, i+1);
-
-
-/*	g_signal_connect (GTK_OBJECT (moko_dialer_panel->buttons[i][j]), "clicked",
-			    G_CALLBACK (moko_dialer_panel_clicked),moko_dialer_panel);
-			    */
-
-      g_signal_connect ((gpointer) moko_dialer_panel->buttons[i][j], "button_release_event",
-                    G_CALLBACK (moko_dialer_panel_pressed),
-                    moko_dialer_panel);
-	  
-	gtk_widget_set_size_request (moko_dialer_panel->buttons[i][j], 20, 20);
-	gtk_widget_show (moko_dialer_panel->buttons[i][j]);
-      }
-    
-}
-
-
-
-static void  moko_dialer_panel_pressed  (MokoDigitButton * button, GdkEventButton  *event,gpointer data)
-{
-
-MokoDialerPanel *moko_dialer_panel;
-
-//here! check it tomorrow!
-moko_dialer_panel=(MokoDialerPanel *)data;
-
-gchar value=-1;
-
-if(event->button==3)
-  { //right button
-	  value=moko_digit_button_get_right( button);
-	  if(value==-1)
-	  	{//button 1-9 pressed with hold , we emit another signal: HOLD_SIGNAL, with the para of the number
-		  value=moko_digit_button_get_left( button);	  	
-		  if(value!=-1)
-		  	{
-			g_signal_emit (moko_dialer_panel,   moko_dialer_panel_signals[HOLD_SIGNAL],0,value);		  	
-		  	}
-	  	}
-	  else
-	  	{//*, 0, # buttons are right clicked or pressed with hold
-		      if(value!=-1)
-			g_signal_emit (moko_dialer_panel,   moko_dialer_panel_signals[CLICKED_SIGNAL],0,value);
-	  	
-	  	}
-
-  }
-else if(event->button==1)
-  {//left button
-	  value=moko_digit_button_get_left( button);
-      if(value!=-1)
-	g_signal_emit (moko_dialer_panel,   moko_dialer_panel_signals[CLICKED_SIGNAL],0,value);
-
-  }
-
-
-  return;
-}
-
-
-
-
-GtkWidget*      moko_dialer_panel_new()
-{
-DBG_ENTER();
-
-MokoDialerPanel * dp;
-
-dp=(MokoDialerPanel * )g_object_new (MOKO_TYPE_DIALER_PANEL, NULL);
-return GTK_WIDGET(dp);
-
-}
-
- 
+/*  moko-dialer-pannel.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-panel.h"
+#include "error.h"
+G_DEFINE_TYPE (MokoDialerPanel, moko_dialer_panel, GTK_TYPE_VBOX)
+     enum
+     {
+       CLICKED_SIGNAL,
+       HOLD_SIGNAL,
+       LAST_SIGNAL
+     };
+
+//forward definition
+     static void moko_dialer_panel_pressed (MokoDigitButton * button,
+                                            GdkEventButton * event,
+                                            gpointer data);
+//static void moko_dialer_panel_pressed (MokoDigitButton * button, gpointer data);
+
+     static gint moko_dialer_panel_signals[LAST_SIGNAL] = { 0 };
+
+static void
+moko_dialer_panel_class_init (MokoDialerPanelClass * class)
+{
+/*
+  GtkVBoxClass* vbox_class;
+
+  vbox_class= (GtkVBoxClass*) class;
+*/
+
+  GtkObjectClass *object_class;
+
+  object_class = (GtkObjectClass *) class;
+  class->moko_dialer_panel_input = NULL;
+  class->moko_dialer_panel_hold = NULL;
+
+  g_print ("moko_dialer_panel:start signal register\n");
+
+  moko_dialer_panel_signals[CLICKED_SIGNAL] =
+    g_signal_new ("user_input",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerPanelClass,
+                                   moko_dialer_panel_input), NULL, NULL,
+                  g_cclosure_marshal_VOID__CHAR, G_TYPE_NONE, 1,
+                  g_type_from_name ("gchar"));
+
+  //                G_TYPE_NONE, 0);
+
+  g_print ("moko_dialer_panel:signal register end,got the id :%d\n",
+           moko_dialer_panel_signals[CLICKED_SIGNAL]);
+
+  moko_dialer_panel_signals[HOLD_SIGNAL] =
+    g_signal_new ("user_hold",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerPanelClass,
+                                   moko_dialer_panel_hold), NULL, NULL,
+                  g_cclosure_marshal_VOID__CHAR, G_TYPE_NONE, 1,
+                  g_type_from_name ("gchar"));
+
+  //                G_TYPE_NONE, 0);
+
+  g_print ("moko_dialer_panel:signal register end,got the id :%d\n",
+           moko_dialer_panel_signals[HOLD_SIGNAL]);
+
+}
+
+
+static void
+moko_dialer_panel_init (MokoDialerPanel * moko_dialer_panel)
+{
+  DBG_ENTER ();
+
+  gchar *left[4][3] = {
+    {"1", "2", "3"},
+    {"4", "5", "6"},
+    {"7", "8", "9"},
+    {"*", "0", "#"}
+  };
+
+  gchar *right[4][3] = {
+    {"", "ABC", "DEF"},
+    {"GHI", "JKL", "MNO"},
+    {"PQRS", "TUV", "WXYZ"},
+    {"+", "p", "w"}
+  };
+
+  gchar leftchar[4][3] = {
+    {'1', '2', '3'},
+    {'4', '5', '6'},
+    {'7', '8', '9'},
+    {'*', '0', '#'}
+  };
+
+  gchar rightchar[4][3] = {
+    {-1, -1, -1},
+    {-1, -1, -1},
+    {-1, -1, -1},
+    {'+', 'p', 'w'}
+  };
+
+
+  GtkWidget *table;
+  gint i, j;
+
+  table = gtk_table_new (4, 3, TRUE);
+  gtk_container_add (GTK_CONTAINER (moko_dialer_panel), table);
+  gtk_widget_show (table);
+
+
+
+  for (i = 0; i < 4; i++)
+    for (j = 0; j < 3; j++)
+    {
+
+      moko_dialer_panel->buttons[i][j] =
+        moko_digit_button_new_with_labels (left[i][j], right[i][j]);
+
+      moko_digit_button_set_numbers (moko_dialer_panel->buttons[i][j],
+                                     leftchar[i][j], rightchar[i][j]);
+
+      gtk_table_attach_defaults (GTK_TABLE (table),
+                                 moko_dialer_panel->buttons[i][j], j, j + 1,
+                                 i, i + 1);
+
+
+/*	g_signal_connect (GTK_OBJECT (moko_dialer_panel->buttons[i][j]), "clicked",
+			    G_CALLBACK (moko_dialer_panel_clicked),moko_dialer_panel);
+			    */
+
+      g_signal_connect ((gpointer) moko_dialer_panel->buttons[i][j],
+                        "button_release_event",
+                        G_CALLBACK (moko_dialer_panel_pressed),
+                        moko_dialer_panel);
+
+      gtk_widget_set_size_request (moko_dialer_panel->buttons[i][j], 20, 20);
+      gtk_widget_show (moko_dialer_panel->buttons[i][j]);
+    }
+
+}
+
+
+
+static void
+moko_dialer_panel_pressed (MokoDigitButton * button, GdkEventButton * event,
+                           gpointer data)
+{
+
+  MokoDialerPanel *moko_dialer_panel;
+
+//here! check it tomorrow!
+  moko_dialer_panel = (MokoDialerPanel *) data;
+
+  gchar value = -1;
+
+  if (event->button == 3)
+  {                             //right button
+    value = moko_digit_button_get_right (button);
+    if (value == -1)
+    {                           //button 1-9 pressed with hold , we emit another signal: HOLD_SIGNAL, with the para of the number
+      value = moko_digit_button_get_left (button);
+      if (value != -1)
+      {
+        g_signal_emit (moko_dialer_panel,
+                       moko_dialer_panel_signals[HOLD_SIGNAL], 0, value);
+      }
+    }
+    else
+    {                           //*, 0, # buttons are right clicked or pressed with hold
+      if (value != -1)
+        g_signal_emit (moko_dialer_panel,
+                       moko_dialer_panel_signals[CLICKED_SIGNAL], 0, value);
+
+    }
+
+  }
+  else if (event->button == 1)
+  {                             //left button
+    value = moko_digit_button_get_left (button);
+    if (value != -1)
+      g_signal_emit (moko_dialer_panel,
+                     moko_dialer_panel_signals[CLICKED_SIGNAL], 0, value);
+
+  }
+
+
+  return;
+}
+
+
+
+
+GtkWidget *
+moko_dialer_panel_new ()
+{
+  DBG_ENTER ();
+
+  MokoDialerPanel *dp;
+
+  dp = (MokoDialerPanel *) g_object_new (MOKO_TYPE_DIALER_PANEL, NULL);
+  return GTK_WIDGET (dp);
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-panel.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,74 +1,69 @@
-/* moko-dialer-panel.h
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _MOKO_DIALER_PANEL_H_
-#define _MOKO_DIALER_PANEL_H_
-
-
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkvbox.h>
-#include "moko-digit-button.h"
-#include <glib-object.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-
-G_BEGIN_DECLS
-
-#define MOKO_TYPE_DIALER_PANEL                (moko_dialer_panel_get_type())
-#define MOKO_DIALER_PANEL (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_PANEL, MokoDialerPanel))
-#define MOKO_DIALER_PANEL_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_PANEL,MokoDialerPanelClass))
-#define MOKO_IS_DIALER_PANEL(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_PANEL))
-#define MOKO_IS_DIALER_PANEL_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_PANEL))
-#define MOKO_DIALER_PANEL_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_PANEL, MokoDialerPanelClass))
-
-
-
-typedef struct _MokoDialerPanelClass   MokoDialerPanelClass;
-
-typedef struct _MokoDialerPanel        MokoDialerPanel;
-struct _MokoDialerPanel
-{
-  GtkVBox vbox;
-  GtkWidget *buttons[4][3];
-};
-
-struct _MokoDialerPanelClass
-{
-  GtkVBoxClass parent_class;
-  void (* moko_dialer_panel_input) (MokoDialerPanel *moko_dialer_panel,gchar parac);
-  void (* moko_dialer_panel_hold) (MokoDialerPanel *moko_dialer_panel,gchar parac);
-};
-
-
-void	       moko_dialer_panel_clear           (MokoDialerPanel *moko_dialer_panel);
-
-GType          moko_dialer_panel_get_type         (void) ;
-
-GtkWidget*      moko_dialer_panel_new();
-
-
-
-
-
-G_END_DECLS
-
-#endif // 
-
-
+/* moko-dialer-panel.h
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_PANEL_H_
+#define _MOKO_DIALER_PANEL_H_
+
+
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkvbox.h>
+#include "moko-digit-button.h"
+#include <glib-object.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkobject.h>
+#include <gtk/gtksignal.h>
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIALER_PANEL                (moko_dialer_panel_get_type())
+#define MOKO_DIALER_PANEL (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_PANEL, MokoDialerPanel))
+#define MOKO_DIALER_PANEL_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_PANEL,MokoDialerPanelClass))
+#define MOKO_IS_DIALER_PANEL(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_PANEL))
+#define MOKO_IS_DIALER_PANEL_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_PANEL))
+#define MOKO_DIALER_PANEL_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_PANEL, MokoDialerPanelClass))
+typedef struct _MokoDialerPanelClass MokoDialerPanelClass;
+
+typedef struct _MokoDialerPanel MokoDialerPanel;
+struct _MokoDialerPanel
+{
+  GtkVBox vbox;
+  GtkWidget *buttons[4][3];
+};
+
+struct _MokoDialerPanelClass
+{
+  GtkVBoxClass parent_class;
+  void (*moko_dialer_panel_input) (MokoDialerPanel * moko_dialer_panel,
+                                   gchar parac);
+  void (*moko_dialer_panel_hold) (MokoDialerPanel * moko_dialer_panel,
+                                  gchar parac);
+};
+
+
+void moko_dialer_panel_clear (MokoDialerPanel * moko_dialer_panel);
+
+GType moko_dialer_panel_get_type (void);
+
+GtkWidget *moko_dialer_panel_new ();
+
+
+
+
+
+G_END_DECLS
+#endif //

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,203 +1,239 @@
-/* moko-dialer-autolist .c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
- #include "moko-dialer-status.h"
-  #include "error.h"
-#include "common.h" 
-G_DEFINE_TYPE (MokoDialerStatus, moko_dialer_status, GTK_TYPE_VBOX)
-
-
-static void
-moko_dialer_status_class_init (MokoDialerStatusClass *class)
-{
-/*
-  GtkVBoxClass* vbox_class;
-
-  vbox_class= (GtkVBoxClass*) class;
-*/
-
-  GtkObjectClass *object_class;
-
-  object_class = (GtkObjectClass*) class;
-
-
-}
-
-
-static void
-moko_dialer_status_init (MokoDialerStatus *moko_dialer_status)
-{
-DBG_ENTER();
-moko_dialer_status->imagePerson=0;
-
-//upper section
-; ///<the topmost title bar of the status
-moko_dialer_status->labelStatusTitle= gtk_label_new("");
-
-/*
-for(gint i=0;i<MOKO_DIALER_MAX_STATUS_ICONS;i++)
-	moko_dialer_status->iconStatus[i]=gtk_image_new();
-*/
-
-moko_dialer_status->icon=gtk_image_new();
-
-
-//lower section  
-	moko_dialer_status->imagePerson=gtk_image_new();  ///<the image of the person we care
-gtk_widget_set_size_request (moko_dialer_status->imagePerson, 130,130);
-  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->imagePerson), 1, 0);
-
-	
-	moko_dialer_status->labelStatus=gtk_label_new("");	///<the status label
-        	  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelStatus), 0, 0);
-//          	  gtk_misc_set_padding(GTK_MISC (moko_dialer_status->labelStatus), 20,0);
-	moko_dialer_status->labelPersonName=gtk_label_new(""); ///<the person name
-		  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelPersonName), 0, 0);
-	moko_dialer_status->labelNumber=gtk_label_new(""); ///<the number of the person
-		  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelNumber), 0, 0);
-//private section
-	moko_dialer_status->number_of_the_icons=0;
-
- gtk_widget_set_size_request (moko_dialer_status->icon, 64,64);
- gtk_box_pack_start( GTK_BOX(moko_dialer_status),	moko_dialer_status->labelStatusTitle , FALSE, FALSE, 20 );
- gtk_box_pack_start( GTK_BOX(moko_dialer_status),	moko_dialer_status->icon, FALSE, FALSE, 20);
- 
-//ok now, we arrange them in the vbox.
-
-// we create another vbox to hold the status labels.
-    GtkVBox *  vbox2 = gtk_vbox_new( FALSE, 0 );
-   gtk_box_pack_start( GTK_BOX(vbox2),	moko_dialer_status->labelStatus, TRUE, TRUE, 0);
-   
-   gtk_box_pack_start( GTK_BOX(vbox2),	moko_dialer_status->labelPersonName, TRUE, TRUE, 0 );
-
-
-    
-   gtk_box_pack_start( GTK_BOX(vbox2),	moko_dialer_status->labelNumber, TRUE, TRUE, 0 );
-// a hbox to hold the image and the vbox2
-    GtkVBox *  hbox2 = gtk_hbox_new( FALSE, 0 );
-
-
-    
-//   gtk_box_pack_start( GTK_BOX(hbox2),	moko_dialer_status->imagePerson, FALSE, FALSE, 0 );
-   gtk_box_pack_start( GTK_BOX(hbox2),	moko_dialer_status->imagePerson, TRUE,TRUE, 0 );
-
-// gtk_box_pack_start( GTK_BOX(hbox2),vbox2, FALSE, FALSE, 0 );
- gtk_box_pack_start( GTK_BOX(hbox2),vbox2, TRUE,TRUE, 36 );
-
-gtk_box_pack_start( GTK_BOX(moko_dialer_status),hbox2, TRUE, TRUE, 0 );
-
-//gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_status), 320, 200); 
-
-DBG_LEAVE();
-
-}
-
-GtkWidget*      moko_dialer_status_new()
-{
-DBG_ENTER();
-
-MokoDialerStatus * dp;
-
-dp=(MokoDialerStatus * )g_object_new (MOKO_TYPE_DIALER_STATUS, NULL);
-return GTK_WIDGET(dp);
-
-}
-
-void moko_dialer_status_set_title_label(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelStatusTitle),text);
-}
-void moko_dialer_status_set_status_label(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-
-//DBG_MESSAGE("moko_dialer_status_set_status_label:moko_dialer_status=0X%x",moko_dialer_status);
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelStatus),text);
-}
-
-void moko_dialer_status_set_person_name(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelPersonName),text);
-} 
-void moko_dialer_status_set_person_number(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelNumber),text);
-} 
-
-void moko_dialer_status_set_person_image(MokoDialerStatus *moko_dialer_status,const gchar* path)
-{
-//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
-file_load_person_image_from_relative_path(moko_dialer_status->imagePerson,path);
-//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
-} 
-int moko_dialer_status_add_status_icon(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-if(moko_dialer_status->number_of_the_icons<MOKO_DIALER_MAX_STATUS_ICONS)
-{
-	moko_dialer_status->iconStatus[moko_dialer_status->number_of_the_icons]=create_pixbuf (text);
-
-	moko_dialer_status->number_of_the_icons++;
-	return 1;
-}
-else
-{
-	DBG_ERROR("MOKO_DIALER_MAX_STATUS_ICONS has reached, add no more icons.");
-	return 0;
-}
-} 
-
-void moko_dialer_status_set_error_icon(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-
-	moko_dialer_status->iconError=create_pixbuf (text);
-//	file_load_person_image_from_relative_path(moko_dialer_status->iconError,text);
-} 
-void moko_dialer_status_set_success_icon(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-	moko_dialer_status->iconError=create_pixbuf (text);
-//	file_load_person_image_from_relative_path(moko_dialer_status->iconSuccuss,text);
-}
-
-void moko_dialer_status_set_icon_by_index(MokoDialerStatus *moko_dialer_status,gint index)
-{
-if( moko_dialer_status->iconStatus[index]!=0&&index<moko_dialer_status->number_of_the_icons)
-	gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconStatus[index]);
-}
-void moko_dialer_status_update_icon(MokoDialerStatus *moko_dialer_status)
-{
-static gint currenticon=0;
-currenticon=(currenticon+1)%moko_dialer_status->number_of_the_icons;
-if( moko_dialer_status->iconStatus[currenticon])
-	moko_dialer_status_set_icon_by_index(moko_dialer_status,currenticon);
-}
-	
-
-void moko_dialer_status_set_error(MokoDialerStatus *moko_dialer_status)
-{
-if(moko_dialer_status->iconError)
-	gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconError);
-moko_dialer_status_set_status_label(moko_dialer_status,"");
-}
-
-void moko_dialer_status_set_success(MokoDialerStatus *moko_dialer_status)
-{
-if(moko_dialer_status->iconSuccess)
-	gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconSuccess);
-
-}
-
+/* moko-dialer-autolist .c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include "moko-dialer-status.h"
+#include "error.h"
+#include "common.h"
+G_DEFINE_TYPE (MokoDialerStatus, moko_dialer_status, GTK_TYPE_VBOX)
+     static void moko_dialer_status_class_init (MokoDialerStatusClass * class)
+{
+/*
+  GtkVBoxClass* vbox_class;
+
+  vbox_class= (GtkVBoxClass*) class;
+*/
+
+  GtkObjectClass *object_class;
+
+  object_class = (GtkObjectClass *) class;
+
+
+}
+
+
+static void
+moko_dialer_status_init (MokoDialerStatus * moko_dialer_status)
+{
+  DBG_ENTER ();
+  moko_dialer_status->imagePerson = 0;
+
+//upper section
+  ;                             ///<the topmost title bar of the status
+  moko_dialer_status->labelStatusTitle = gtk_label_new ("");
+
+/*
+for(gint i=0;i<MOKO_DIALER_MAX_STATUS_ICONS;i++)
+	moko_dialer_status->iconStatus[i]=gtk_image_new();
+*/
+
+  moko_dialer_status->icon = gtk_image_new ();
+
+
+//lower section  
+  moko_dialer_status->imagePerson = gtk_image_new ();   ///<the image of the person we care
+  gtk_widget_set_size_request (moko_dialer_status->imagePerson, 130, 130);
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->imagePerson), 1, 0);
+
+
+  moko_dialer_status->labelStatus = gtk_label_new (""); ///<the status label
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelStatus), 0, 0);
+//                gtk_misc_set_padding(GTK_MISC (moko_dialer_status->labelStatus), 20,0);
+  moko_dialer_status->labelPersonName = gtk_label_new ("");     ///<the person name
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelPersonName), 0,
+                          0);
+  moko_dialer_status->labelNumber = gtk_label_new (""); ///<the number of the person
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelNumber), 0, 0);
+//private section
+  moko_dialer_status->number_of_the_icons = 0;
+
+  gtk_widget_set_size_request (moko_dialer_status->icon, 64, 64);
+  gtk_box_pack_start (GTK_BOX (moko_dialer_status),
+                      moko_dialer_status->labelStatusTitle, FALSE, FALSE, 20);
+  gtk_box_pack_start (GTK_BOX (moko_dialer_status), moko_dialer_status->icon,
+                      FALSE, FALSE, 20);
+
+//ok now, we arrange them in the vbox.
+
+// we create another vbox to hold the status labels.
+  GtkVBox *vbox2 = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelStatus, TRUE,
+                      TRUE, 0);
+
+  gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelPersonName,
+                      TRUE, TRUE, 0);
+
+
+
+  gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelNumber, TRUE,
+                      TRUE, 0);
+// a hbox to hold the image and the vbox2
+  GtkVBox *hbox2 = gtk_hbox_new (FALSE, 0);
+
+
+
+//   gtk_box_pack_start( GTK_BOX(hbox2),        moko_dialer_status->imagePerson, FALSE, FALSE, 0 );
+  gtk_box_pack_start (GTK_BOX (hbox2), moko_dialer_status->imagePerson, TRUE,
+                      TRUE, 0);
+
+// gtk_box_pack_start( GTK_BOX(hbox2),vbox2, FALSE, FALSE, 0 );
+  gtk_box_pack_start (GTK_BOX (hbox2), vbox2, TRUE, TRUE, 36);
+
+  gtk_box_pack_start (GTK_BOX (moko_dialer_status), hbox2, TRUE, TRUE, 0);
+
+//gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_status), 320, 200); 
+
+  DBG_LEAVE ();
+
+}
+
+GtkWidget *
+moko_dialer_status_new ()
+{
+  DBG_ENTER ();
+
+  MokoDialerStatus *dp;
+
+  dp = (MokoDialerStatus *) g_object_new (MOKO_TYPE_DIALER_STATUS, NULL);
+  return GTK_WIDGET (dp);
+
+}
+
+void
+moko_dialer_status_set_title_label (MokoDialerStatus * moko_dialer_status,
+                                    const gchar * text)
+{
+
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelStatusTitle), text);
+}
+
+void
+moko_dialer_status_set_status_label (MokoDialerStatus * moko_dialer_status,
+                                     const gchar * text)
+{
+
+//DBG_MESSAGE("moko_dialer_status_set_status_label:moko_dialer_status=0X%x",moko_dialer_status);
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelStatus), text);
+}
+
+void
+moko_dialer_status_set_person_name (MokoDialerStatus * moko_dialer_status,
+                                    const gchar * text)
+{
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelPersonName), text);
+}
+
+void
+moko_dialer_status_set_person_number (MokoDialerStatus * moko_dialer_status,
+                                      const gchar * text)
+{
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelNumber), text);
+}
+
+void
+moko_dialer_status_set_person_image (MokoDialerStatus * moko_dialer_status,
+                                     const gchar * path)
+{
+//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
+  file_load_person_image_from_relative_path (moko_dialer_status->imagePerson,
+                                             path);
+//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
+}
+
+int
+moko_dialer_status_add_status_icon (MokoDialerStatus * moko_dialer_status,
+                                    const gchar * text)
+{
+  if (moko_dialer_status->number_of_the_icons < MOKO_DIALER_MAX_STATUS_ICONS)
+  {
+    moko_dialer_status->iconStatus[moko_dialer_status->number_of_the_icons] =
+      create_pixbuf (text);
+
+    moko_dialer_status->number_of_the_icons++;
+    return 1;
+  }
+  else
+  {
+    DBG_ERROR
+      ("MOKO_DIALER_MAX_STATUS_ICONS has reached, add no more icons.");
+    return 0;
+  }
+}
+
+void
+moko_dialer_status_set_error_icon (MokoDialerStatus * moko_dialer_status,
+                                   const gchar * text)
+{
+  
moko_dialer_status->iconError = create_pixbuf (text);
+//      file_load_person_image_from_relative_path(moko_dialer_status->iconError,text);
+}
+
+void
+moko_dialer_status_set_success_icon (MokoDialerStatus * moko_dialer_status,
+                                     const gchar * text)
+{
+  moko_dialer_status->iconError = create_pixbuf (text);
+//      file_load_person_image_from_relative_path(moko_dialer_status->iconSuccuss,text);
+}
+
+void
+moko_dialer_status_set_icon_by_index (MokoDialerStatus * moko_dialer_status,
+                                      gint index)
+{
+  if (moko_dialer_status->iconStatus[index] != 0
+      && index < moko_dialer_status->number_of_the_icons)
+    gtk_image_set_from_pixbuf (moko_dialer_status->icon,
+                               moko_dialer_status->iconStatus[index]);
+}
+
+void
+moko_dialer_status_update_icon (MokoDialerStatus * moko_dialer_status)
+{
+  static gint currenticon = 0;
+  currenticon = (currenticon + 1) % moko_dialer_status->number_of_the_icons;
+  if (moko_dialer_status->iconStatus[currenticon])
+    moko_dialer_status_set_icon_by_index (moko_dialer_status, currenticon);
+}
+
+
+void
+moko_dialer_status_set_error (MokoDialerStatus * moko_dialer_status)
+{
+  if (moko_dialer_status->iconError)
+    gtk_image_set_from_pixbuf (moko_dialer_status->icon,
+                               moko_dialer_status->iconError);
+  moko_dialer_status_set_status_label (moko_dialer_status, "");
+}
+
+void
+moko_dialer_status_set_success (MokoDialerStatus * moko_dialer_status)
+{
+  if (moko_dialer_status->iconSuccess)
+    gtk_image_set_from_pixbuf (moko_dialer_status->icon,
+                               moko_dialer_status->iconSuccess);
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,97 +1,97 @@
-/* moko-dialer-status.h
- *  to display the person name, picuter,number. etc.
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _MOKO_DIALER_STATUS_H_
-#define _MOKO_DIALER_STATUS_H_
-
-
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkhbox.h>
-#include <glib-object.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtktextview.h>
-#include "moko-dialer-tip.h"
-#include "moko-dialer-declares.h"
-#include "contacts.h"
-
-//#include "moko-dialer-includes.h"
-
-G_BEGIN_DECLS
-
-
-
-#define MOKO_TYPE_DIALER_STATUS                (moko_dialer_status_get_type())
-#define MOKO_DIALER_STATUS (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatus))
-#define MOKO_DIALER_STATUS_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_STATUS,MokoDialerStatusClass))
-#define MOKO_IS_DIALER_STATUS(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_STATUS))
-#define MOKO_IS_DIALER_STATUS_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_STATUS))
-#define MOKO_DIALER_STATUS_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatusClass))
-
-
-
-typedef struct _MokoDialerStatusClass   MokoDialerStatusClass;
-
-typedef struct _MokoDialerStatus        MokoDialerStatus;
-struct _MokoDialerStatus
-{
-  GtkVBox vbox;
-//upper section
-  GtkWidget * labelStatusTitle; ///<the topmost title bar of the status
-  GtkWidget * icon;
-  GdkPixbuf * iconStatus[MOKO_DIALER_MAX_STATUS_ICONS];
-  GdkPixbuf * iconError;
-  GdkPixbuf * iconSuccess;
-//lower section  
-  GtkWidget * imagePerson;  ///<the image of the person we care
-  GtkWidget * labelStatus;	///<the status label
-  GtkWidget * labelPersonName; ///<the person name
-  GtkWidget * labelNumber; ///<the number of the person
-
-//private section
-  gint number_of_the_icons;
-  
-
-};
-
-struct _MokoDialerStatusClass
-{
-  GtkVBoxClass parent_class;
-};
-
-
-GType          moko_dialer_status_get_type         (void) ;
-
-GtkWidget*      moko_dialer_status_new();
-
-void moko_dialer_status_set_title_label(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_person_name(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_person_number(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_person_image(MokoDialerStatus *moko_dialer_status,const gchar* path);
-void moko_dialer_status_set_icons(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_status_label(MokoDialerStatus *moko_dialer_status,const gchar* text);
-
-G_END_DECLS
-
-#endif // 
-
-
-
-
+/* moko-dialer-status.h
+ *  to display the person name, picuter,number. etc.
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_STATUS_H_
+#define _MOKO_DIALER_STATUS_H_
+
+
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkhbox.h>
+#include <glib-object.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkobject.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtktextview.h>
+#include "moko-dialer-tip.h"
+#include "moko-dialer-declares.h"
+#include "contacts.h"
+
+//#include "moko-dialer-includes.h"
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIALER_STATUS                (moko_dialer_status_get_type())
+#define MOKO_DIALER_STATUS (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatus))
+#define MOKO_DIALER_STATUS_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_STATUS,MokoDialerStatusClass))
+#define MOKO_IS_DIALER_STATUS(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_STATUS))
+#define MOKO_IS_DIALER_STATUS_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_STATUS))
+#define MOKO_DIALER_STATUS_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatusClass))
+typedef struct _MokoDialerStatusClass MokoDialerStatusClass;
+
+typedef struct _MokoDialerStatus MokoDialerStatus;
+struct _MokoDialerStatus
+{
+  GtkVBox vbox;
+//upper section
+  GtkWidget *labelStatusTitle;  ///<the topmost title bar of the status
+  GtkWidget *icon;
+  GdkPixbuf *iconStatus[MOKO_DIALER_MAX_STATUS_ICONS];
+  GdkPixbuf *iconError;
+  GdkPixbuf *iconSuccess;
+//lower section  
+  GtkWidget *imagePerson;       ///<the image of the person we care
+  GtkWidget *labelStatus;       ///<the status label
+  GtkWidget *labelPersonName;   ///<the person name
+  GtkWidget *labelNumber;       ///<the number of the person
+
+//private section
+  gint number_of_the_icons;
+
+
+};
+
+struct _MokoDialerStatusClass
+{
+  GtkVBoxClass parent_class;
+};
+
+
+GType moko_dialer_status_get_type (void);
+
+GtkWidget *moko_dialer_status_new ();
+
+void moko_dialer_status_set_title_label (MokoDialerStatus *
+                                         moko_dialer_status,
+                                         const gchar * text);
+void moko_dialer_status_set_person_name (MokoDialerStatus *
+                                         moko_dialer_status,
+                                         const gchar * text);
+void moko_dialer_status_set_person_number (MokoDialerStatus *
+                                           moko_dialer_status,
+                                           const gchar * text);
+void moko_dialer_status_set_person_image (MokoDialerStatus *
+                                          moko_dialer_status,
+                                          const gchar * path);
+void moko_dialer_status_set_icons (MokoDialerStatus * moko_dialer_status,
+                                   const gchar * text);
+void moko_dialer_status_set_status_label (MokoDialerStatus *
+                                          moko_dialer_status,
+                                          const gchar * text);
+
+G_END_DECLS
+#endif //

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,463 +1,495 @@
-/*  moko-dialer-textview.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- 
- */
-
- #include "moko-dialer-textview.h"
- #include "moko-dialer-declares.h"
- #include "error.h"
-G_DEFINE_TYPE (MokoDialerTextview, moko_dialer_textview, GTK_TYPE_TEXT_VIEW)
-
-
-
-enum {
-  CLICKED_SIGNAL,
-  HOLD_SIGNAL,
-  LAST_SIGNAL
-};
-
-//forward definition
-//static void  moko_dialer_textview_pressed  (MokoDigitButton * button, GdkEventButton  *event,gpointer data);
-//static void moko_dialer_textview_pressed (MokoDigitButton * button, gpointer data);
-
-static gint moko_dialer_textview_signals[LAST_SIGNAL] = { 0 };
-
-static void
-moko_dialer_textview_class_init (MokoDialerTextviewClass *class)
-{
-
-  GtkObjectClass *object_class;
-
-  object_class = (GtkObjectClass*) class;
-
-
-}
-
-
-static void moko_dialer_textview_init (MokoDialerTextview *moko_dialer_textview)
-{
-
-			GtkTextView *textview=0;
-			GtkTextBuffer *buffer;
-			GdkColor color;
-
-			textview=&moko_dialer_textview->textview;
-			buffer = gtk_text_view_get_buffer (textview);	
-			moko_dialer_textview->font_desc_textview=NULL;
-			moko_dialer_textview->tag_for_inputed=NULL;
-			moko_dialer_textview->tag_for_cursor=NULL;
-			moko_dialer_textview->tag_for_autofilled=NULL;
-
-			gdk_color_parse("black",&color);
-//			gtk_widget_modify_bg(textview,GTK_STATE_NORMAL,&color);
-			gtk_widget_modify_base(textview,GTK_STATE_NORMAL,&color);
-			
-
-
-
-			  gtk_widget_set_size_request (GTK_WIDGET(textview), 480, 92);
-			  GTK_WIDGET_UNSET_FLAGS (textview, GTK_CAN_FOCUS);
-			  gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
-			  gtk_text_view_set_accepts_tab (GTK_TEXT_VIEW (textview), FALSE);
-			  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_CHAR);
-			  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE);
-			  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 1);
-			  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textview), 1);
-
-
-
-		PangoFontDescription * font_desc_textview=NULL;
-		font_desc_textview=pango_font_description_new();
-
-		//set the default font for the textview.
-		pango_font_description_set_size(font_desc_textview,32*PANGO_SCALE);
-
-		if(font_desc_textview)
-			{
-				gtk_widget_modify_font(GTK_WIDGET(moko_dialer_textview),font_desc_textview);
-				//save it to the structure for later usage.
-				moko_dialer_textview->font_desc_textview=font_desc_textview;
-			}
-		//create the formatting tag;
-		moko_dialer_textview->tag_for_inputed= gtk_text_buffer_create_tag (buffer, "tag_input","foreground", "#FF8000", NULL); 
-		moko_dialer_textview->tag_for_cursor=  gtk_text_buffer_create_tag (buffer, "tag_cursor","weight","PANGO_WEIGHT_BOLD",	NULL); 
-		moko_dialer_textview->tag_for_autofilled=  gtk_text_buffer_create_tag (buffer, "tag_filled","foreground", "#FFFF00", NULL); 
-		moko_dialer_textview->sensed=FALSE;
-    
-}
-
-
-GtkWidget*      moko_dialer_textview_new()
-{
-MokoDialerTextview * dp;
-
-dp=(MokoDialerTextview * )g_object_new (MOKO_TYPE_DIALER_TEXTVIEW, NULL);
-return GTK_WIDGET(dp);
-
-}
-
-/**
- * @brief moko_dialer_textview_set_color(MokoDialerTextview *moko_dialer_textview)
- *
- * set the text left to the cursor to black, and right to red.
- *
- * @param moko_dialer_textview the display area
- * @param len the char length,if it exceeds 13,then automatically decrease the size.
- * @return  void
- * @retval void
- */
-
-void moko_dialer_textview_set_color(MokoDialerTextview *moko_dialer_textview)
-{
-
-GtkTextBuffer *buffer;
-gint len;
-GtkTextIter start,cursoriter_1,cursoriter;
-GtkTextIter end;
-	
-//text_view= lookup_widget (GTK_WIDGET(button), "textview");
- /* Obtaining the buffer associated with the widget. */
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-
-gtk_text_buffer_get_iter_at_mark(buffer,
-		&cursoriter,gtk_text_buffer_get_insert(buffer));
-
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
-
- gint cur=gtk_text_iter_get_offset(&cursoriter);
-
-if(cur>0)
- {
-	 gtk_text_buffer_remove_all_tags(buffer,&start,&end);
-
-	 gtk_text_buffer_get_iter_at_offset(buffer,&cursoriter_1,cur-1);
-	 gtk_text_buffer_apply_tag(buffer, moko_dialer_textview->tag_for_inputed, &start, &cursoriter);	
- 	 gtk_text_buffer_apply_tag(buffer, moko_dialer_textview->tag_for_autofilled, &cursoriter, &end);	 
- 	 gtk_text_buffer_apply_tag(buffer, moko_dialer_textview->tag_for_cursor, &cursoriter_1, &cursoriter);	
-
- }	
- else
- {//cur==0
-	gtk_text_buffer_apply_tag (buffer, moko_dialer_textview->tag_for_autofilled, &cursoriter, &end);	 	 
- }
-
-	 
- len =gtk_text_buffer_get_char_count(buffer);
-  if(len>=12&&len<=64)
-  {
-  	if(moko_dialer_textview->font_desc_textview)
-	pango_font_description_set_size(moko_dialer_textview->font_desc_textview,32*PANGO_SCALE);
-  }
-  else if(len>=9&&len<12)
-  {  	if(moko_dialer_textview->font_desc_textview)
-	  pango_font_description_set_size(moko_dialer_textview->font_desc_textview,48*PANGO_SCALE);
-  }
-  else if(len>=0&&len<9)
-  {
-    	if(moko_dialer_textview->font_desc_textview)
-	  pango_font_description_set_size(moko_dialer_textview->font_desc_textview,64*PANGO_SCALE);
-  }
-  
-  gtk_widget_modify_font(GTK_WIDGET(moko_dialer_textview), moko_dialer_textview->font_desc_textview);  
-
-  gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(moko_dialer_textview),gtk_text_buffer_get_insert(buffer));
-  
-}
-
-
-
- /**
- * @brief moko_dialer_textview_insert  
- *
- * This function should be called upon the keypad is clicked in dialer window.
- *
- * @param button the button hit.
- * @param number the number to be added to the display.
- * @return  int
- * @retval 
- */
- 
- gint moko_dialer_textview_insert(MokoDialerTextview *moko_dialer_textview, const gchar* number)
-{
-
-gint len=0;
-
-GtkTextBuffer *buffer;
-GtkTextIter start;
-GtkTextIter end;
-GtkTextIter selectioniter,insertiter;
-GtkTextMark *selectmark,*insertmark;
-
-//DBG_MESSAGE("number=%s",number);
-
- /* Obtaining the buffer associated with the widget. */
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-	
-selectmark=gtk_text_buffer_get_selection_bound(buffer);
-insertmark=	gtk_text_buffer_get_insert(buffer);
-//get current cursor iterator
-gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-gtk_text_buffer_get_iter_at_mark(buffer,&selectioniter,selectmark);
-	//to see whether there is a selection range.
-if(gtk_text_iter_get_offset(&insertiter)!=gtk_text_iter_get_offset(&selectioniter))
-	{
-		//yes, first delete the range.
-	gtk_text_buffer_delete(buffer,&selectioniter,&insertiter);
-	insertmark=	gtk_text_buffer_get_insert(buffer);
-	gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-	}
-
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
-
-
-   len=gtk_text_buffer_get_char_count(buffer);
-  //len=strlen(codestring);
-	if(len>=0&&len<MOKO_DIALER_MAX_NUMBER_LEN)
-	{
-	
-	gtk_text_buffer_insert_at_cursor( buffer,number,strlen(number));
-	len=len+strlen(number);
-	}
-	else
-	{
-//	DBG_WARN("INPUT EXCEEDS %d,reset to null!",MAXDIALNUMBERLEN);
-	gtk_text_buffer_set_text (buffer,number, -1);
-	len=1;
-	}
-	//reget the cursor iter.
-	insertmark=	gtk_text_buffer_get_insert(buffer);
-//get current cursor iterator
-	gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-	//get the inputed string lengh.
-	len=gtk_text_iter_get_offset(&insertiter);
-//	DBG_MESSAGE("the current cursor offset is %d",len);
-
-/*
-	if(len>=MINSENSATIVELEN)
-	{//here we start to search the contacts.
-		rebuild_contact_view(text_view,1);		
-	}
-*/
-
-	moko_dialer_textview_set_color(moko_dialer_textview);
-	return len;
-}
-
-
-//get the input section of the textview 
-//if ALL=true, get whole text
-//else only get the inputed digits.
-gint  moko_dialer_textview_get_input(MokoDialerTextview *moko_dialer_textview,gchar* input,int ALL)
-{
-gchar* codestring;
-GtkTextBuffer *buffer;
-GtkTextIter start;
-GtkTextIter end;
-GtkTextIter insertiter;
-GtkTextMark *insertmark;
-	
-//DBG_ENTER();
-
-/* Obtaining the buffer associated with the widget. */
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-	
-//get current cursor iterator
-insertmark=	gtk_text_buffer_get_insert(buffer);
-gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-//get start & end iterator
-gtk_text_buffer_get_start_iter (buffer, &start);
-gtk_text_buffer_get_end_iter (buffer, &end);
-
-if(gtk_text_iter_get_offset(&insertiter)==gtk_text_iter_get_offset(&start))
-{
-	strcpy(input,"");
-	return 0;
-}
-// DBG_TRACE();
-if(ALL)
-	/* Get the entire buffer text. */
-	codestring = gtk_text_buffer_get_text (buffer, &start, &end,FALSE);
-else
-	codestring = gtk_text_buffer_get_text (buffer, &start, &insertiter, FALSE);
-//DBG_MESSAGE("%s",codestring);
-strcpy(input,codestring);
-// DBG_TRACE();
-g_free(codestring);
-return 1;
-}
-
-//delete all the input 
-int  moko_dialer_textview_empty(MokoDialerTextview *moko_dialer_textview)
-{
-GtkTextBuffer *buffer;
-
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-
-gtk_text_buffer_set_text(buffer,"",-1);
-return 1;
-}
-
-///delete the selection or one character.
-int  moko_dialer_textview_delete(MokoDialerTextview *moko_dialer_textview)
-{
-GtkTextBuffer *buffer;
-GtkTextIter selectioniter,insertiter;
-GtkTextMark *selectmark,*insertmark;
-gint len;
-
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-
-selectmark=gtk_text_buffer_get_selection_bound(buffer);
-insertmark=	gtk_text_buffer_get_insert(buffer);
-//get current cursor iterator
-gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-gtk_text_buffer_get_iter_at_mark(buffer,&selectioniter,selectmark);
-	//to see whether there is a selection range.
-	if(gtk_text_iter_get_offset(&insertiter)!=gtk_text_iter_get_offset(&selectioniter))
-	{
-		//yes, first delete the range.
-	gtk_text_buffer_delete(buffer,&selectioniter,&insertiter);
-	}
-	else
-	{
-		//no selection, then just perform backspace.
-	gtk_text_buffer_backspace(buffer,&insertiter,TRUE,TRUE);
-	}
-
-//now we get the inputed string length.	
-	insertmark=	gtk_text_buffer_get_insert(buffer);
-	//get current cursor iterator
-	gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-	len=gtk_text_iter_get_offset(&insertiter);
-
-	return 1;
-
-}
-
-//autofill the string to the inputed digits string on the textview
-
-int  moko_dialer_textview_fill_it(MokoDialerTextview *moko_dialer_textview,gchar* string)
-{
-
-
-GtkTextBuffer *buffer;
-GtkTextIter start;
-GtkTextIter end;
-GtkTextIter insertiter;
-GtkTextMark *insertmark;
-gint offset;
-gint offsetend;	
-gint offsetstart;	
-
-//DBG_ENTER();
-//DBG_MESSAGE("Sensative string:%s",string);
-
-/* Obtaining the buffer associated with the widget. */
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-
-//get current cursor iterator
-insertmark=	gtk_text_buffer_get_insert(buffer);
-gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-//get start & end iterator
-gtk_text_buffer_get_start_iter (buffer, &start);
-gtk_text_buffer_get_end_iter (buffer, &end);
-offsetend=gtk_text_iter_get_offset(&end);
-offset=gtk_text_iter_get_offset(&insertiter);
-//if startpos=endpos, that means we didn't input anything
-//so we just insert the text.
-
-offsetstart=gtk_text_iter_get_offset(&start);
-if(offsetend==offsetstart)
-{
-	
-	gtk_text_buffer_set_text(buffer,string,-1);
-	
-	gtk_text_buffer_get_start_iter (buffer, &start);
-	gtk_text_buffer_place_cursor(buffer,&start);
-	moko_dialer_textview_set_color(moko_dialer_textview);
-	moko_dialer_textview->sensed=TRUE;
-	//gtk_widget_grab_focus(text_view);
-	return 1;
-
-}
-
-/* Get the entire buffer text. */
-
-//codestring = gtk_text_buffer_get_text (buffer, &start, &insertiter, FALSE);
-
-gtk_text_buffer_delete(buffer,&insertiter,&end);
-
-
-//reget current cursor iterator
-insertmark=	gtk_text_buffer_get_insert(buffer);
-gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-
-//here we have to call the get sensentivestring to get "139" or something.
-//gtk_text_buffer_insert_with_tags_by_name(buffer,&insertiter,"139",3,tag_name);
-if(string!=0)
-{
-	if(strlen(string)>0)
-	{
-	gtk_text_buffer_insert( buffer,&insertiter,string,strlen(string));
-
-//reget current cursor iterator
-	insertmark=	gtk_text_buffer_get_insert(buffer);
-	gtk_text_buffer_get_iter_at_mark(buffer,&insertiter,insertmark);
-	gtk_text_iter_set_offset(&insertiter,offset);
-	//set the private data of sensed.
-	}
-}
-
-//setback the cursor position
-gtk_text_buffer_place_cursor(buffer,&insertiter);
-	
-moko_dialer_textview_set_color(moko_dialer_textview);
-
-//gtk_widget_grab_focus(text_view);
-//g_free (codestring );
-
-//DBG_LEAVE();
-return 1;
-}
-
-gint moko_dialer_textview_confirm_it(MokoDialerTextview *moko_dialer_textview,const gchar* string)
-{
-
-GtkTextBuffer *buffer;
-GtkTextIter end;
-
-buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
-
-
-gtk_text_buffer_set_text (buffer,string,-1);
-
-
-gtk_text_buffer_get_end_iter (buffer, &end);
-//set the cursor to the end of the buffer
-gtk_text_buffer_place_cursor(buffer,&end);
-
-moko_dialer_textview_set_color(moko_dialer_textview);
-//
-	
-return 1;
-
-}
-
- 
-
+/*  moko-dialer-textview.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ 
+ */
+
+#include "moko-dialer-textview.h"
+#include "moko-dialer-declares.h"
+#include "error.h"
+G_DEFINE_TYPE (MokoDialerTextview, moko_dialer_textview, GTK_TYPE_TEXT_VIEW)
+     enum
+     {
+       CLICKED_SIGNAL,
+       HOLD_SIGNAL,
+       LAST_SIGNAL
+     };
+
+//forward definition
+//static void  moko_dialer_textview_pressed  (MokoDigitButton * button, GdkEventButton  *event,gpointer data);
+//static void moko_dialer_textview_pressed (MokoDigitButton * button, gpointer data);
+
+     static gint moko_dialer_textview_signals[LAST_SIGNAL] = { 0 };
+
+static void
+moko_dialer_textview_class_init (MokoDialerTextviewClass * class)
+{
+
+  GtkObjectClass *object_class;
+
+  object_class = (GtkObjectClass *) class;
+
+
+}
+
+
+static void
+moko_dialer_textview_init (MokoDialerTextview * moko_dialer_textview)
+{
+
+  GtkTextView *textview = 0;
+  GtkTextBuffer *buffer;
+  GdkColor color;
+
+  textview = &moko_dialer_textview->textview;
+  buffer = gtk_text_view_get_buffer (textview);
+  moko_dialer_textview->font_desc_textview = NULL;
+  moko_dialer_textview->tag_for_inputed = NULL;
+  moko_dialer_textview->tag_for_cursor = NULL;
+  moko_dialer_textview->tag_for_autofilled = NULL;
+
+  gdk_color_parse ("black", &color);
+//                      gtk_widget_modify_bg(textview,GTK_STATE_NORMAL,&color);
+  gtk_widget_modify_base (textview, GTK_STATE_NORMAL, &color);
+
+
+
+
+  gtk_widget_set_size_request (GTK_WIDGET (textview), 480, 92);
+  GTK_WIDGET_UNSET_FLAGS (textview, GTK_CAN_FOCUS);
+  gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
+  gtk_text_view_set_accepts_tab (GTK_TEXT_VIEW (textview), FALSE);
+  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_CHAR);
+  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE);
+  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 1);
+  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textview), 1);
+
+
+
+  PangoFontDescription *font_desc_textview = NULL;
+  font_desc_textview = pango_font_description_new ();
+
+  // set the default font for the textview.
+  pango_font_description_set_size (font_desc_textview, 32 * PANGO_SCALE);
+
+  if (font_desc_textview)
+  {
+    gtk_widget_modify_font (GTK_WIDGET (moko_dialer_textview),
+                            font_desc_textview);
+    // save it to the structure for later usage.
+    moko_dialer_textview->font_desc_textview = font_desc_textview;
+  }
+  // create the formatting tag;
+  moko_dialer_textview->tag_for_inputed =
+    gtk_text_buffer_create_tag (buffer, "tag_input", "foreground", "#FF8000",
+                                NULL);
+  moko_dialer_textview->tag_for_cursor =
+    gtk_text_buffer_create_tag (buffer, "tag_cursor", "weight",
+                                "PANGO_WEIGHT_BOLD", NULL);
+  moko_dialer_textview->tag_for_autofilled =
+    gtk_text_buffer_create_tag (buffer, "tag_filled", "foreground", "#FFFF00",
+                                NULL);
+  moko_dialer_textview->sensed = FALSE;
+
+}
+
+
+GtkWidget *
+moko_dialer_textview_new ()
+{
+  MokoDialerTextview *dp;
+
+  dp = (MokoDialerTextview *) g_object_new (MOKO_TYPE_DIALER_TEXTVIEW, NULL);
+  return GTK_WIDGET (dp);
+
+}
+
+/**
+ * @brief moko_dialer_textview_set_color(MokoDialerTextview *moko_dialer_textview)
+ *
+ * set the text left to the cursor to black, and right to red.
+ *
+ * @param moko_dialer_textview the display area
+ * @param len the char length,if it exceeds 13,then automatically decrease the size.
+ * @return  void
+ * @retval void
+ */
+
+void
+moko_dialer_textview_set_color (MokoDialerTextview * moko_dialer_textview)
+{
+
+  GtkTextBuffer *buffer;
+  gint len;
+  GtkTextIter start, cursoriter_1, cursoriter;
+  GtkTextIter end;
+
+//text_view= lookup_widget (GTK_WIDGET(button), "textview");
+  /* Obtaining the buffer associated with the widget. */
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+  gtk_text_buffer_get_iter_at_mark (buffer,
+                                    &cursoriter,
+                                    gtk_text_buffer_get_insert (buffer));
+
+  gtk_text_buffer_get_start_iter (buffer, &start);
+  gtk_text_buffer_get_end_iter (buffer, &end);
+
+  gint cur = gtk_text_iter_get_offset (&cursoriter);
+
+  if (cur > 0)
+  {
+    gtk_text_buffer_remove_all_tags (buffer, &start, &end);
+
+    gtk_text_buffer_get_iter_at_offset (buffer, &cursoriter_1, cur - 1);
+    gtk_text_buffer_apply_tag (buffer, moko_dialer_textview->tag_for_inputed,
+                               &start, &cursoriter);
+    gtk_text_buffer_apply_tag (buffer,
+                               moko_dialer_textview->tag_for_autofilled,
+                               &cursoriter, &end);
+    gtk_text_buffer_apply_tag (buffer, moko_dialer_textview->tag_for_cursor,
+                               &cursoriter_1, &cursoriter);
+
+  }
+  else
+  {                             // cur==0
+    gtk_text_buffer_apply_tag (buffer,
+                               moko_dialer_textview->tag_for_autofilled,
+                               &cursoriter, &end);
+  }
+
+
+  len = gtk_text_buffer_get_char_count (buffer);
+  if (len >= 12 && len <= 64)
+  {
+    if (moko_dialer_textview->font_desc_textview)
+      pango_font_description_set_size (moko_dialer_textview->
+                                       font_desc_textview, 32 * PANGO_SCALE);
+  }
+  else if (len >= 9 && len < 12)
+  {
+    if (moko_dialer_textview->font_desc_textview)
+      pango_font_description_set_size (moko_dialer_textview->
+                                       font_desc_textview, 48 * PANGO_SCALE);
+  }
+  else if (len >= 0 && len < 9)
+  {
+    if (moko_dialer_textview->font_desc_textview)
+      pango_font_description_set_size (moko_dialer_textview->
+                                       font_desc_textview, 64 * PANGO_SCALE);
+  }
+
+  gtk_widget_modify_font (GTK_WIDGET (moko_dialer_textview),
+                          moko_dialer_textview->font_desc_textview);
+
+  gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW (moko_dialer_textview),
+                                      gtk_text_buffer_get_insert (buffer));
+
+}
+
+
+
+ /**
+ * @brief moko_dialer_textview_insert  
+ *
+ * This function should be called upon the keypad is clicked in dialer window.
+ *
+ * @param button the button hit.
+ * @param number the number to be added to the display.
+ * @return  int
+ * @retval 
+ */
+
+gint
+moko_dialer_textview_insert (MokoDialerTextview * moko_dialer_textview,
+                             const gchar * number)
+{
+
+  gint len = 0;
+
+  GtkTextBuffer *buffer;
+  GtkTextIter start;
+  GtkTextIter end;
+  GtkTextIter selectioniter, insertiter;
+  GtkTextMark *selectmark, *insertmark;
+
+//DBG_MESSAGE("number=%s",number);
+
+  /* Obtaining the buffer associated with the widget. */
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+  selectmark = gtk_text_buffer_get_selection_bound (buffer);
+  insertmark = gtk_text_buffer_get_insert (buffer);
+//get current cursor iterator
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+  gtk_text_buffer_get_iter_at_mark (buffer, &selectioniter, selectmark);
+  // to see whether there is a selection range.
+  if (gtk_text_iter_get_offset (&insertiter) !=
+      gtk_text_iter_get_offset (&selectioniter))
+  {
+    // yes, first delete the range.
+    gtk_text_buffer_delete (buffer, &selectioniter, &insertiter);
+    insertmark = gtk_text_buffer_get_insert (buffer);
+    gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+  }
+
+  gtk_text_buffer_get_start_iter (buffer, &start);
+  gtk_text_buffer_get_end_iter (buffer, &end);
+
+
+  len = gtk_text_buffer_get_char_count (buffer);
+  // len=strlen(codestring);
+  if (len >= 0 && len < MOKO_DIALER_MAX_NUMBER_LEN)
+  {
+
+    gtk_text_buffer_insert_at_cursor (buffer, number, strlen (number));
+    len = len + strlen (number);
+  }
+  else
+  {
+//      DBG_WARN("INPUT EXCEEDS %d,reset to null!",MAXDIALNUMBERLEN);
+    gtk_text_buffer_set_text (buffer, number, -1);
+    len = 1;
+  }
+  // reget the cursor iter.
+  insertmark = gtk_text_buffer_get_insert (buffer);
+//get current cursor iterator
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+  // get the inputed string lengh.
+  len = gtk_text_iter_get_offset (&insertiter);
+//      DBG_MESSAGE("the current cursor offset is %d",len);
+
+/*
+	if(len>=MINSENSATIVELEN)
+	{//here we start to search the contacts.
+		rebuild_contact_view(text_view,1);		
+	}
+*/
+
+  moko_dialer_textview_set_color (moko_dialer_textview);
+  return len;
+}
+
+
+//get the input section of the textview 
+//if ALL=true, get whole text
+//else only get the inputed digits.
+gint
+moko_dialer_textview_get_input (MokoDialerTextview * moko_dialer_textview,
+                                gchar * input, int ALL)
+{
+  gchar *codestring;
+  GtkTextBuffer *buffer;
+  GtkTextIter start;
+  GtkTextIter end;
+  GtkTextIter insertiter;
+  GtkTextMark *insertmark;
+
+//DBG_ENTER();
+
+/* Obtaining the buffer associated with the widget. */
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+//get current cursor iterator
+  insertmark = gtk_text_buffer_get_insert (buffer);
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+//get start & end iterator
+  gtk_text_buffer_get_start_iter (buffer, &start);
+  gtk_text_buffer_get_end_iter (buffer, &end);
+
+  if (gtk_text_iter_get_offset (&insertiter) ==
+      gtk_text_iter_get_offset (&start))
+  {
+    strcpy (input, "");
+    return 0;
+  }
+// DBG_TRACE();
+  if (ALL)
+    /* Get the entire buffer text. */
+    codestring = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+  else
+    codestring =
+      gtk_text_buffer_get_text (buffer, &start, &insertiter, FALSE);
+//DBG_MESSAGE("%s",codestring);
+  strcpy (input, codestring);
+// DBG_TRACE();
+  g_free (codestring);
+  return 1;
+}
+
+//delete all the input 
+int
+moko_dialer_textview_empty (MokoDialerTextview * moko_dialer_textview)
+{
+  GtkTextBuffer * buffer;
+
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+  gtk_text_buffer_set_text (buffer, "", -1);
+  return 1;
+}
+
+///delete the selection or one character.
+int
+moko_dialer_textview_delete (MokoDialerTextview * moko_dialer_textview)
+{
+  GtkTextBuffer *buffer;
+  GtkTextIter selectioniter, insertiter;
+  GtkTextMark *selectmark, *insertmark;
+  gint len;
+
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+  selectmark = gtk_text_buffer_get_selection_bound (buffer);
+  insertmark = gtk_text_buffer_get_insert (buffer);
+//get current cursor iterator
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+  gtk_text_buffer_get_iter_at_mark (buffer, &selectioniter, selectmark);
+  // to see whether there is a selection range.
+  if (gtk_text_iter_get_offset (&insertiter) !=
+      gtk_text_iter_get_offset (&selectioniter))
+  {
+    // yes, first delete the range.
+    gtk_text_buffer_delete (buffer, &selectioniter, &insertiter);
+  }
+  else
+  {
+    // no selection, then just perform backspace.
+    gtk_text_buffer_backspace (buffer, &insertiter, TRUE, TRUE);
+  }
+
+//now we get the inputed string length. 
+  insertmark = gtk_text_buffer_get_insert (buffer);
+  // get current cursor iterator
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+  len = gtk_text_iter_get_offset (&insertiter);
+
+  return 1;
+
+}
+
+//autofill the string to the inputed digits string on the textview
+
+int
+moko_dialer_textview_fill_it (MokoDialerTextview * moko_dialer_textview,
+                              gchar * string)
+{
+
+
+  GtkTextBuffer *buffer;
+  GtkTextIter start;
+  GtkTextIter end;
+  GtkTextIter insertiter;
+  GtkTextMark *insertmark;
+  gint offset;
+  gint offsetend;
+  gint offsetstart;
+
+//DBG_ENTER();
+//DBG_MESSAGE("Sensative string:%s",string);
+
+/* Obtaining the buffer associated with the widget. */
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+//get current cursor iterator
+  insertmark = gtk_text_buffer_get_insert (buffer);
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+//get start & end iterator
+  gtk_text_buffer_get_start_iter (buffer, &start);
+  gtk_text_buffer_get_end_iter (buffer, &end);
+  offsetend = gtk_text_iter_get_offset (&end);
+  offset = gtk_text_iter_get_offset (&insertiter);
+//if startpos=endpos, that means we didn't input anything
+//so we just insert the text.
+
+  offsetstart = gtk_text_iter_get_offset (&start);
+  if (offsetend == offsetstart)
+  {
+
+    gtk_text_buffer_set_text (buffer, string, -1);
+
+    gtk_text_buffer_get_start_iter (buffer, &start);
+    gtk_text_buffer_place_cursor (buffer, &start);
+    moko_dialer_textview_set_color (moko_dialer_textview);
+    moko_dialer_textview->sensed = TRUE;
+    // gtk_widget_grab_focus(text_view);
+    return 1;
+
+  }
+
+/* Get the entire buffer text. */
+
+//codestring = gtk_text_buffer_get_text (buffer, &start, &insertiter, FALSE);
+
+  gtk_text_buffer_delete (buffer, &insertiter, &end);
+
+
+//reget current cursor iterator
+  insertmark = gtk_text_buffer_get_insert (buffer);
+  gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+
+//here we have to call the get sensentivestring to get "139" or something.
+//gtk_text_buffer_insert_with_tags_by_name(buffer,&insertiter,"139",3,tag_name);
+  if (string != 0)
+  {
+    if (strlen (string) > 0)
+    {
+      gtk_text_buffer_insert (buffer, &insertiter, string, strlen (string));
+
+//reget current cursor iterator
+      insertmark = gtk_text_buffer_get_insert (buffer);
+      gtk_text_buffer_get_iter_at_mark (buffer, &insertiter, insertmark);
+      gtk_text_iter_set_offset (&insertiter, offset);
+      // set the private data of sensed.
+    }
+  }
+
+//setback the cursor position
+  gtk_text_buffer_place_cursor (buffer, &insertiter);
+
+  moko_dialer_textview_set_color (moko_dialer_textview);
+
+//gtk_widget_grab_focus(text_view);
+//g_free (codestring );
+
+//DBG_LEAVE();
+  return 1;
+}
+
+gint
+moko_dialer_textview_confirm_it (MokoDialerTextview * moko_dialer_textview,
+                                 const gchar * string)
+{
+
+  GtkTextBuffer *buffer;
+  GtkTextIter end;
+
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
+
+
+  gtk_text_buffer_set_text (buffer, string, -1);
+
+
+  gtk_text_buffer_get_end_iter (buffer, &end);
+//set the cursor to the end of the buffer
+  gtk_text_buffer_place_cursor (buffer, &end);
+
+  moko_dialer_textview_set_color (moko_dialer_textview);
+//
+
+  return 1;
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,76 +1,71 @@
-/* moko-dialer-textview.h
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _MOKO_DIALER_TEXTVIEW_H_
-#define _MOKO_DIALER_TEXTVIEW_H_
-
-
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkvbox.h>
-#include <glib-object.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtktextview.h>
-
-G_BEGIN_DECLS
-
-
-#define MOKO_TYPE_DIALER_TEXTVIEW                (moko_dialer_textview_get_type())
-#define MOKO_DIALER_TEXTVIEW (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_TEXTVIEW, MokoDialerTextview))
-#define MOKO_DIALER_TEXTVIEW_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_TEXTVIEW,MokoDialerTextviewClass))
-#define MOKO_IS_DIALER_TEXTVIEW(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_TEXTVIEW))
-#define MOKO_IS_DIALER_TEXTVIEW_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_TEXTVIEW))
-#define MOKO_DIALER_TEXTVIEW_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_TEXTVIEW, MokoDialerTextviewClass))
-
-typedef struct _MokoDialerTextviewClass   MokoDialerTextviewClass;
-
-typedef struct _MokoDialerTextview        MokoDialerTextview;
-
-struct _MokoDialerTextview
-{
-GtkTextView textview; ///<the main widget
-PangoFontDescription * font_desc_textview; ///< the font description of this textview
-GtkTextTag*  tag_for_inputed; ///<the formating tag for the digits user already inputed
-GtkTextTag*  tag_for_cursor; ///<the formatting tag  for the right digit user just inputed.
-GtkTextTag*  tag_for_autofilled;///<the formatting tag for the autofilled digits if any.
-gboolean  sensed;
-};
-
-struct _MokoDialerTextviewClass
-{
-  GtkTextViewClass parent_class;
-};
-
-
-GType          moko_dialer_textview_get_type         (void) ;
-
-GtkWidget*      moko_dialer_textview_new();
-
- int moko_dialer_textview_insert(MokoDialerTextview *moko_dialer_textview, const gchar* number);
-
-int  moko_dialer_textview_get_input(MokoDialerTextview *moko_dialer_textview,gchar* input,int ALL);
-int  moko_dialer_textview_empty(MokoDialerTextview *moko_dialer_textview);
-
-G_END_DECLS
-
-#endif // 
-
-
-
+/* moko-dialer-textview.h
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_TEXTVIEW_H_
+#define _MOKO_DIALER_TEXTVIEW_H_
+
+
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkvbox.h>
+#include <glib-object.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkobject.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtktextview.h>
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIALER_TEXTVIEW                (moko_dialer_textview_get_type())
+#define MOKO_DIALER_TEXTVIEW (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_TEXTVIEW, MokoDialerTextview))
+#define MOKO_DIALER_TEXTVIEW_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_TEXTVIEW,MokoDialerTextviewClass))
+#define MOKO_IS_DIALER_TEXTVIEW(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_TEXTVIEW))
+#define MOKO_IS_DIALER_TEXTVIEW_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_TEXTVIEW))
+#define MOKO_DIALER_TEXTVIEW_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_TEXTVIEW, MokoDialerTextviewClass))
+typedef struct _MokoDialerTextviewClass MokoDialerTextviewClass;
+
+typedef struct _MokoDialerTextview MokoDialerTextview;
+
+struct _MokoDialerTextview
+{
+  GtkTextView textview;         ///<the main widget
+  PangoFontDescription *font_desc_textview;     ///< the font description of this textview
+  GtkTextTag *tag_for_inputed;  ///<the formating tag for the digits user already inputed
+  GtkTextTag *tag_for_cursor;   ///<the formatting tag  for the right digit user just inputed.
+  GtkTextTag *tag_for_autofilled;       ///<the formatting tag for the autofilled digits if any.
+  gboolean sensed;
+};
+
+struct _MokoDialerTextviewClass
+{
+  GtkTextViewClass parent_class;
+};
+
+
+GType moko_dialer_textview_get_type (void);
+
+GtkWidget *moko_dialer_textview_new ();
+
+int moko_dialer_textview_insert (MokoDialerTextview * moko_dialer_textview,
+                                 const gchar * number);
+
+int moko_dialer_textview_get_input (MokoDialerTextview * moko_dialer_textview,
+                                    gchar * input, int ALL);
+int moko_dialer_textview_empty (MokoDialerTextview * moko_dialer_textview);
+
+G_END_DECLS
+#endif //

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,248 +1,260 @@
-/* moko-dialer-tip.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
- #include "moko-dialer-tip.h"
- #include "error.h"
-
-
-G_DEFINE_TYPE (MokoDialerTip, moko_dialer_tip, GTK_TYPE_EVENT_BOX)
-
-
-#define MOKO_DIALER_TIP_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_DIALER_TIP, MokoDialerTipPrivate))
-
-
-
-struct _MokoDialerTipPrivate
-{
-
-  GtkWidget * label; ///<the displaying label;
-  gint index; ///<the index of this tip widget
-  gboolean selected;///<is this tip currently selected?
-  
-};
-
-
-
-typedef struct _MokoDialerTipPrivate MokoDialerTipPrivate;
-
-GtkWidget*      moko_dialer_tip_new()
-{
-
-return moko_dialer_tip_new_with_label_and_index("",-1);
-}
-
-
-/**
- * @brief new a MokoDialerTip with the a string.
- * @param stringname  the name for the user;
- * @param index the index of this widget
- */
-GtkWidget*      moko_dialer_tip_new_with_label_and_index(const gchar * stringname,const gint index)
-{
-
-
-
- MokoDialerTip *  dialertip= ( MokoDialerTip * )g_object_new (MOKO_TYPE_DIALER_TIP, NULL);
-
-
- GdkColor  color;
- 
-
- MokoDialerTipPrivate* priv = ( MokoDialerTipPrivate*)MOKO_DIALER_TIP_GET_PRIVATE(dialertip);
-
- priv->index=index;
-
-GtkWidget*  label= gtk_label_new(stringname);
-
- priv->selected=FALSE;
-  
-  gtk_widget_show (label);
-
-
-  gtk_container_add (GTK_CONTAINER (dialertip), label);
-
-  GTK_WIDGET_SET_FLAGS (label, GTK_CAN_FOCUS);
-
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-
-//set the default color
-
- 	gdk_color_parse("orange",&color);
-	
-	gtk_label_set_line_wrap(GTK_LABEL(label),TRUE);
-	
-	gtk_widget_modify_fg(label,GTK_STATE_NORMAL,&color);
-	
-	gtk_label_set_pattern(GTK_LABEL(label),"___________________");
-
-
-
-	priv->label=label;
-
-// 	gdk_color_parse("black",&color);
-
-	gtk_widget_set_name(GTK_WIDGET(dialertip),"gtkeventbox-black");
-//	gtk_widget_modify_fg(GTK_WIDGET(dialertip),GTK_STATE_NORMAL,&color); 	
-//	gtk_widget_modify_bg(GTK_WIDGET(dialertip),GTK_STATE_NORMAL,&color); 	
-
-//	gtk_widget_hide(GTK_WIDGET(dialertip));
-	 return GTK_WIDGET(dialertip);
-
-}
-
-gboolean moko_dialer_tip_set_label(GtkWidget* widget,const gchar * stringname)
-{
-
-g_return_val_if_fail(MOKO_IS_DIALER_TIP(widget),FALSE);
-
- MokoDialerTipPrivate* priv = ( MokoDialerTipPrivate*)MOKO_DIALER_TIP_GET_PRIVATE(widget);
-
-g_return_val_if_fail(priv!=NULL,FALSE);
-
-gtk_label_set_text( GTK_LABEL(priv->label),stringname);
-
-gtk_label_set_pattern(GTK_LABEL(priv->label),"___________________");
-
-
-
-return TRUE;
-}
-
-gboolean moko_dialer_tip_set_index(GtkWidget* widget,const gint index)
-{
-
-g_return_val_if_fail(MOKO_IS_DIALER_TIP(widget),FALSE);
-
- MokoDialerTipPrivate* priv = ( MokoDialerTipPrivate*)MOKO_DIALER_TIP_GET_PRIVATE(widget);
-
-g_return_val_if_fail(priv!=NULL,FALSE);
-
-priv->index=index;
-return TRUE;
-}
-
-	
-static void
-moko_dialer_tip_class_init(MokoDialerTipClass *klass)
-{
-//g_print("moko_dialer_tip_class_init\n");
-
-// GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-//DBG_ENTER();
- g_type_class_add_private (klass, sizeof (MokoDialerTipPrivate));
-
-return;
-}
-
-/**
- * @brief  set the digit button digit field to be -1.
- */
-static void
-moko_dialer_tip_init(MokoDialerTip *self)
-{
-
-//DBG_ENTER();
-
-MokoDialerTipPrivate* priv = MOKO_DIALER_TIP_GET_PRIVATE(self);
-priv->label=0;
-priv->index=-1;
-priv->selected=FALSE;
-
-// gtk_widget_set_size_request (GTK_WIDGET(self), 64, 64);
-return;
-}
-
-gint moko_dialer_tip_get_index(MokoDialerTip* tip)
-{
-g_return_val_if_fail(MOKO_IS_DIALER_TIP(tip),-1);
-
- MokoDialerTipPrivate* priv = ( MokoDialerTipPrivate*)MOKO_DIALER_TIP_GET_PRIVATE(tip);
-
-g_return_val_if_fail(priv!=NULL,-1);
-
-
-return(priv->index);
-
-}
-
-gboolean moko_dialer_tip_set_selected(GtkWidget* tip,gboolean selected)
-{
-g_return_val_if_fail(MOKO_IS_DIALER_TIP(tip),FALSE);
-
- MokoDialerTipPrivate* priv = ( MokoDialerTipPrivate*)MOKO_DIALER_TIP_GET_PRIVATE(tip);
-
-g_return_val_if_fail(priv!=NULL,FALSE);
-
-GdkColor  colornormal,colorselected;
-
-priv->selected=selected;
-
-if(selected)
-{
-colorselected.red=255<<8;colorselected.green=255<<8;colorselected.blue=0;
-gtk_widget_modify_fg(priv->label,GTK_STATE_NORMAL,&colorselected);
-}
-else
-{
-gdk_color_parse("orange",&colornormal);
-gtk_widget_modify_fg(priv->label,GTK_STATE_NORMAL,&colornormal);
-
-}
-return TRUE;
-
-}
-
-gboolean  moko_dialer_tip_is_selected(GtkWidget* tip)
-{
-g_return_val_if_fail(MOKO_IS_DIALER_TIP(tip),FALSE);
-
- MokoDialerTipPrivate* priv = ( MokoDialerTipPrivate*)MOKO_DIALER_TIP_GET_PRIVATE(tip);
-
-g_return_val_if_fail(priv!=NULL,FALSE);
-
-return (priv->selected);
-}
-/*
-GType moko_dialer_tip_get_type(void)
-{
-    static GType self_type = 0;
-
-    if (!self_type)
-    {
-        static const GTypeInfo f_info =
-        {
-            sizeof (MokoDialerTipClass),
-            NULL, // base_init 
-            NULL, // base_finalize
-            (GClassInitFunc) moko_dialer_tip_class_init,
-            NULL, // class_finalize 
-            NULL, // class_data 
-            sizeof (MokoDialerTip),
-            0,
-            (GInstanceInitFunc) moko_dialer_tip_init,
-        };
-
-       // add the type of your parent class here 
-        self_type = g_type_register_static(GTK_TYPE_BUTTON, "MokoDialerTip", &f_info, 0);
-    }
-
-    return self_type;
-}
-
-*/
+/* moko-dialer-tip.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include "moko-dialer-tip.h"
+#include "error.h"
+
+
+G_DEFINE_TYPE (MokoDialerTip, moko_dialer_tip, GTK_TYPE_EVENT_BOX)
+#define MOKO_DIALER_TIP_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_DIALER_TIP, MokoDialerTipPrivate))
+     struct _MokoDialerTipPrivate
+     {
+
+       GtkWidget *label;        ///<the displaying label;
+       gint index;              ///<the index of this tip widget
+       gboolean selected;       ///<is this tip currently selected?
+
+     };
+
+
+
+     typedef struct _MokoDialerTipPrivate MokoDialerTipPrivate;
+
+     GtkWidget *moko_dialer_tip_new ()
+{
+
+  return moko_dialer_tip_new_with_label_and_index ("", -1);
+}
+
+
+/**
+ * @brief new a MokoDialerTip with the a string.
+ * @param stringname  the name for the user;
+ * @param index the index of this widget
+ */
+GtkWidget *
+moko_dialer_tip_new_with_label_and_index (const gchar * stringname,
+                                          const gint index)
+{
+
+
+
+  MokoDialerTip *dialertip =
+    (MokoDialerTip *) g_object_new (MOKO_TYPE_DIALER_TIP, NULL);
+
+
+  GdkColor color;
+
+
+  MokoDialerTipPrivate *priv =
+    (MokoDialerTipPrivate *) MOKO_DIALER_TIP_GET_PRIVATE (dialertip);
+
+  priv->index = index;
+
+  GtkWidget *label = gtk_label_new (stringname);
+
+  priv->selected = FALSE;
+
+  gtk_widget_show (label);
+
+
+  gtk_container_add (GTK_CONTAINER (dialertip), label);
+
+  GTK_WIDGET_SET_FLAGS (label, GTK_CAN_FOCUS);
+
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+
+//set the default color
+
+  gdk_color_parse ("orange", &color);
+
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+
+  gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &color);
+
+  gtk_label_set_pattern (GTK_LABEL (label), "___________________");
+
+
+
+  priv->label = label;
+
+//      gdk_color_parse("black",&color);
+
+  gtk_widget_set_name (GTK_WIDGET (dialertip), "gtkeventbox-black");
+//      gtk_widget_modify_fg(GTK_WIDGET(dialertip),GTK_STATE_NORMAL,&color);    
+//      gtk_widget_modify_bg(GTK_WIDGET(dialertip),GTK_STATE_NORMAL,&color);    
+
+//      gtk_widget_hide(GTK_WIDGET(dialertip));
+  return GTK_WIDGET (dialertip);
+
+}
+
+gboolean
+moko_dialer_tip_set_label (GtkWidget * widget, const gchar * stringname)
+{
+
+  g_return_val_if_fail (MOKO_IS_DIALER_TIP (widget), FALSE);
+
+  MokoDialerTipPrivate *priv =
+    (MokoDialerTipPrivate *) MOKO_DIALER_TIP_GET_PRIVATE (widget);
+
+  g_return_val_if_fail (priv != NULL, FALSE);
+
+  gtk_label_set_text (GTK_LABEL (priv->label), stringname);
+
+  gtk_label_set_pattern (GTK_LABEL (priv->label), "___________________");
+
+
+
+  return TRUE;
+}
+
+gboolean
+moko_dialer_tip_set_index (GtkWidget * widget, const gint index)
+{
+
+  g_return_val_if_fail (MOKO_IS_DIALER_TIP (widget), FALSE);
+
+  MokoDialerTipPrivate *priv =
+    (MokoDialerTipPrivate *) MOKO_DIALER_TIP_GET_PRIVATE (widget);
+
+  g_return_val_if_fail (priv != NULL, FALSE);
+
+  priv->index = index;
+  return TRUE;
+}
+
+
+static void
+moko_dialer_tip_class_init (MokoDialerTipClass * klass)
+{
+//g_print("moko_dialer_tip_class_init\n");
+
+// GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+//DBG_ENTER();
+  g_type_class_add_private (klass, sizeof (MokoDialerTipPrivate));
+
+  return;
+}
+
+/**
+ * @brief  set the digit button digit field to be -1.
+ */
+static void
+moko_dialer_tip_init (MokoDialerTip * self)
+{
+
+//DBG_ENTER();
+
+  MokoDialerTipPrivate *priv = MOKO_DIALER_TIP_GET_PRIVATE (self);
+  priv->label = 0;
+  priv->index = -1;
+  priv->selected = FALSE;
+
+// gtk_widget_set_size_request (GTK_WIDGET(self), 64, 64);
+  return;
+}
+
+gint
+moko_dialer_tip_get_index (MokoDialerTip * tip)
+{
+  g_return_val_if_fail (MOKO_IS_DIALER_TIP (tip), -1);
+
+  MokoDialerTipPrivate *priv =
+    (MokoDialerTipPrivate *) MOKO_DIALER_TIP_GET_PRIVATE (tip);
+
+  g_return_val_if_fail (priv != NULL, -1);
+
+
+  return (priv->index);
+
+}
+
+gboolean
+moko_dialer_tip_set_selected (GtkWidget * tip, gboolean selected)
+{
+  g_return_val_if_fail (MOKO_IS_DIALER_TIP (tip), FALSE);
+
+  MokoDialerTipPrivate *priv =
+    (MokoDialerTipPrivate *) MOKO_DIALER_TIP_GET_PRIVATE (tip);
+
+  g_return_val_if_fail (priv != NULL, FALSE);
+
+  GdkColor colornormal, colorselected;
+
+  priv->selected = selected;
+
+  if (selected)
+  {
+    colorselected.red = 255 << 8;
+    colorselected.green = 255 << 8;
+    colorselected.blue = 0;
+    gtk_widget_modify_fg (priv->label, GTK_STATE_NORMAL, &colorselected);
+  }
+  else
+  {
+    gdk_color_parse ("orange", &colornormal);
+    gtk_widget_modify_fg (priv->label, GTK_STATE_NORMAL, &colornormal);
+
+  }
+  return TRUE;
+
+}
+
+gboolean
+moko_dialer_tip_is_selected (GtkWidget * tip)
+{
+  g_return_val_if_fail (MOKO_IS_DIALER_TIP (tip), FALSE);
+
+  MokoDialerTipPrivate *priv =
+    (MokoDialerTipPrivate *) MOKO_DIALER_TIP_GET_PRIVATE (tip);
+
+  g_return_val_if_fail (priv != NULL, FALSE);
+
+  return (priv->selected);
+}
+
+/*
+GType moko_dialer_tip_get_type(void)
+{
+    static GType self_type = 0;
+
+    if (!self_type)
+    {
+        static const GTypeInfo f_info =
+        {
+            sizeof (MokoDialerTipClass),
+            NULL, // base_init 
+            NULL, // base_finalize
+            (GClassInitFunc) moko_dialer_tip_class_init,
+            NULL, // class_finalize 
+            NULL, // class_data 
+            sizeof (MokoDialerTip),
+            0,
+            (GInstanceInitFunc) moko_dialer_tip_init,
+        };
+
+       // add the type of your parent class here 
+        self_type = g_type_register_static(GTK_TYPE_BUTTON, "MokoDialerTip", &f_info, 0);
+    }
+
+    return self_type;
+}
+
+*/

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,81 +1,72 @@
-/* moko-dialer-tip.h
- *  MokoDialerTip, for the autofill feature, this widget shows the current hints for the end user.
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #ifndef _MOKO_DIALER_TIP_H_
-#define _MOKO_DIALER_TIP_H_
-
-
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkvbox.h>
-#include <glib-object.h>
-//#include <gtk/gtktable.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtklabel.h>
- #include <gtk/gtkeventbox.h>
-
-G_BEGIN_DECLS
-
-
-#define MOKO_TYPE_DIALER_TIP                (moko_dialer_tip_get_type())
-#define MOKO_DIALER_TIP (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_TIP, MokoDialerTip))
-#define MOKO_DIALER_TIP_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_TIP,MokoDialerTipClass))
-#define MOKO_IS_DIALER_TIP(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_TIP))
-#define MOKO_IS_DIALER_TIP_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_TIP))
-#define MOKO_DIALER_TIP_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_TIP, MokoDialerTipClass))
-
-
-
-typedef struct _MokoDialerTipClass   MokoDialerTipClass;
-
-typedef struct _MokoDialerTip        MokoDialerTip;
-
-struct _MokoDialerTip
-{
- GtkEventBox eventbox;
-};
-
-struct _MokoDialerTipClass
-{
-  GtkEventBoxClass parent_class;
-
-};
-
-
-GType          moko_dialer_tip_get_type         (void) ;
-
-GtkWidget*      moko_dialer_tip_new();
-
-GtkWidget*      moko_dialer_tip_new_with_label_and_index(const gchar * stringname,const gint index);
-
-gint moko_dialer_tip_get_index(MokoDialerTip* tip);
-gboolean moko_dialer_tip_set_label(GtkWidget* widget,const gchar * stringname);
-gboolean moko_dialer_tip_set_index(GtkWidget* widget,const gint index);
-
-gboolean  moko_dialer_tip_is_selected(GtkWidget* tip);
-
-gboolean moko_dialer_tip_set_selected(GtkWidget* tip,gboolean selected);
-G_END_DECLS
-
-#endif // 
-
-
-
-
-
+/* moko-dialer-tip.h
+ *  MokoDialerTip, for the autofill feature, this widget shows the current hints for the end user.
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#ifndef _MOKO_DIALER_TIP_H_
+#define _MOKO_DIALER_TIP_H_
+
+
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkvbox.h>
+#include <glib-object.h>
+//#include <gtk/gtktable.h>
+#include <gtk/gtkobject.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkeventbox.h>
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIALER_TIP                (moko_dialer_tip_get_type())
+#define MOKO_DIALER_TIP (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_TIP, MokoDialerTip))
+#define MOKO_DIALER_TIP_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_TIP,MokoDialerTipClass))
+#define MOKO_IS_DIALER_TIP(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_TIP))
+#define MOKO_IS_DIALER_TIP_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_TIP))
+#define MOKO_DIALER_TIP_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_TIP, MokoDialerTipClass))
+typedef struct _MokoDialerTipClass MokoDialerTipClass;
+
+typedef struct _MokoDialerTip MokoDialerTip;
+
+struct _MokoDialerTip
+{
+  GtkEventBox eventbox;
+};
+
+struct _MokoDialerTipClass
+{
+  GtkEventBoxClass parent_class;
+
+};
+
+
+GType moko_dialer_tip_get_type (void);
+
+GtkWidget *moko_dialer_tip_new ();
+
+GtkWidget *moko_dialer_tip_new_with_label_and_index (const gchar * stringname,
+                                                     const gint index);
+
+gint moko_dialer_tip_get_index (MokoDialerTip * tip);
+gboolean moko_dialer_tip_set_label (GtkWidget * widget,
+                                    const gchar * stringname);
+gboolean moko_dialer_tip_set_index (GtkWidget * widget, const gint index);
+
+gboolean moko_dialer_tip_is_selected (GtkWidget * tip);
+
+gboolean moko_dialer_tip_set_selected (GtkWidget * tip, gboolean selected);
+G_END_DECLS
+#endif //

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,193 +1,197 @@
-/*  moko-button-digit.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
-
-
-//#include "moko-application.h"
-
-#include "moko-digit-button.h"
-#include <gtk/gtkwindow.h>
-#include <gtk/gtk.h>
-#include <gtk/gtkbutton.h>
-
-
-G_DEFINE_TYPE (MokoDigitButton, moko_digit_button, GTK_TYPE_BUTTON)
-
-
-#define MOKO_DIGIT_BUTTON_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButtonPrivate))
-
-
-
-struct _MokoDigitButtonPrivate
-{
-
-  GtkWidget * labelDigit;
-  GtkWidget * labelAcrobat;
-  gchar leftclickdigit;
-  gchar rightclickdigit;
-  
-};
-
-
-
-typedef struct _MokoDigitButtonPrivate MokoDigitButtonPrivate;
-
-GtkWidget*      moko_digit_button_new()
-{
-
-//g_print("moko_digit_button_new\n");
-// return (GTK_WIDGET(g_object_new (MOKO_TYPE_DIGIT_BUTTON, NULL)));
-return moko_digit_button_new_with_labels("1","ABC");
-}
-
-
-/**
- * @brief new a MokoDigitButton with the 2 strings.
- * @param string_digit  the left digit part of the button. such as '1','2'...'0'
- * @param string_acrobat  the right acrobat part of the button, such as 'ABC' etc.
- */
-GtkWidget*      moko_digit_button_new_with_labels(const gchar * string_digit, const gchar * string_acrobat)
-{
-
-
- MokoDigitButton * digitbutton = ( MokoDigitButton * )g_object_new (MOKO_TYPE_DIGIT_BUTTON, NULL);
-
-  gtk_widget_show (GTK_WIDGET(digitbutton));
-  gtk_widget_set_size_request (digitbutton, 64, 64);
-
-//  GtkWidget * hbox = gtk_hbox_new (TRUE, 0);
-  GtkWidget * hbox = gtk_hbox_new (FALSE, 0);
-  gtk_widget_show (hbox);
-  gtk_container_add (GTK_CONTAINER (digitbutton), hbox);
-
-
-  GtkWidget * vbox = gtk_vbox_new (TRUE, 0);
-  gtk_widget_show (vbox);
-  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
-  GtkWidget* labelDigit = gtk_label_new (string_digit);
-  gtk_widget_show (labelDigit);
-  gtk_box_pack_start (GTK_BOX (vbox), labelDigit, TRUE, TRUE, 0);
-
-  GtkWidget* alignment = gtk_alignment_new (0, 1, 1, 0.3);
-  gtk_widget_show (alignment);
-  gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
-
-  GtkWidget * labelAcrobat = gtk_label_new (string_acrobat);
-  gtk_widget_show (labelAcrobat);
-  gtk_container_add (GTK_CONTAINER (alignment), labelAcrobat);
-  gtk_widget_set_size_request (labelAcrobat, 0, 0);
-  gtk_label_set_justify (GTK_LABEL (labelAcrobat), GTK_JUSTIFY_RIGHT);
-
-  gtk_widget_set_name( GTK_WIDGET(digitbutton), "mokofingerbutton-dialer" );
-
- MokoDigitButtonPrivate* priv = ( MokoDigitButtonPrivate*)MOKO_DIGIT_BUTTON_GET_PRIVATE(digitbutton);
-
- priv->labelDigit=labelDigit;
- priv->labelAcrobat=labelAcrobat;
-
-//g_print("moko_digit_button_new_with_labels:%s,%s\n",string_digit,string_acrobat);
-
- return GTK_WIDGET(digitbutton);
-
-}
-
-gboolean moko_digit_button_set_numbers(GtkWidget* widget,gchar left, gchar right)
-{
-
-g_return_val_if_fail(MOKO_IS_DIGIT_BUTTON(widget),FALSE);
- MokoDigitButtonPrivate* priv = ( MokoDigitButtonPrivate*)MOKO_DIGIT_BUTTON_GET_PRIVATE(widget);
-g_return_val_if_fail(priv!=NULL,FALSE);
-
- priv->leftclickdigit=left;
- priv->rightclickdigit=right;
-// g_print("moko_digit_button_set_numbers:%c,%d\n",left,right);
-return TRUE;
-}
-	
-static void
-moko_digit_button_class_init(MokoDigitButtonClass *klass)
-{
-//g_print("moko_digit_button_class_init\n");
-
-// GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (MokoDigitButtonPrivate));
-
-return;
-}
-
-/**
- * @brief  set the digit button digit field to be -1.
- */
-static void
-moko_digit_button_init(MokoDigitButton *self)
-{
-
- MokoDigitButtonPrivate* priv = MOKO_DIGIT_BUTTON_GET_PRIVATE(self);
- priv->labelDigit=0;
- priv->labelAcrobat=0;
- priv->leftclickdigit=-1;
- priv->rightclickdigit=-1;
-//g_print("moko_digit_button_init\n");
-return;
-}
-
-gchar moko_digit_button_get_left(MokoDigitButton* button)
-{
- MokoDigitButtonPrivate* priv = MOKO_DIGIT_BUTTON_GET_PRIVATE(button);
-// g_print("moko_digit_button_get_left:%c\n",priv->leftclickdigit);
-return(priv->leftclickdigit);
-
-}
-gchar moko_digit_button_get_right(MokoDigitButton* button)
-{
- MokoDigitButtonPrivate* priv = MOKO_DIGIT_BUTTON_GET_PRIVATE(button);
-// g_print("moko_digit_button_get_right:%c\n",priv->rightclickdigit);
-return(priv->rightclickdigit);
-
-}
-
-/*
-GType moko_digit_button_get_type(void)
-{
-    static GType self_type = 0;
-
-    if (!self_type)
-    {
-        static const GTypeInfo f_info =
-        {
-            sizeof (MokoDigitButtonClass),
-            NULL, // base_init 
-            NULL, // base_finalize
-            (GClassInitFunc) moko_digit_button_class_init,
-            NULL, // class_finalize 
-            NULL, // class_data 
-            sizeof (MokoDigitButton),
-            0,
-            (GInstanceInitFunc) moko_digit_button_init,
-        };
-
-       // add the type of your parent class here 
-        self_type = g_type_register_static(GTK_TYPE_BUTTON, "MokoDigitButton", &f_info, 0);
-    }
-
-    return self_type;
-}
-
-*/
+/*  moko-button-digit.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+
+
+//#include "moko-application.h"
+
+#include "moko-digit-button.h"
+#include <gtk/gtkwindow.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkbutton.h>
+
+
+G_DEFINE_TYPE (MokoDigitButton, moko_digit_button, GTK_TYPE_BUTTON)
+#define MOKO_DIGIT_BUTTON_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButtonPrivate))
+     struct _MokoDigitButtonPrivate
+     {
+
+       GtkWidget *labelDigit;
+       GtkWidget *labelAcrobat;
+       gchar leftclickdigit;
+       gchar rightclickdigit;
+
+     };
+
+
+
+     typedef struct _MokoDigitButtonPrivate MokoDigitButtonPrivate;
+
+     GtkWidget *moko_digit_button_new ()
+{
+
+//g_print("moko_digit_button_new\n");
+// return (GTK_WIDGET(g_object_new (MOKO_TYPE_DIGIT_BUTTON, NULL)));
+  return moko_digit_button_new_with_labels ("1", "ABC");
+}
+
+
+/**
+ * @brief new a MokoDigitButton with the 2 strings.
+ * @param string_digit  the left digit part of the button. such as '1','2'...'0'
+ * @param string_acrobat  the right acrobat part of the button, such as 'ABC' etc.
+ */
+GtkWidget *
+moko_digit_button_new_with_labels (const gchar * string_digit,
+                                   const gchar * string_acrobat)
+{
+
+
+  MokoDigitButton *digitbutton =
+    (MokoDigitButton *) g_object_new (MOKO_TYPE_DIGIT_BUTTON, NULL);
+
+  gtk_widget_show (GTK_WIDGET (digitbutton));
+  gtk_widget_set_size_request (digitbutton, 64, 64);
+
+//  GtkWidget * hbox = gtk_hbox_new (TRUE, 0);
+  GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox);
+  gtk_container_add (GTK_CONTAINER (digitbutton), hbox);
+
+
+  GtkWidget *vbox = gtk_vbox_new (TRUE, 0);
+  gtk_widget_show (vbox);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+  GtkWidget *labelDigit = gtk_label_new (string_digit);
+  gtk_widget_show (labelDigit);
+  gtk_box_pack_start (GTK_BOX (vbox), labelDigit, TRUE, TRUE, 0);
+
+  GtkWidget *alignment = gtk_alignment_new (0, 1, 1, 0.3);
+  gtk_widget_show (alignment);
+  gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
+
+  GtkWidget *labelAcrobat = gtk_label_new (string_acrobat);
+  gtk_widget_show (labelAcrobat);
+  gtk_container_add (GTK_CONTAINER (alignment), labelAcrobat);
+  gtk_widget_set_size_request (labelAcrobat, 0, 0);
+  gtk_label_set_justify (GTK_LABEL (labelAcrobat), GTK_JUSTIFY_RIGHT);
+
+  gtk_widget_set_name (GTK_WIDGET (digitbutton), "mokofingerbutton-dialer");
+
+  MokoDigitButtonPrivate *priv =
+    (MokoDigitButtonPrivate *) MOKO_DIGIT_BUTTON_GET_PRIVATE (digitbutton);
+
+  priv->labelDigit = labelDigit;
+  priv->labelAcrobat = labelAcrobat;
+
+//g_print("moko_digit_button_new_with_labels:%s,%s\n",string_digit,string_acrobat);
+
+  return GTK_WIDGET (digitbutton);
+
+}
+
+gboolean
+moko_digit_button_set_numbers (GtkWidget * widget, gchar left, gchar right)
+{
+
+  g_return_val_if_fail (MOKO_IS_DIGIT_BUTTON (widget), FALSE);
+  MokoDigitButtonPrivate *priv =
+    (MokoDigitButtonPrivate *) MOKO_DIGIT_BUTTON_GET_PRIVATE (widget);
+  g_return_val_if_fail (priv != NULL, FALSE);
+
+  priv->leftclickdigit = left;
+  priv->rightclickdigit = right;
+// g_print("moko_digit_button_set_numbers:%c,%d\n",left,right);
+  return TRUE;
+}
+
+static void
+moko_digit_button_class_init (MokoDigitButtonClass * klass)
+{
+//g_print("moko_digit_button_class_init\n");
+
+// GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (MokoDigitButtonPrivate));
+
+  return;
+}
+
+/**
+ * @brief  set the digit button digit field to be -1.
+ */
+static void
+moko_digit_button_init (MokoDigitButton * self)
+{
+
+  MokoDigitButtonPrivate *priv = MOKO_DIGIT_BUTTON_GET_PRIVATE (self);
+  priv->labelDigit = 0;
+  priv->labelAcrobat = 0;
+  priv->leftclickdigit = -1;
+  priv->rightclickdigit = -1;
+//g_print("moko_digit_button_init\n");
+  return;
+}
+
+gchar
+moko_digit_button_get_left (MokoDigitButton * button)
+{
+  MokoDigitButtonPrivate *priv = MOKO_DIGIT_BUTTON_GET_PRIVATE (button);
+// g_print("moko_digit_button_get_left:%c\n",priv->leftclickdigit);
+  return (priv->leftclickdigit);
+
+}
+
+gchar
+moko_digit_button_get_right (MokoDigitButton * button)
+{
+  MokoDigitButtonPrivate *priv = MOKO_DIGIT_BUTTON_GET_PRIVATE (button);
+// g_print("moko_digit_button_get_right:%c\n",priv->rightclickdigit);
+  return (priv->rightclickdigit);
+
+}
+
+/*
+GType moko_digit_button_get_type(void)
+{
+    static GType self_type = 0;
+
+    if (!self_type)
+    {
+        static const GTypeInfo f_info =
+        {
+            sizeof (MokoDigitButtonClass),
+            NULL, // base_init 
+            NULL, // base_finalize
+            (GClassInitFunc) moko_digit_button_class_init,
+            NULL, // class_finalize 
+            NULL, // class_data 
+            sizeof (MokoDigitButton),
+            0,
+            (GInstanceInitFunc) moko_digit_button_init,
+        };
+
+       // add the type of your parent class here 
+        self_type = g_type_register_static(GTK_TYPE_BUTTON, "MokoDigitButton", &f_info, 0);
+    }
+
+    return self_type;
+}
+
+*/

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,68 +1,62 @@
-/*  moko-button-digit.h
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
-#ifndef _MOKO_DIGIT_BUTTON_H_
-#define _MOKO_DIGIT_BUTTON_H_
-
-#include <gtk/gtkbutton.h>
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-
-#define MOKO_TYPE_DIGIT_BUTTON                 (moko_digit_button_get_type())
-#define MOKO_DIGIT_BUTTON(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButton))
-#define MOKO_DIGIT_BUTTON_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButtonClass))
-#define MOKO_IS_DIGIT_BUTTON(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIGIT_BUTTON))
-#define MOKO_IS_DIGIT_BUTTON_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIGIT_BUTTON))
-#define MOKO_DIGIT_BUTTON_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButtonClass))
-
-
-
-typedef struct _MokoDigitButtonClass   MokoDigitButtonClass;
-
-typedef struct _MokoDigitButton        MokoDigitButton;
-struct _MokoDigitButton
-{
-  GtkButton gtkbutton;
-};
-
-struct _MokoDigitButtonClass
-{
-  GtkButtonClass        parent_class;
-};
-
-
-GType          moko_digit_button_get_type         (void) ;
-
-gboolean moko_digit_button_set_numbers(GtkWidget* widget,gchar left, gchar right);
-	
-GtkWidget*      moko_digit_button_new_with_labels(const gchar * label1, const gchar * label2);
-
-GtkWidget*      moko_digit_button_new();
-
-gchar moko_digit_button_get_right(MokoDigitButton* button);
-
-gchar moko_digit_button_get_left(MokoDigitButton* button);
-
-G_END_DECLS
-
-#endif // _MOKO_FINGER_WHEEL_H_
-
-
+/*  moko-button-digit.h
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#ifndef _MOKO_DIGIT_BUTTON_H_
+#define _MOKO_DIGIT_BUTTON_H_
+
+#include <gtk/gtkbutton.h>
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIGIT_BUTTON                 (moko_digit_button_get_type())
+#define MOKO_DIGIT_BUTTON(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButton))
+#define MOKO_DIGIT_BUTTON_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButtonClass))
+#define MOKO_IS_DIGIT_BUTTON(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIGIT_BUTTON))
+#define MOKO_IS_DIGIT_BUTTON_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIGIT_BUTTON))
+#define MOKO_DIGIT_BUTTON_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIGIT_BUTTON, MokoDigitButtonClass))
+typedef struct _MokoDigitButtonClass MokoDigitButtonClass;
+
+typedef struct _MokoDigitButton MokoDigitButton;
+struct _MokoDigitButton
+{
+  GtkButton gtkbutton;
+};
+
+struct _MokoDigitButtonClass
+{
+  GtkButtonClass parent_class;
+};
+
+
+GType moko_digit_button_get_type (void);
+
+gboolean moko_digit_button_set_numbers (GtkWidget * widget, gchar left,
+                                        gchar right);
+
+GtkWidget *moko_digit_button_new_with_labels (const gchar * label1,
+                                              const gchar * label2);
+
+GtkWidget *moko_digit_button_new ();
+
+gchar moko_digit_button_get_right (MokoDigitButton * button);
+
+gchar moko_digit_button_get_left (MokoDigitButton * button);
+
+G_END_DECLS
+#endif // _MOKO_FINGER_WHEEL_H_

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -36,131 +36,143 @@
 #include "openmoko-dialer-window-dialer.h"
 #include "openmoko-dialer-window-outgoing.h"
 #include "openmoko-dialer-window-incoming.h"
-MOKO_DIALER_APP_DATA* p_dialer_data=0;
-MOKO_DIALER_APP_DATA*  moko_get_app_data()
+MOKO_DIALER_APP_DATA *p_dialer_data = 0;
+MOKO_DIALER_APP_DATA *
+moko_get_app_data ()
 {
-return p_dialer_data;
+  return p_dialer_data;
 }
 
-void gsm_incoming_call(gchar * number)
+void
+gsm_incoming_call (gchar * number)
 {
 
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
 
-if(appdata)
-{
+  if (appdata)
+  {
 //first, we should remove the "" from the number.
-char temp[20];
-int start=0;
-int end=strlen(number);
-while(number[start]=='\"'&&start<end)start++;
-if(end>1)while(number[end-1]=='\"'&&start<end)end--;
+    char temp[20];
+    int start = 0;
+    int end = strlen (number);
+    while (number[start] == '\"' && start < end)
+      start++;
+    if (end > 1)
+      while (number[end - 1] == '\"' && start < end)
+        end--;
 
-DBG_MESSAGE("START=%d,END=%d",start,end);
-strcpy(temp,number+start);
-temp[end-1]=0;
-DBG_MESSAGE("%s",temp);	
+    DBG_MESSAGE ("START=%d,END=%d", start, end);
+    strcpy (temp, number + start);
+    temp[end - 1] = 0;
+    DBG_MESSAGE ("%s", temp);
 
 
 
 //got the number;
-strcpy(appdata->g_peer_info.number,temp);
+    strcpy (appdata->g_peer_info.number, temp);
 
 //retrieve the contact information if any.
-contact_get_peer_info_from_number(appdata->g_contactlist.contacts , &(appdata->g_peer_info));
+    contact_get_peer_info_from_number (appdata->g_contactlist.contacts,
+                                       &(appdata->g_peer_info));
 // contact_get_peer_info_from_number
 
 
 //transfer the contact info
-window_incoming_prepare(appdata);
+    window_incoming_prepare (appdata);
 
-gtk_widget_show(appdata->window_incoming);
-}
-else
-{
-DBG_ERROR("gui failed to initialize.try another time.");
-}
+    gtk_widget_show (appdata->window_incoming);
+  }
+  else
+  {
+    DBG_ERROR ("gui failed to initialize.try another time.");
+  }
 
 
 }
 
-void gsm_peer_accept()
+void
+gsm_peer_accept ()
 {
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-DBG_ENTER();
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  DBG_ENTER ();
 //moko_dialer_status_update_icon(appdata->status_outgoing);
 
 
-appdata->g_state.callstate=STATE_TALKING;
+  appdata->g_state.callstate = STATE_TALKING;
 
-gtk_widget_hide(appdata->window_outgoing);
+  gtk_widget_hide (appdata->window_outgoing);
 
-if(!appdata->window_talking)
-	window_talking_init(appdata);
+  if (!appdata->window_talking)
+    window_talking_init (appdata);
 
 //transfer the contact info
-window_talking_prepare(appdata);
+  window_talking_prepare (appdata);
 
 //start talking.
 
-gtk_widget_show(appdata->window_talking);
+  gtk_widget_show (appdata->window_talking);
 
 
-DBG_LEAVE();
+  DBG_LEAVE ();
 }
 
-void gsm_peer_refuse()
+void
+gsm_peer_refuse ()
 {
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-window_outgoing_fails(appdata);
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  window_outgoing_fails (appdata);
 }
 
-void gsm_peer_abort()
+void
+gsm_peer_abort ()
 {
 
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-if(appdata->window_incoming)
-	gtk_widget_hide(appdata->window_incoming);
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  if (appdata->window_incoming)
+    gtk_widget_hide (appdata->window_incoming);
 
 
 }
 
-void gsm_peer_disconnect()
+void
+gsm_peer_disconnect ()
 {
 
-     MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-     gsm_hangup();
-     gtk_widget_hide(appdata->window_talking);
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  gsm_hangup ();
+  gtk_widget_hide (appdata->window_talking);
 
 }
-int main( int argc, char** argv )
+
+int
+main (int argc, char **argv)
 {
-    p_dialer_data=calloc(1,sizeof(MOKO_DIALER_APP_DATA));
-    /* Initialize GTK+ */
-    gtk_init( &argc, &argv );
+  p_dialer_data = calloc (1, sizeof (MOKO_DIALER_APP_DATA));
+  /* Initialize GTK+ */
+  gtk_init (&argc, &argv);
 
 
-    //init application data
-   contact_init_contact_data(&(p_dialer_data->g_contactlist));
-   history_init_history_data(&(p_dialer_data->g_historylist));
-   
+  //init application data
+  contact_init_contact_data (&(p_dialer_data->g_contactlist));
+  history_init_history_data (&(p_dialer_data->g_historylist));
 
-    /* application object */
+
+  /* application object */
 //    MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
-    g_set_application_name( "OpenMoko Dialer" );
+  g_set_application_name ("OpenMoko Dialer");
 
 
 //   gtk_main();
 
 
 
- GMainLoop* mainloop=0;
- mainloop = g_main_loop_new(NULL, FALSE );
- p_dialer_data->mainloop=mainloop;
+  GMainLoop *mainloop = 0;
+  mainloop = g_main_loop_new (NULL, FALSE);
+  p_dialer_data->mainloop = mainloop;
 
 
 //init the dialer window
-  window_dialer_init(p_dialer_data); 
+  window_dialer_init (p_dialer_data);
 //  window_incoming_init(p_dialer_data); 
 //  window_outgoing_init(p_dialer_data); 
 //  window_history_init(p_dialer_data); 
@@ -168,23 +180,23 @@
 
 
 //from now on we will not use multithreads.
-  gsm_lgsm_start(mainloop);
+  gsm_lgsm_start (mainloop);
   //start a timer to monitor incoming calls
   //gtk_timeout_add(100,incoming_calls,0);
- 
+
 //instead, we add a g_source
 
 
   //gdk_threads_enter();
   //gtk_main ();
   //gdk_threads_leave();
-  
+
 //  GMainLoop* mainloop = g_main_loop_new(NULL, FALSE );
-  
+
 //  [ set up a GSource ]
 //  [ add a GPollFD ]
 //  g_source_attach( gsource, NULL );
-  g_main_loop_run(mainloop);
+  g_main_loop_run (mainloop);
 
 
 
@@ -193,9 +205,8 @@
 
 
 //release everything    
-    contact_release_contact_list(&(p_dialer_data->g_contactlist)); 
+  contact_release_contact_list (&(p_dialer_data->g_contactlist));
 
-  history_release_history_list(&(p_dialer_data->g_historylist));
-    return 0;
+  history_release_history_list (&(p_dialer_data->g_historylist));
+  return 0;
 }
-

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -15,7 +15,7 @@
  *
  *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
  */
- #include "moko-dialer-includes.h"
+#include "moko-dialer-includes.h"
 /*
 
 typedef struct _window_outgoing
@@ -30,71 +30,69 @@
 GtkWidget* buttonRedial;
 }WindowOutgoing;
 */
- typedef struct _dialer_data
+typedef struct _dialer_data
 {
- //the global data area begins here
+  //the global data area begins here
 
- GMainLoop* mainloop;
+  GMainLoop *mainloop;
 
-MokoDialerTextview *moko_dialer_text_view; ///<the textview for the dialer window 
+  MokoDialerTextview *moko_dialer_text_view;    ///<the textview for the dialer window 
 
-MokoDialerTextview *moko_dtmf_text_view; ///<the textview for the dtmf window
+  MokoDialerTextview *moko_dtmf_text_view;      ///<the textview for the dtmf window
 
 
-MokoDialerAutolist *moko_dialer_autolist;
+  MokoDialerAutolist *moko_dialer_autolist;
 
-DIALER_CONTACTS_LIST_HEAD       g_contactlist; ///< the whole list of the contacts from the contact book.
+  DIALER_CONTACTS_LIST_HEAD g_contactlist;      ///< the whole list of the contacts from the contact book.
 
-DIALER_CONTACT_PEER_INFO g_peer_info; ///<hold the peer's name, number, etc.
+  DIALER_CONTACT_PEER_INFO g_peer_info; ///<hold the peer's name, number, etc.
 
-HISTORY_LIST_HEAD g_historylist; ///< the whole list of the talk history
-HISTORY_ENTRY * g_currentselected; ///<pointer to the history entry which in the GUI the user selects.
-GLOBAL_STATE g_state; ///< the global states holder. we count on it a lot.
+  HISTORY_LIST_HEAD g_historylist;      ///< the whole list of the talk history
+  HISTORY_ENTRY *g_currentselected;     ///<pointer to the history entry which in the GUI the user selects.
+  GLOBAL_STATE g_state;         ///< the global states holder. we count on it a lot.
 
 
-TIMER_DATA g_timer_data;///< the data used by the timers
+  TIMER_DATA g_timer_data;      ///< the data used by the timers
 
-MokoDialerStatus * status_outgoing;
-MokoDialerStatus * status_talking;
-MokoDialerStatus * status_incoming;
+  MokoDialerStatus *status_outgoing;
+  MokoDialerStatus *status_talking;
+  MokoDialerStatus *status_incoming;
 
-GtkWidget* window_incoming;
-GtkWidget* window_outgoing;
-GtkWidget* window_talking;
-GtkWidget * window_history;
-GtkWidget * window_dialer;
+  GtkWidget *window_incoming;
+  GtkWidget *window_outgoing;
+  GtkWidget *window_talking;
+  GtkWidget *window_history;
+  GtkWidget *window_dialer;
 
 //buttons
-GtkWidget* buttonSpeaker;
-GtkWidget* buttonCancel;
-GtkWidget* buttonRedial;
+  GtkWidget *buttonSpeaker;
+  GtkWidget *buttonCancel;
+  GtkWidget *buttonRedial;
 
-GtkWidget* imageTALK;
-GtkWidget* imageDTMF;
+  GtkWidget *imageTALK;
+  GtkWidget *imageDTMF;
 
-GtkWidget* content_talk;
-GtkWidget* content_dtmf;
+  GtkWidget *content_talk;
+  GtkWidget *content_dtmf;
 
 
-GtkWidget* wheel_talking;
-GtkWidget* toolbox_talking;
+  GtkWidget *wheel_talking;
+  GtkWidget *toolbox_talking;
 
 
-GtkWidget* wheel_history;
-GtkWidget* toolbox_history;
-GtkWidget* label_filter_history;
-GtkWidget* label_counter_history;
-GtkWidget* treeview_history;
-GtkWidget* menu_history;
+  GtkWidget *wheel_history;
+  GtkWidget *toolbox_history;
+  GtkWidget *label_filter_history;
+  GtkWidget *label_counter_history;
+  GtkWidget *treeview_history;
+  GtkWidget *menu_history;
 
-gboolean dtmf_in_talking_window;
-gboolean history_need_to_update;
+  gboolean dtmf_in_talking_window;
+  gboolean history_need_to_update;
 
- GtkListStore  *g_list_store_filter;///<the list store used by the gtktreeview, for displaying the history list dynamically.
+  GtkListStore *g_list_store_filter;    ///<the list store used by the gtktreeview, for displaying the history list dynamically.
 
- HISTORY_TYPE g_history_filter_type;///<indicates the current history filter type, the gtktreeview will be filtered on the value.
+  HISTORY_TYPE g_history_filter_type;   ///<indicates the current history filter type, the gtktreeview will be filtered on the value.
 
- GdkPixbuf * g_iconReceived,*g_iconMissed,*g_iconDialed;///<the global pixbuf for the 3 icons displayed in the history window.}DIALER_APP_DATA;
-}MOKO_DIALER_APP_DATA;
-
-
+  GdkPixbuf *g_iconReceived, *g_iconMissed, *g_iconDialed;      ///<the global pixbuf for the 3 icons displayed in the history window.}DIALER_APP_DATA;
+} MOKO_DIALER_APP_DATA;

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,397 +1,438 @@
-/*   openmoko-dialer-window-dialer.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
-#include <libmokoui/moko-finger-tool-box.h>
-#include <libmokoui/moko-finger-window.h>
-#include <libmokoui/moko-finger-wheel.h>
-#include <libmokoui/moko-pixmap-button.h>
-
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkvbox.h>
-#include "contacts.h"
-#include "openmoko-dialer-main.h"
-#include "openmoko-dialer-window-dialer.h"
-#include "openmoko-dialer-window-history.h"
-
-void cb_delete_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-g_debug( "delete button clicked" );
-
-if(moko_dialer_autolist_has_selected(appdata->moko_dialer_autolist))
-{
-//first of all, we un-select the selection.
-moko_dialer_autolist_set_select(appdata->moko_dialer_autolist,-1);
-
-//fill the textview with ""
-moko_dialer_textview_fill_it(appdata->moko_dialer_text_view,"");
-//moko_dialer_textview_set_color(moko_dialer_textview);
-}
-else
-{
-moko_dialer_textview_delete(appdata->moko_dialer_text_view);
-//refresh the autolist,but do not automaticall fill the textview
-char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
-moko_dialer_textview_get_input(appdata->moko_dialer_text_view,codesinput, 0);
-
-if(strlen(codesinput)>=MOKO_DIALER_MIN_SENSATIVE_LEN)
-{
-moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,codesinput,FALSE);
-moko_dialer_textview_set_color(appdata->moko_dialer_text_view);
-}
-else
-	moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
-
-
-}
-
-}
-
-void cb_history_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-if(!appdata->window_history)
-	window_history_init(appdata);
-
-//start dialling.
-gtk_widget_show(appdata->window_history);
-
-}
-
-void window_dialer_dial_out(MOKO_DIALER_APP_DATA * appdata)
-{
-gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
- //get the input digits
- moko_dialer_textview_get_input(appdata->moko_dialer_text_view, codesinput, 0);
-if(strlen(codesinput)<1)
-{
-	if(strlen(appdata->g_state.lastnumber)>0)
-	{
-	moko_dialer_textview_insert(appdata->moko_dialer_text_view,appdata->g_state.lastnumber);
-	moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,appdata->g_state.lastnumber,TRUE);
-	}
-	//user didn't input anything, maybe it's a redial
-	
-	return;
-}
-//empty the textview
-moko_dialer_textview_empty(appdata->moko_dialer_text_view);
-
-//and we set the selected autolist to be No
-moko_dialer_autolist_set_select(appdata->moko_dialer_autolist,-1);
-moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
-
-//got the number;
-strcpy(appdata->g_peer_info.number,codesinput);
-
-//retrieve the contact information if any.
-contact_get_peer_info_from_number(appdata->g_contactlist.contacts , &(appdata->g_peer_info));
-// contact_get_peer_info_from_number
-
-/*
-if(!appdata->window_outgoing)
-	window_incoming_init(appdata);
-
-//transfer the contact info
-window_incoming_prepare(appdata);
-
-//start dialling.
-gtk_widget_show(appdata->window_incoming);
-*/
-
-//transfer the contact info
-window_outgoing_prepare(appdata);
-
-//start dialling.
-gtk_widget_show(appdata->window_outgoing);
-
-
-
-}
-
-void cb_dialer_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-window_dialer_dial_out(appdata);
-}
-
-
-
-void
-on_dialer_autolist_user_selected(GtkWidget * widget,gpointer para_pointer,
-                                        gpointer         user_data)
-{
-gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
-gint lenstring=0;
-gint leninput=0;
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-MokoDialerTextview *moko_dialer_text_view=appdata->moko_dialer_text_view;
-DIALER_READY_CONTACT * ready_contact=(DIALER_READY_CONTACT * )para_pointer;
-DBG_MESSAGE("GOT THE MESSAGE OF SELECTED:%s",ready_contact->p_entry->content);
-moko_dialer_textview_get_input(moko_dialer_text_view,codesinput, 0);
-lenstring=strlen(ready_contact->p_entry->content);
-leninput=strlen(codesinput);
-if(lenstring>leninput)
-{
-
-moko_dialer_textview_fill_it(moko_dialer_text_view,&(ready_contact->p_entry->content[leninput]));
-
-}
-
-}
-
-void
-on_dialer_autolist_user_confirmed(GtkWidget * widget,gpointer para_pointer,
-                                        gpointer         user_data)
-{
-
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-MokoDialerTextview *moko_dialer_text_view=appdata->moko_dialer_text_view;
-DIALER_READY_CONTACT * ready_contact=(DIALER_READY_CONTACT * )para_pointer;
-DBG_MESSAGE("GOT THE MESSAGE OF confirmed:%s",ready_contact->p_entry->content);
-moko_dialer_textview_confirm_it(moko_dialer_text_view,ready_contact->p_entry->content);
-DBG_MESSAGE("And here we are supposed to call out directly");
-window_dialer_dial_out(appdata);
-
-
-}
-void
-on_dialer_autolist_nomatch(GtkWidget * widget,gpointer         user_data)
-{
-
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-MokoDialerTextview *moko_dialer_text_view=appdata->moko_dialer_text_view;
-
-DBG_MESSAGE("GOT THE MESSAGE OF no match");
-moko_dialer_textview_fill_it(moko_dialer_text_view,"");
-
-}
-
-void
-on_dialer_menu_close(GtkWidget * widget,gpointer         user_data)
-{
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-g_main_loop_quit(appdata->mainloop);
-
-}
-
-void
-on_dialer_menu_hide(GtkWidget * widget,gpointer         user_data)
-{
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-gtk_widget_hide(appdata->window_dialer);
-
-
-}
-
-
-
-
-void
-on_dialer_panel_user_input(GtkWidget * widget,gchar parac,
-                                        gpointer         user_data)
-{
-char input[2];
-input[0]=parac;
-input[1]=0;
-char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
-
-//DBG_TRACE();
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-MokoDialerTextview *moko_dialer_text_view=appdata->moko_dialer_text_view;
-
-
-moko_dialer_textview_insert(moko_dialer_text_view, input);
-//DBG_TRACE();
-
-
-moko_dialer_textview_get_input(moko_dialer_text_view,codesinput, 0);
-//DBG_TRACE();
-
-//DBG_MESSAGE("LEN=%d,MAX=%d",strlen(codesinput),MOKO_DIALER_MAX_NUMBER_LEN);
-
-if(strlen(codesinput)>=MOKO_DIALER_MIN_SENSATIVE_LEN)
-{
-	moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,codesinput,TRUE);
-}
-else
-{	moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
-}
-
-}
-void
-on_dialer_panel_user_hold(GtkWidget * widget,gchar parac,
-                                        gpointer         user_data)
-{
-
-g_print("on_dialer_panel_user_hold:%c\n", parac);
-}
-
-#define WINDOW_DIALER_BUTTON_SIZE_X 100
-#define WINDOW_DIALER_BUTTON_SIZE_Y 100
-gint window_dialer_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-if(!p_dialer_data-> window_dialer)
-{
-
-	GdkColor  color;
-	gdk_color_parse("black",&color);
-
-    GtkVBox* vbox = NULL;
-
-
-    MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-
-
-    GtkMenu* appmenu = GTK_MENU(gtk_menu_new());
-    GtkMenuItem* closeitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label( "Close" ));
-    g_signal_connect( G_OBJECT(closeitem), "activate", G_CALLBACK(on_dialer_menu_close), p_dialer_data);
-    gtk_menu_shell_append( appmenu, closeitem );
-
-     GtkMenuItem* hideitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label( "Hide" ));
-    g_signal_connect( G_OBJECT(hideitem), "activate", G_CALLBACK(on_dialer_menu_hide), p_dialer_data);
-    gtk_menu_shell_append( appmenu, hideitem);
-
-
-    moko_finger_window_set_application_menu( window, appmenu );
-
-//    g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK( gtk_main_quit ), NULL );
-
-
-    /* contents */
-    vbox = gtk_vbox_new( FALSE, 0 );
-  GtkHBox* hbox = gtk_hbox_new( FALSE, 10 );
-
-	
- GtkEventBox *eventbox1 = gtk_event_box_new ();
- gtk_widget_show (eventbox1);
-	//  gtk_widget_set_size_request (eventbox1, 480, 132);
-  gtk_widget_set_name(GTK_WIDGET(eventbox1),"gtkeventbox-black");
-
-    MokoDialerAutolist* autolist=moko_dialer_autolist_new();
-    moko_dialer_autolist_set_data	(autolist,&(p_dialer_data->g_contactlist));
-    p_dialer_data->moko_dialer_autolist=autolist;
-
-   gtk_container_add (GTK_CONTAINER (eventbox1), autolist);
-//    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(autolist), FALSE, FALSE, 5 );
-    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(eventbox1), FALSE, FALSE, 0 );
- 
-    gtk_widget_modify_bg(eventbox1,GTK_STATE_NORMAL,&color);
-
-    g_signal_connect (GTK_OBJECT (autolist), "user_selected",
-			    G_CALLBACK (on_dialer_autolist_user_selected),p_dialer_data);
-
-  
-    g_signal_connect (GTK_OBJECT (autolist), "user_confirmed",
-			    G_CALLBACK ( on_dialer_autolist_user_confirmed),p_dialer_data);
-
-    g_signal_connect (GTK_OBJECT (autolist), "autolist_nomatch",
-			    G_CALLBACK ( on_dialer_autolist_nomatch),p_dialer_data);
-
-
-
-
-
-	eventbox1 = gtk_event_box_new ();
-	gtk_widget_show (eventbox1);
-	gtk_widget_set_name(GTK_WIDGET(eventbox1),"gtkeventbox-black");
-      gtk_widget_modify_bg(eventbox1,GTK_STATE_NORMAL,&color);
-//	  gtk_widget_set_size_request (eventbox1, 480, 132);
-
-    MokoDialerTextview * mokotextview=moko_dialer_textview_new();
-    p_dialer_data->moko_dialer_text_view=mokotextview;
-
-   gtk_container_add (GTK_CONTAINER (eventbox1), mokotextview);
-       gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(eventbox1), FALSE,FALSE, 0 );
-//    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(mokotextview), FALSE,FALSE, 5 );
-
-
-    MokoDialerPanel* mokodialerpanel=moko_dialer_panel_new();
-
-   gtk_widget_set_size_request (mokodialerpanel, 380, 384);
-
-
-    g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_input",
-			    G_CALLBACK (on_dialer_panel_user_input),p_dialer_data);
-
-  
-    g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_hold",
-			    G_CALLBACK ( on_dialer_panel_user_hold),p_dialer_data);
-   	
-    gtk_box_pack_start( GTK_BOX(hbox), GTK_WIDGET(mokodialerpanel), TRUE, TRUE, 5 );
-
-
-
-//the buttons
-
-    GtkVBox *  vbox2 = gtk_vbox_new( FALSE, 0 );
-    GtkButton* button1 = moko_pixmap_button_new();
-    g_signal_connect( G_OBJECT(button1), "clicked", G_CALLBACK(cb_delete_button_clicked), p_dialer_data );
-    gtk_widget_set_name( GTK_WIDGET(button1), "mokofingerbutton-orange" );
-	moko_pixmap_button_set_center_stock(button1,"gtk-delete");
-	moko_pixmap_button_set_action_btn_lower_label(button1,"Delete");
-  gtk_widget_set_size_request (button1, WINDOW_DIALER_BUTTON_SIZE_X, WINDOW_DIALER_BUTTON_SIZE_Y);
-  
-    gtk_box_pack_start( GTK_BOX(vbox2), GTK_WIDGET(button1),FALSE, FALSE, 5 );
-
-    GtkButton* button3 = moko_pixmap_button_new();
-    g_signal_connect( G_OBJECT(button3), "clicked", G_CALLBACK(cb_history_button_clicked), p_dialer_data );
-    gtk_widget_set_name( GTK_WIDGET(button3), "mokofingerbutton-orange" );
-//moko_pixmap_button_set_center_stock(button3,"gtk-refresh");
-moko_pixmap_button_set_finger_toolbox_btn_center_image(button3, file_new_image_from_relative_path("all.png"));
-moko_pixmap_button_set_action_btn_lower_label(button3,"History");
-  gtk_widget_set_size_request (button3, WINDOW_DIALER_BUTTON_SIZE_X, WINDOW_DIALER_BUTTON_SIZE_Y);	
-    gtk_box_pack_start( GTK_BOX(vbox2), GTK_WIDGET(button3),FALSE, FALSE, 5 );
-
-
-    GtkButton* button2 = moko_pixmap_button_new();
-	
-    g_signal_connect( G_OBJECT(button2), "clicked", G_CALLBACK(cb_dialer_button_clicked), p_dialer_data );
-    gtk_widget_set_name( GTK_WIDGET(button2), "mokofingerbutton-black" );
- moko_pixmap_button_set_finger_toolbox_btn_center_image(button2, file_new_image_from_relative_path("phone.png"));
-moko_pixmap_button_set_action_btn_lower_label(button2,"Dial");
-  gtk_widget_set_size_request (button2, WINDOW_DIALER_BUTTON_SIZE_X+20, WINDOW_DIALER_BUTTON_SIZE_Y+80);
-  
-    gtk_box_pack_start( GTK_BOX(vbox2), GTK_WIDGET(button2), FALSE, FALSE, 20 );
-
-
-    gtk_box_pack_start( GTK_BOX(hbox), GTK_WIDGET(vbox2),TRUE, TRUE, 5 );
-
-
-
-    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(hbox), TRUE, TRUE, 5 );
-
-
-    
-    
-    moko_finger_window_set_contents( window, GTK_WIDGET(vbox) );
-
-
-    p_dialer_data-> window_dialer=window;
-
-   gtk_widget_show_all( GTK_WIDGET(window) );
-
-}
-
-    return 1;
-}
-
+/*   openmoko-dialer-window-dialer.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkvbox.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "openmoko-dialer-window-dialer.h"
+#include "openmoko-dialer-window-history.h"
+
+void
+cb_delete_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  g_debug ("delete button clicked");
+
+  if (moko_dialer_autolist_has_selected (appdata->moko_dialer_autolist))
+  {
+//first of all, we un-select the selection.
+    moko_dialer_autolist_set_select (appdata->moko_dialer_autolist, -1);
+
+//fill the textview with ""
+    moko_dialer_textview_fill_it (appdata->moko_dialer_text_view, "");
+//moko_dialer_textview_set_color(moko_dialer_textview);
+  }
+  else
+  {
+    moko_dialer_textview_delete (appdata->moko_dialer_text_view);
+//refresh the autolist,but do not automaticall fill the textview
+    char codesinput[MOKO_DIALER_MAX_NUMBER_LEN + 1];
+    moko_dialer_textview_get_input (appdata->moko_dialer_text_view,
+                                    codesinput, 0);
+
+    if (strlen (codesinput) >= MOKO_DIALER_MIN_SENSATIVE_LEN)
+    {
+      moko_dialer_autolist_refresh_by_string (appdata->moko_dialer_autolist,
+                                              codesinput, FALSE);
+      moko_dialer_textview_set_color (appdata->moko_dialer_text_view);
+    }
+    else
+      moko_dialer_autolist_hide_all_tips (appdata->moko_dialer_autolist);
+
+
+  }
+
+}
+
+void
+cb_history_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  if (!appdata->window_history)
+    window_history_init (appdata);
+
+//start dialling.
+  gtk_widget_show (appdata->window_history);
+
+}
+
+void
+window_dialer_dial_out (MOKO_DIALER_APP_DATA * appdata)
+{
+  gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN + 1];
+  //get the input digits
+  moko_dialer_textview_get_input (appdata->moko_dialer_text_view, codesinput,
+                                  0);
+  if (strlen (codesinput) < 1)
+  {
+    if (strlen (appdata->g_state.lastnumber) > 0)
+    {
+      moko_dialer_textview_insert (appdata->moko_dialer_text_view,
+                                   appdata->g_state.lastnumber);
+      moko_dialer_autolist_refresh_by_string (appdata->moko_dialer_autolist,
+                                              appdata->g_state.lastnumber,
+                                              TRUE);
+    }
+    //user didn't input anything, maybe it's a redial
+
+    return;
+  }
+//empty the textview
+  moko_dialer_textview_empty (appdata->moko_dialer_text_view);
+
+//and we set the selected autolist to be No
+  moko_dialer_autolist_set_select (appdata->moko_dialer_autolist, -1);
+  moko_dialer_autolist_hide_all_tips (appdata->moko_dialer_autolist);
+
+//got the number;
+  strcpy (appdata->g_peer_info.number, codesinput);
+
+//retrieve the contact information if any.
+  contact_get_peer_info_from_number (appdata->g_contactlist.contacts,
+                                     &(appdata->g_peer_info));
+// contact_get_peer_info_from_number
+
+/*
+if(!appdata->window_outgoing)
+	window_incoming_init(appdata);
+
+//transfer the contact info
+window_incoming_prepare(appdata);
+
+//start dialling.
+gtk_widget_show(appdata->window_incoming);
+*/
+
+//transfer the contact info
+  window_outgoing_prepare (appdata);
+
+//start dialling.
+  gtk_widget_show (appdata->window_outgoing);
+
+
+
+}
+
+void
+cb_dialer_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  window_dialer_dial_out (appdata);
+}
+
+
+
+void
+on_dialer_autolist_user_selected (GtkWidget * widget, gpointer para_pointer,
+                                  gpointer user_data)
+{
+  gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN + 1];
+  gint lenstring = 0;
+  gint leninput = 0;
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  MokoDialerTextview *moko_dialer_text_view = appdata->moko_dialer_text_view;
+  DIALER_READY_CONTACT *ready_contact = (DIALER_READY_CONTACT *) para_pointer;
+  DBG_MESSAGE ("GOT THE MESSAGE OF SELECTED:%s",
+               ready_contact->p_entry->content);
+  moko_dialer_textview_get_input (moko_dialer_text_view, codesinput, 0);
+  lenstring = strlen (ready_contact->p_entry->content);
+  leninput = strlen (codesinput);
+  if (lenstring > leninput)
+  {
+
+    moko_dialer_textview_fill_it (moko_dialer_text_view,
+                                  &(ready_contact->p_entry->
+                                    content[leninput]));
+
+  }
+
+}
+
+void
+on_dialer_autolist_user_confirmed (GtkWidget * widget, gpointer para_pointer,
+                                   gpointer user_data)
+{
+
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  MokoDialerTextview *moko_dialer_text_view = appdata->moko_dialer_text_view;
+  DIALER_READY_CONTACT *ready_contact = (DIALER_READY_CONTACT *) para_pointer;
+  DBG_MESSAGE ("GOT THE MESSAGE OF confirmed:%s",
+               ready_contact->p_entry->content);
+  moko_dialer_textview_confirm_it (moko_dialer_text_view,
+                                   ready_contact->p_entry->content);
+  DBG_MESSAGE ("And here we are supposed to call out directly");
+  window_dialer_dial_out (appdata);
+
+
+}
+
+void
+on_dialer_autolist_nomatch (GtkWidget * widget, gpointer user_data)
+{
+
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  MokoDialerTextview *moko_dialer_text_view = appdata->moko_dialer_text_view;
+
+  DBG_MESSAGE ("GOT THE MESSAGE OF no match");
+  moko_dialer_textview_fill_it (moko_dialer_text_view, "");
+
+}
+
+void
+on_dialer_menu_close (GtkWidget * widget, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  g_main_loop_quit (appdata->mainloop);
+
+}
+
+void
+on_dialer_menu_hide (GtkWidget * widget, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  gtk_widget_hide (appdata->window_dialer);
+
+
+}
+
+
+
+
+void
+on_dialer_panel_user_input (GtkWidget * widget, gchar parac,
+                            gpointer user_data)
+{
+  char input[2];
+  input[0] = parac;
+  input[1] = 0;
+  char codesinput[MOKO_DIALER_MAX_NUMBER_LEN + 1];
+
+//DBG_TRACE();
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  MokoDialerTextview *moko_dialer_text_view = appdata->moko_dialer_text_view;
+
+
+  moko_dialer_textview_insert (moko_dialer_text_view, input);
+//DBG_TRACE();
+
+
+  moko_dialer_textview_get_input (moko_dialer_text_view, codesinput, 0);
+//DBG_TRACE();
+
+//DBG_MESSAGE("LEN=%d,MAX=%d",strlen(codesinput),MOKO_DIALER_MAX_NUMBER_LEN);
+
+  if (strlen (codesinput) >= MOKO_DIALER_MIN_SENSATIVE_LEN)
+  {
+    moko_dialer_autolist_refresh_by_string (appdata->moko_dialer_autolist,
+                                            codesinput, TRUE);
+  }
+  else
+  {
+    moko_dialer_autolist_hide_all_tips (appdata->moko_dialer_autolist);
+  }
+
+}
+void
+on_dialer_panel_user_hold (GtkWidget * widget, gchar parac,
+                           gpointer user_data)
+{
+
+  g_print ("on_dialer_panel_user_hold:%c\n", parac);
+}
+
+#define WINDOW_DIALER_BUTTON_SIZE_X 100
+#define WINDOW_DIALER_BUTTON_SIZE_Y 100
+gint
+window_dialer_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  if (!p_dialer_data->window_dialer)
+  {
+
+    GdkColor color;
+    gdk_color_parse ("black", &color);
+
+    GtkVBox *vbox = NULL;
+
+
+    MokoFingerWindow *window = MOKO_FINGER_WINDOW (moko_finger_window_new ());
+
+
+    GtkMenu *appmenu = GTK_MENU (gtk_menu_new ());
+    GtkMenuItem *closeitem =
+      GTK_MENU_ITEM (gtk_menu_item_new_with_label ("Close"));
+    g_signal_connect (G_OBJECT (closeitem), "activate",
+                      G_CALLBACK (on_dialer_menu_close), p_dialer_data);
+    gtk_menu_shell_append (appmenu, closeitem);
+
+    GtkMenuItem *hideitem =
+      GTK_MENU_ITEM (gtk_menu_item_new_with_label ("Hide"));
+    g_signal_connect (G_OBJECT (hideitem), "activate",
+                      G_CALLBACK (on_dialer_menu_hide), p_dialer_data);
+    gtk_menu_shell_append (appmenu, hideitem);
+
+
+    moko_finger_window_set_application_menu (window, appmenu);
+
+//    g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK( gtk_main_quit ), NULL );
+
+
+    /* contents */
+    vbox = gtk_vbox_new (FALSE, 0);
+    GtkHBox *hbox = gtk_hbox_new (FALSE, 10);
+
+
+    GtkEventBox *eventbox1 = gtk_event_box_new ();
+    gtk_widget_show (eventbox1);
+    //  gtk_widget_set_size_request (eventbox1, 480, 132);
+    gtk_widget_set_name (GTK_WIDGET (eventbox1), "gtkeventbox-black");
+
+    MokoDialerAutolist *autolist = moko_dialer_autolist_new ();
+    moko_dialer_autolist_set_data (autolist, &(p_dialer_data->g_contactlist));
+    p_dialer_data->moko_dialer_autolist = autolist;
+
+    gtk_container_add (GTK_CONTAINER (eventbox1), autolist);
+//    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(autolist), FALSE, FALSE, 5 );
+    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eventbox1), FALSE, FALSE,
+                        0);
+
+    gtk_widget_modify_bg (eventbox1, GTK_STATE_NORMAL, &color);
+
+    g_signal_connect (GTK_OBJECT (autolist), "user_selected",
+                      G_CALLBACK (on_dialer_autolist_user_selected),
+                      p_dialer_data);
+
+
+    g_signal_connect (GTK_OBJECT (autolist), "user_confirmed",
+                      G_CALLBACK (on_dialer_autolist_user_confirmed),
+                      p_dialer_data);
+
+    g_signal_connect (GTK_OBJECT (autolist), "autolist_nomatch",
+                      G_CALLBACK (on_dialer_autolist_nomatch), p_dialer_data);
+
+
+
+
+
+    eventbox1 = gtk_event_box_new ();
+    gtk_widget_show (eventbox1);
+    
gtk_widget_set_name (GTK_WIDGET (eventbox1), "gtkeventbox-black");
+    gtk_widget_modify_bg (eventbox1, GTK_STATE_NORMAL, &color);
+//        gtk_widget_set_size_request (eventbox1, 480, 132);
+
+    MokoDialerTextview *mokotextview = moko_dialer_textview_new ();
+    p_dialer_data->moko_dialer_text_view = mokotextview;
+
+    gtk_container_add (GTK_CONTAINER (eventbox1), mokotextview);
+    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eventbox1), FALSE, FALSE,
+                        0);
+//    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(mokotextview), FALSE,FALSE, 5 );
+
+
+    MokoDialerPanel *mokodialerpanel = moko_dialer_panel_new ();
+
+    gtk_widget_set_size_request (mokodialerpanel, 380, 384);
+
+
+    g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_input",
+                      G_CALLBACK (on_dialer_panel_user_input), p_dialer_data);
+
+
+    g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_hold",
+                      G_CALLBACK (on_dialer_panel_user_hold), p_dialer_data);
+
+    gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (mokodialerpanel), TRUE,
+                        TRUE, 5);
+
+
+
+//the buttons
+
+    GtkVBox *vbox2 = gtk_vbox_new (FALSE, 0);
+    GtkButton *button1 = moko_pixmap_button_new ();
+    g_signal_connect (G_OBJECT (button1), "clicked",
+                      G_CALLBACK (cb_delete_button_clicked), p_dialer_data);
+    gtk_widget_set_name (GTK_WIDGET (button1), "mokofingerbutton-orange");
+    moko_pixmap_button_set_center_stock (button1, "gtk-delete");
+    moko_pixmap_button_set_action_btn_lower_label (button1, "Delete");
+    gtk_widget_set_size_request (button1, WINDOW_DIALER_BUTTON_SIZE_X,
+                                 WINDOW_DIALER_BUTTON_SIZE_Y);
+
+    gtk_box_pack_start (GTK_BOX (vbox2), GTK_WIDGET (button1), FALSE, FALSE,
+                        5);
+
+    GtkButton *button3 = moko_pixmap_button_new ();
+    g_signal_connect (G_OBJECT (button3), "clicked",
+                      G_CALLBACK (cb_history_button_clicked), p_dialer_data);
+    gtk_widget_set_name (GTK_WIDGET (button3), "mokofingerbutton-orange");
+//moko_pixmap_button_set_center_stock(button3,"gtk-refresh");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button3,
+                                                            file_new_image_from_relative_path
+                                                            ("all.png"));
+    moko_pixmap_button_set_action_btn_lower_label (button3, "History");
+    gtk_widget_set_size_request (button3, WINDOW_DIALER_BUTTON_SIZE_X,
+                                 WINDOW_DIALER_BUTTON_SIZE_Y);
+    gtk_box_pack_start (GTK_BOX (vbox2), GTK_WIDGET (button3), FALSE, FALSE,
+                        5);
+
+
+    GtkButton *button2 = moko_pixmap_button_new ();
+
+    g_signal_connect (G_OBJECT (button2), "clicked",
+                      G_CALLBACK (cb_dialer_button_clicked), p_dialer_data);
+    gtk_widget_set_name (GTK_WIDGET (button2), "mokofingerbutton-black");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button2,
+                                                            file_new_image_from_relative_path
+                                                            ("phone.png"));
+    moko_pixmap_button_set_action_btn_lower_label (button2, "Dial");
+    gtk_widget_set_size_request (button2, WINDOW_DIALER_BUTTON_SIZE_X + 20,
+                                 WINDOW_DIALER_BUTTON_SIZE_Y + 80);
+
+    gtk_box_pack_start (GTK_BOX (vbox2), GTK_WIDGET (button2), FALSE, FALSE,
+                        20);
+
+
+    gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (vbox2), TRUE, TRUE, 5);
+
+
+
+    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), TRUE, TRUE, 5);
+
+
+
+
+    moko_finger_window_set_contents (window, GTK_WIDGET (vbox));
+
+
+    p_dialer_data->window_dialer = window;
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+  }
+
+  return 1;
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,39 +1,38 @@
-/*  openmoko-dialer-window-dialer.h
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #include "moko-dialer-includes.h"
-
- #ifndef _OPENMOKO_DIALER_WINDOW_DIALER_H
-#define _OPENMOKO_DIALER_WINDOW_DIALER_H
-
-#ifdef __cplusplus
-
-
-
-extern "C"
-
-{
-#endif
-
- 
-gint window_dialer_init( MOKO_DIALER_APP_DATA* p_dialer_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif 
+/*  openmoko-dialer-window-dialer.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-includes.h"
+
+#ifndef _OPENMOKO_DIALER_WINDOW_DIALER_H
+#define _OPENMOKO_DIALER_WINDOW_DIALER_H
+
+#ifdef __cplusplus
+
+
+
+extern "C"
+{
+#endif
+
+
+  gint window_dialer_init (MOKO_DIALER_APP_DATA * p_dialer_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,961 +1,1014 @@
-/*   openmoko-dialer-window-talking.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
-#include <libmokoui/moko-finger-tool-box.h>
-#include <libmokoui/moko-finger-window.h>
-#include <libmokoui/moko-finger-wheel.h>
-#include <libmokoui/moko-pixmap-button.h>
-
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreemodelfilter.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtkmenu.h>
-#include "contacts.h"
-#include "openmoko-dialer-main.h"
-#include "moko-dialer-status.h"
-#include  "history.h"
-#include "openmoko-dialer-window-history.h"
-
-/**
- * @brief re-filter the treeview widget by the history type
- *
- * 
- *
- * @param type HISTORY_TYPE, indicating only the history items of that type will be displayed
- * @return 1
- * @retval
- */
- 
-int history_view_change_filter(MOKO_DIALER_APP_DATA* p_dialer_data,HISTORY_TYPE  type)
-{
-GtkWidget* historyview;
-GtkTreePath* path;
-DBG_TRACE();
-p_dialer_data->g_history_filter_type=type;
-gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(p_dialer_data->g_list_store_filter));
-
-path=gtk_tree_path_new_first();
-gtk_tree_view_set_cursor(GTK_TREE_VIEW(p_dialer_data->treeview_history),path,0,0);   
-gtk_tree_path_free(path);
-
-	
-return 1;
-}
-
-void
-on_all_calls_activate                  (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"All");
-	history_view_change_filter(p_dialer_data,ALL);
-	history_update_counter(p_dialer_data);
-}
-
-
-void
-on_missed_calls_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"Missed");
-	history_view_change_filter(p_dialer_data,MISSED);
-	history_update_counter(p_dialer_data);
-}
-
-
-void
-on_dialed_calls_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"Dialed");
-	history_view_change_filter(p_dialer_data,OUTGOING);
-	history_update_counter(p_dialer_data);
-}
-
-
-void
-on_received_calls_activate            (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"Received");
-	history_view_change_filter(p_dialer_data,INCOMING);
-	history_update_counter(p_dialer_data);
-}
-
-gboolean
-on_eventboxTop_button_release_event    (GtkWidget       *widget,
-                                        GdkEventButton  *event,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-	
- gtk_menu_popup(GTK_MENU(appdata->menu_history),0,0,0,0,0,0);
- 
-  return FALSE;
-}
-
-void
-openmoko_history_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
- GtkTreeSelection    *selection;
- GtkTreeModel        *model;
- GtkTreeIter         iter;
- GtkTreePath* path;
- GtkTreeView * treeview;
- //DBG_ENTER();
-
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
- if(treeview==0)return ;
-	 
- selection = gtk_tree_view_get_selection(treeview);
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- {
-	 DBG_WARN("no current selection\n");
-	 return ;
- }
- 		path=gtk_tree_model_get_path(model,&iter);
-		if(!gtk_tree_path_prev(path))
-		{
-				DBG_WARN("no prev for the top level\n");
-				gtk_tree_path_free(path);
-				return;
-		}
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-  return ;
-
-
-}
-
-void
-openmoko_history_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
- GtkTreeSelection    *selection;
- GtkTreeModel        *model;
- GtkTreeIter         iter;
- GtkTreePath* path;
- GtkTreeView * treeview;
- //DBG_ENTER();
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
- if(treeview==0)return ;
-	 
- selection = gtk_tree_view_get_selection(treeview);
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- {
-	 DBG_WARN("no current selection\n");
-	 return ;
- }
-	 if(gtk_tree_model_iter_next(model,&iter))
-	 {
-		path=gtk_tree_model_get_path(model,&iter);
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-		gtk_tree_path_free(path);
-		return ;
-	 }
- 
-  return ;
-}
-
-
-void cb_tool_button_history_delete_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-GtkTreeIter iter; //iter of the filter store
-GtkTreeIter iter0; //iter of the back store
-GtkTreeModel* model;
-GtkTreeModel* model0;
-GtkTreeSelection * selection;
-GtkTreeView* treeview;
-GtkTreePath* path;
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
-selection = gtk_tree_view_get_selection(treeview);
-
-	
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-{
-	return;
-}
-	
-if(appdata->g_currentselected)
-{
-DBG_MESSAGE("to delete %s",appdata->g_currentselected->number);
-history_delete_entry(&(appdata->g_historylist),appdata->g_currentselected);
-}
-
-path=gtk_tree_model_get_path(model,&iter);
-
-
-model0=gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
-
-
-gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model),&iter0,&iter);
-
-gtk_list_store_remove(GTK_LIST_STORE(model0),&iter0);
-
-
-gtk_tree_view_set_cursor(treeview,path,0,0);
-
-
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-{
-	if(!gtk_tree_path_prev(path))
-	{
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-		DBG_WARN("history is empty now!");
-		history_update_counter(appdata);
-	}
-	else
-	{
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-	}
-	//we deleted the last one.
-	
-}
-
-gtk_tree_path_free(path);
-
-return ;
-
-  DBG_ENTER();
-}
-
-void cb_tool_button_history_call_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-	DBG_ENTER();
-	
-
+/*   openmoko-dialer-window-talking.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtktreeview.h>
+#include <gtk/gtktreemodelfilter.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkimagemenuitem.h>
+#include <gtk/gtkmenu.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "moko-dialer-status.h"
+#include  "history.h"
+#include "openmoko-dialer-window-history.h"
+
+/**
+ * @brief re-filter the treeview widget by the history type
+ *
+ * 
+ *
+ * @param type HISTORY_TYPE, indicating only the history items of that type will be displayed
+ * @return 1
+ * @retval
+ */
+
+int
+history_view_change_filter (MOKO_DIALER_APP_DATA * p_dialer_data,
+                            HISTORY_TYPE type)
+{
+  GtkWidget *historyview;
+  GtkTreePath *path;
+  DBG_TRACE ();
+  p_dialer_data->g_history_filter_type = type;
+  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER
+                                  (p_dialer_data->g_list_store_filter));
+
+  path = gtk_tree_path_new_first ();
+  gtk_tree_view_set_cursor (GTK_TREE_VIEW (p_dialer_data->treeview_history),
+                            path, 0, 0);
+  gtk_tree_path_free (path);
+
+
+  return 1;
+}
+
+void
+on_all_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "All");
+  history_view_change_filter (p_dialer_data, ALL);
+  history_update_counter (p_dialer_data);
+}
+
+
+void
+on_missed_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "Missed");
+  history_view_change_filter (p_dialer_data, MISSED);
+  history_update_counter (p_dialer_data);
+}
+
+
+void
+on_dialed_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "Dialed");
+  history_view_change_filter (p_dialer_data, OUTGOING);
+  history_update_counter (p_dialer_data);
+}
+
+
+void
+on_received_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "Received");
+  history_view_change_filter (p_dialer_data, INCOMING);
+  history_update_counter (p_dialer_data);
+}
+
+gboolean
+on_eventboxTop_button_release_event (GtkWidget * widget,
+                                     GdkEventButton * event,
+                                     MOKO_DIALER_APP_DATA * appdata)
+{
+
+  gtk_menu_popup (GTK_MENU (appdata->menu_history), 0, 0, 0, 0, 0, 0);
+
+  return FALSE;
+}
+
+void
+openmoko_history_wheel_press_left_up_cb (GtkWidget * widget,
+                                         MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GtkTreeView *treeview;
+  //DBG_ENTER();
+
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+  if (treeview == 0)
+    return;
+
+  selection = gtk_tree_view_get_selection (treeview);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    DBG_WARN ("no current selection\n");
+    return;
+  }
+  path = gtk_tree_model_get_path (model, &iter);
+  if (!gtk_tree_path_prev (path))
+  {
+    DBG_WARN ("no prev for the top level\n");
+    gtk_tree_path_free (path);
+    return;
+  }
+  gtk_tree_view_set_cursor (treeview, path, 0, 0);
+  return;
+
+
+}
+
+void
+openmoko_history_wheel_press_right_down_cb (GtkWidget * widget,
+                                            MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GtkTreeView *treeview;
+  //DBG_ENTER();
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+  if (treeview == 0)
+    return;
+
+  selection = gtk_tree_view_get_selection (treeview);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    DBG_WARN ("no current selection\n");
+    return;
+  }
+  if (gtk_tree_model_iter_next (model, &iter))
+  {
+    path = gtk_tree_model_get_path (model, &iter);
+    gtk_tree_view_set_cursor (treeview, path, 0, 0);
+    gtk_tree_path_free (path);
+    return;
+  }
+
+  return;
+}
+
+
+void
+cb_tool_button_history_delete_clicked (GtkButton * button,
+                                       MOKO_DIALER_APP_DATA * appdata)
+{
+  GtkTreeIter iter;             //iter of the filter store
+  GtkTreeIter iter0;            //iter of the back store
+  GtkTreeModel *model;
+  GtkTreeModel *model0;
+  GtkTreeSelection *selection;
+  GtkTreeView *treeview;
+  GtkTreePath *path;
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+  selection = gtk_tree_view_get_selection (treeview);
+
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    return;
+  }
+
+  if (appdata->g_currentselected)
+  {
+    DBG_MESSAGE ("to delete %s", appdata->g_currentselected->number);
+    history_delete_entry (&(appdata->g_historylist),
+                          appdata->g_currentselected);
+  }
+
+  path = gtk_tree_model_get_path (model, &iter);
+
+
+  model0 = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+
+
+  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
+                                                    (model), &iter0, &iter);
+
+  gtk_list_store_remove (GTK_LIST_STORE (model0), &iter0);
+
+
+  gtk_tree_view_set_cursor (treeview, path, 0, 0);
+
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    if (!gtk_tree_path_prev (path))
+    {
+      gtk_tree_view_set_cursor (treeview, path, 0, 0);
+      DBG_WARN ("history is empty now!");
+      history_update_counter (appdata);
+    }
+    else
+    {
+      gtk_tree_view_set_cursor (treeview, path, 0, 0);
+    }
+    //we deleted the last one.
+
+  }
+
+  gtk_tree_path_free (path);
+
+  return;
+
+  DBG_ENTER ();
+}
+
+void
+cb_tool_button_history_call_clicked (GtkButton * button,
+                                     MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+
+
+}
+
+void
+cb_tool_button_history_sms_clicked (GtkButton * button,
+                                    MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+
+
+}
+
+void
+cb_tool_button_history_back_clicked (GtkButton * button,
+                                     MOKO_DIALER_APP_DATA * appdata)
+{
+  gtk_widget_hide (appdata->window_history);
+
+}
+
+
+void
+on_window_history_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+
+  gtk_widget_hide (appdata->wheel_history);
+  gtk_widget_hide (appdata->toolbox_history);
+
+}
+
+void
+on_window_history_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+  if (appdata->wheel_history)
+    gtk_widget_show (appdata->wheel_history);
+
+  if (appdata->toolbox_history)
+    gtk_widget_show (appdata->toolbox_history);
+
+  if (appdata->history_need_to_update)
+  {
+    DBG_MESSAGE ("NEED TO UPDATE HISTORY");
+  }
+
+  DBG_LEAVE ();
+}
+
+
+
+
+gint
+window_history_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  DBG_ENTER ();
+
+
+  if (p_dialer_data->window_history == 0)
+  {
+
+    history_create_menu_history (p_dialer_data);
+
+    MokoFingerWindow *window = NULL;
+    MokoFingerToolBox *tools = NULL;
+    GtkWidget *button;
+    GtkWidget *image;
+
+//now the container--window
+    window = MOKO_FINGER_WINDOW (moko_finger_window_new ());
+    p_dialer_data->window_history = window;
+
+
+    moko_finger_window_set_contents (window,
+                                     create_window_history_content
+                                     (p_dialer_data));
+
+    g_signal_connect ((gpointer) window, "show",
+                      G_CALLBACK (on_window_history_show), p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+                      G_CALLBACK (on_window_history_hide), p_dialer_data);
+
+
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
+
+
+    //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all???
+    gtk_widget_show (GTK_WIDGET (moko_finger_window_get_wheel (window)));
+
+    g_signal_connect (G_OBJECT (moko_finger_window_get_wheel (window)),
+                      "press_left_up",
+                      G_CALLBACK (openmoko_history_wheel_press_left_up_cb),
+                      p_dialer_data);
+    g_signal_connect (G_OBJECT (moko_finger_window_get_wheel (window)),
+                      "press_right_down",
+                      G_CALLBACK (openmoko_history_wheel_press_right_down_cb),
+                      p_dialer_data);
+
+
+
+    tools = moko_finger_window_get_toolbox (window);
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("phone.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_call_clicked),
+                      p_dialer_data);
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("sms.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_sms_clicked),
+                      p_dialer_data);
+
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("delete.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_delete_clicked),
+                      p_dialer_data);
+    gtk_widget_show (GTK_WIDGET (tools));
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("tony.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_back_clicked),
+                      p_dialer_data);
+    gtk_widget_show (GTK_WIDGET (tools));
+
+    p_dialer_data->wheel_history = moko_finger_window_get_wheel (window);
+    p_dialer_data->toolbox_history = tools;
+
+    gtk_widget_hide (window);
+
+    DBG_LEAVE ();
+  }
+  else
+  {
+    //here we have to refresh it.
+    DBG_TRACE ();
+  }
+  return 1;
+}
+
+void
+on_treeviewHistory_cursor_changed (GtkTreeView * treeview, gpointer user_data)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+  GtkTreeSelection *selection;
+  HISTORY_ENTRY *p;
+  int hasname;
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+
+  selection = gtk_tree_view_get_selection (p_dialer_data->treeview_history);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    p_dialer_data->g_currentselected = 0;
+    return;
+  }
+
+  gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1);
+
+  p_dialer_data->g_currentselected = p;
+
+  gtk_tree_model_get (model, &iter, COLUMN_HASNAME, &hasname, -1);
+  history_update_counter (p_dialer_data);
+
+}
+
+
+
+GtkWidget *
+create_window_history_content (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  GtkWidget *treeviewHistory;
+  GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
+  //FIRST of all, the top title area;
+  GtkWidget *eventboxTop = gtk_event_box_new ();
+  gtk_widget_show (eventboxTop);
+  gtk_box_pack_start (GTK_BOX (vbox), eventboxTop, FALSE, FALSE, 5);
+  gtk_widget_set_size_request (eventboxTop, 480, 64);
+  gtk_widget_set_name (eventboxTop, "gtkeventbox-black");
+
+  GtkWidget *hbox67 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox67);
+  gtk_container_add (GTK_CONTAINER (eventboxTop), hbox67);
+
+  GtkWidget *eventboxLeftTop = gtk_event_box_new ();
+  gtk_widget_show (eventboxLeftTop);
+  gtk_box_pack_start (GTK_BOX (hbox67), eventboxLeftTop, FALSE, TRUE, 0);
+  gtk_widget_set_name (eventboxLeftTop, "gtkeventbox-black");
+
+
+
+  GtkWidget *imageLeftMenu = file_new_image_from_relative_path ("all.png");
+  gtk_widget_show (imageLeftMenu);
+  gtk_container_add (GTK_CONTAINER (eventboxLeftTop), imageLeftMenu);
+
+  GtkWidget *labelHistoryTitle = gtk_label_new (("History-"));
+  gtk_widget_show (labelHistoryTitle);
+  gtk_box_pack_start (GTK_BOX (hbox67), labelHistoryTitle, FALSE, FALSE, 0);
+  gtk_widget_set_size_request (labelHistoryTitle, 221, -1);
+  gtk_label_set_justify (GTK_LABEL (labelHistoryTitle), GTK_JUSTIFY_RIGHT);
+  gtk_misc_set_alignment (GTK_MISC (labelHistoryTitle), 1, 0.5);
+
+  GtkWidget *labelFilter = gtk_label_new (("All"));
+  gtk_widget_show (labelFilter);
+  gtk_box_pack_start (GTK_BOX (hbox67), labelFilter, TRUE, TRUE, 0);
+  gtk_misc_set_alignment (GTK_MISC (labelFilter), 0, 0.5);
+  p_dialer_data->label_filter_history = labelFilter;
+
+  GtkWidget *labelCounter = gtk_label_new (("1/21"));
+  gtk_widget_show (labelCounter);
+  gtk_box_pack_start (GTK_BOX (hbox67), labelCounter, TRUE, TRUE, 0);
+  gtk_label_set_justify (GTK_LABEL (labelCounter), GTK_JUSTIFY_RIGHT);
+  gtk_misc_set_alignment (GTK_MISC (labelCounter), 0.8, 0.5);
+  p_dialer_data->label_counter_history = labelCounter;
+
+  g_signal_connect ((gpointer) eventboxTop, "button_release_event",
+                    G_CALLBACK (on_eventboxTop_button_release_event),
+                    p_dialer_data);
+
+  GtkWidget *align = gtk_alignment_new (0, 0, 1, 1);
+  gtk_alignment_set_padding (align, 0, 150, 0, 0);      //FIXME too many numbers has to be retrieved from style
+
+  GtkWidget *scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_show (scrolledwindow);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+                                  GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+
+  treeviewHistory = gtk_tree_view_new ();
+  gtk_container_add (GTK_CONTAINER (align), scrolledwindow);
+  gtk_container_add (GTK_CONTAINER (scrolledwindow), treeviewHistory);
+
+  gtk_widget_show (treeviewHistory);
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeviewHistory), FALSE);
+  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeviewHistory), FALSE);
+//   gtk_misc_set_alignment (GTK_MISC (treeviewHistory), 0.5, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
+
+
+  gtk_widget_set_name (treeviewHistory, "gtktreeview-black");
+  p_dialer_data->treeview_history = treeviewHistory;
+  history_build_history_list_view (p_dialer_data);
+  gtk_widget_set_size_request (scrolledwindow, -1, 400);
+//  gtk_misc_set_alignment (GTK_MISC (treeviewHistory),1,0.1);
+
+
+  g_signal_connect ((gpointer) treeviewHistory, "cursor_changed",
+                    G_CALLBACK (on_treeviewHistory_cursor_changed),
+                    p_dialer_data);
+
+
+  return vbox;
+}
+
+
+/**
+ * @brief re-filter the treeview widget by current history type,a callback when the history treeview refreshes
+ *
+ * this callback will be called for every treemodel iters,whenever the treeview filter is refreshing
+ *
+ * @param model GtkTreeModel *, the background database of the treeview
+ * @param iter GtkTreeIter *, the iterator of every item of the model.
+ * @param  data gpointer , of no use currently
+ * @return boolean
+ * @retval TRUE means the iter will be displayed
+ * @retval  FALSE means the iter will not be displayed
+ */
+static gboolean
+history_view_filter_visible_function (GtkTreeModel * model,
+                                      GtkTreeIter * iter, gpointer data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) data;
+  HISTORY_TYPE type;
+  if (p_dialer_data->g_history_filter_type == ALL)
+    return TRUE;
+  gtk_tree_model_get (model, iter, COLUMN_TYPE, &type, -1);
+  if (type == p_dialer_data->g_history_filter_type)
+    return TRUE;
+  else
+    return FALSE;
+}
+
+
+
+/**
+ * @brief find the treeview in the window, fill-in the data and show it on the screen.
+ *
+ *
+ *
+ * @param window GtkWidget* the window which contains the history treeview. but it's not necessarilly
+ *to be a window, any widget that can help to lookup the treeview will be OK.
+ * @return 
+ * @retval 0 error occured
+ * @retval 1 everything is OK
+ */
+
+gint
+history_build_history_list_view (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+  GtkListStore *list_store;
+
+  GtkTreeIter iter;
+  HISTORY_ENTRY *entry;
+
+  //copied
+  GtkTreeViewColumn *col;
+  GtkCellRenderer *renderer;
+
+  //GtkTreeModel        *model;
+  GtkWidget *contactview = NULL;
+
+  //DBG_ENTER();
+  //DBG_MESSAGE("History:%d",g_historylist.length);
+
+  //DBG_TRACE();
+  p_dialer_data->g_history_filter_type = ALL;
+  contactview = p_dialer_data->treeview_history;
+
+  if (contactview == NULL)
+    return 0;
+//pack image and label
+  col = gtk_tree_view_column_new ();
+
+  gtk_tree_view_column_set_title (col, ("Title"));
+  gtk_tree_view_column_set_resizable (col, TRUE);
+
+
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_tree_view_column_pack_start (col, renderer, FALSE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "pixbuf", COLUMN_TYPEICON, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (col, renderer, FALSE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "text", COLUMN_TIME, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (col, renderer, FALSE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "text", COLUMN_SEPRATE, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (col, renderer, TRUE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "text", COLUMN_NAME_NUMBER, NULL);
+
+
+  gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col);
+
+
+  entry = p_dialer_data->g_historylist.first;
+
+  list_store = gtk_list_store_new (N_COLUMN, G_TYPE_INT, GDK_TYPE_PIXBUF,
+                                   G_TYPE_STRING, G_TYPE_STRING,
+                                   G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER,
+                                   G_TYPE_INT, -1);
+  //we will use a filter to facilitate the filtering in treeview without rebuilding the database.                         
+  p_dialer_data->g_list_store_filter =
+    gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL);
+  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER
+                                          (p_dialer_data->
+                                           g_list_store_filter),
+                                          history_view_filter_visible_function,
+                                          p_dialer_data, NULL);
+
+//load the three icons to memory.
+  GError *error = NULL;
+  p_dialer_data->g_iconReceived = create_pixbuf ("received.png", &error);
+  if (error)
+  {
+    DBG_WARN ("Cound not load icon :%s", error->message);
+    g_error_free (error);
+    p_dialer_data->g_iconReceived = NULL;
+    error = NULL;
+  }
+
+  p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png", &error);
+  if (error)
+  {
+    DBG_WARN ("Cound not load icon :%s", error->message);
+    g_error_free (error);
+    p_dialer_data->g_iconDialed = NULL;
+    error = NULL;
+  }
+
+
+  p_dialer_data->g_iconMissed = create_pixbuf ("missed.png", &error);
+  if (error)
+  {
+    DBG_WARN ("Cound not load icon :%s", error->message);
+    g_error_free (error);
+    p_dialer_data->g_iconMissed = NULL;
+    error = NULL;
+  }
+
+
+  while (entry)
+  {
+    //DBG_MESSAGE(entry->number);
+    gtk_list_store_append (list_store, &iter);
+    gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type,
+                        COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time,
+                        COLUMN_DURATION, entry->durationsec,
+                        COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1);
+    if (entry->name == 0)
+    {
+      //DBG_MESSAGE(entry->number);
+      gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER,
+                          entry->number, -1);
+      gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1);
+    }
+    else
+    {
+      gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->name,
+                          -1);
+      gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1);
+    }
+    switch (entry->type)
+    {
+      case INCOMING:
+        {
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconReceived, -1);
+          //      icon=gdk_pixbuf_new_from_file("./received.png",&error);
+          break;
+        }
+      case OUTGOING:
+        {                       //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconDialed, -1);
+          break;
+        }
+      case MISSED:
+        {                       //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconMissed, -1);
+          break;
+        }
+
+      default:
+
+        {                       //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconMissed, -1);
+          break;
+        }
+    }
+
+
+
+    entry = entry->next;
+  }
+
+  gtk_tree_view_set_model (GTK_TREE_VIEW (contactview),
+                           GTK_TREE_MODEL (p_dialer_data->
+                                           g_list_store_filter));
+
+  g_object_unref (list_store);
+
+  return 1;
+}
+
+
+/**
+ * @brief update the counter display widget - labelCounter
+ *
+ * @param widget GtkWidget*, any widget in the same window with treeviewHistory and labelCounter
+ *
+ * @return 1
+ */
+gint
+history_update_counter (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+  DBG_ENTER ();
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+  GtkTreeSelection *selection;
+  GtkTreePath *path;
+  GtkTreeView *treeview;
+  int count = 0;
+  int nth = 0;
+  char *pathstring;
+  char display[10];
+
+  treeview = GTK_TREE_VIEW (p_dialer_data->treeview_history);
+  if (!p_dialer_data->treeview_history)
+  {
+    DBG_WARN ("COUNTER NOT READY ");
+    return 0;
+  }
+
+
+  model = gtk_tree_view_get_model (treeview);
+
+  count = gtk_tree_model_iter_n_children (model, NULL);
+
+  selection = gtk_tree_view_get_selection (treeview);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    nth = 0;
+  }
+  else
+  {
+    path = gtk_tree_model_get_path (model, &iter);
+    pathstring = gtk_tree_path_to_string (path);
+    nth = atoi (pathstring) + 1;
+    gtk_tree_path_free (path);
+
+  }
+
+  GtkWidget *labelcounter;
+  labelcounter = p_dialer_data->label_counter_history;
+  sprintf (display, "%d/%d", nth, count);
+  gtk_label_set_text (GTK_LABEL (labelcounter), display);
+  return 1;
+
+}
+
+GtkWidget *
+history_create_menu_history (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+  if (!p_dialer_data->menu_history)
+  {
+    GtkWidget *menu_history;
+    GtkWidget *all_calls;
+    GtkWidget *imageAll;
+    GtkWidget *separator1;
+    GtkWidget *missed_calls;
+    GtkWidget *imageMissed;
+    GtkWidget *separator3;
+    GtkWidget *dialed_calls;
+    GtkWidget *imageDialed;
+    GtkWidget *separator2;
+    GtkWidget *received_calls;
+    GtkWidget *imageReceived;
+
+    menu_history = gtk_menu_new ();
+    gtk_container_set_border_width (GTK_CONTAINER (menu_history), 2);
+
+    all_calls = gtk_image_menu_item_new_with_mnemonic (("Calls All"));
+    gtk_widget_show (all_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), all_calls);
+    gtk_widget_set_size_request (all_calls, 250, 60);
+
+
+    imageAll = file_new_image_from_relative_path ("all.png");
+    gtk_widget_show (imageAll);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (all_calls), imageAll);
+
+    separator1 = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator1);
+    gtk_container_add (GTK_CONTAINER (menu_history), separator1);
+    gtk_widget_set_size_request (separator1, 120, -1);
+    gtk_widget_set_sensitive (separator1, FALSE);
+
+    missed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Missed "));
+    gtk_widget_show (missed_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), missed_calls);
+    gtk_widget_set_size_request (missed_calls, 120, 60);
+
+    //imageMissed = gtk_image_new_from_stock ("gtk-goto-bottom", GTK_ICON_SIZE_MENU);
+    imageMissed = file_new_image_from_relative_path ("missed.png");
+
+    gtk_widget_show (imageMissed);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (missed_calls),
+                                   imageMissed);
+
+    separator3 = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator3);
+    gtk_container_add (GTK_CONTAINER (menu_history), separator3);
+    gtk_widget_set_size_request (separator3, 120, -1);
+    gtk_widget_set_sensitive (separator3, FALSE);
+
+    dialed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Dialed"));
+    gtk_widget_show (dialed_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), dialed_calls);
+    gtk_widget_set_size_request (dialed_calls, 120, 60);
+
+    // imageDialed = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU);
+    imageDialed = file_new_image_from_relative_path ("dialed.png");
+    gtk_widget_show (imageDialed);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialed_calls),
+                                   imageDialed);
+
+    separator2 = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator2);
+    gtk_container_add (GTK_CONTAINER (menu_history), separator2);
+    gtk_widget_set_size_request (separator2, 120, -1);
+    gtk_widget_set_sensitive (separator2, FALSE);
+
+    received_calls =
+      gtk_image_menu_item_new_with_mnemonic (("Calls Received "));
+    gtk_widget_show (received_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), received_calls);
+    gtk_widget_set_size_request (received_calls, 120, 60);
+
+//  imageReceived = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU);
+    imageReceived = file_new_image_from_relative_path ("received.png");
+    gtk_widget_show (imageReceived);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (received_calls),
+                                   imageReceived);
+
+    g_signal_connect ((gpointer) all_calls, "activate",
+                      G_CALLBACK (on_all_calls_activate), p_dialer_data);
+    g_signal_connect ((gpointer) missed_calls, "activate",
+                      G_CALLBACK (on_missed_calls_activate), p_dialer_data);
+    g_signal_connect ((gpointer) dialed_calls, "activate",
+                      G_CALLBACK (on_dialed_calls_activate), p_dialer_data);
+    g_signal_connect ((gpointer) received_calls, "activate",
+                      G_CALLBACK (on_received_calls_activate), p_dialer_data);
+
+    p_dialer_data->menu_history = menu_history;
+    return menu_history;
+  }
+  else
+    return p_dialer_data->menu_history;
+}
+
+
+
+/**
+ * @brief add an entry to the history treeview
+ *
+ *
+ *
+ * @param entry HISTORY_ENTRY *, the history entry to be added to the treeview.
+ * @return 
+ * @retval 0 error occured
+ * @retval 1 everything is OK
+ */
+gint
+history_list_view_add (MOKO_DIALER_APP_DATA * appdata, HISTORY_ENTRY * entry)
+{
+  DBG_ENTER ();
+  if (entry == 0)
+  {
+    DBG_ERROR ("THE ENTRY IS ZERO");
+    return 0;
+  }
+
+  if (appdata->treeview_history == 0)
+  {
+    DBG_WARN ("not ready");
+    return 0;
+
+  }
+  //
+  GtkTreeIter iter;             //iter of the filter store
+  GtkTreeModel *model;
+  GtkListStore *list_store;
+  GtkTreeView *treeview;
+
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+
+  model =
+    gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER
+                                     (appdata->g_list_store_filter));
+
+  list_store = GTK_LIST_STORE (model);
+  //
+
+
+  //DBG_MESSAGE(entry->number);
+  gtk_list_store_insert (list_store, &iter, 0);
+  gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type,
+                      COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time,
+                      COLUMN_DURATION, entry->durationsec,
+                      COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1);
+  if (entry->name == 0)
+  {
+    //DBG_MESSAGE(entry->number);
+    gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->number,
+                        -1);
+    gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1);
+  }
+  else
+  {
+    gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->name,
+                        -1);
+    gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1);
+  }
+  switch (entry->type)
+  {
+    case INCOMING:
+      {
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconReceived, -1);
+        //      icon=gdk_pixbuf_new_from_file("./received.png",&error);
+        break;
+      }
+    case OUTGOING:
+      {                         //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconDialed, -1);
+        break;
+      }
+    case MISSED:
+      {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconMissed, -1);
+        break;
+      }
+
+    default:
+
+      {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconMissed, -1);
+        break;
+      }
+  }
+  history_update_counter (appdata);
+  return 1;
+}
+
+
+gint
+add_histroy_entry (MOKO_DIALER_APP_DATA * appdata, HISTORY_TYPE type,
+                   const char *name, const char *number, const char *picpath,
+                   char *time, char *date, int durationsec)
+{
   
-}
-
-void cb_tool_button_history_sms_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-	DBG_ENTER();
-	
-
-  
-}
-
-void cb_tool_button_history_back_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-     gtk_widget_hide(appdata->window_history);
-     
-}
-
-
-void
-on_window_history_hide                 (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-
-gtk_widget_hide(appdata->wheel_history);
-gtk_widget_hide(appdata->toolbox_history);
-
-}
-
-void
-on_window_history_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-
-if(appdata->wheel_history)
-gtk_widget_show(appdata->wheel_history);
-
-if(appdata->toolbox_history)
-gtk_widget_show(appdata->toolbox_history);
-
-if(appdata->history_need_to_update)
-{
-DBG_MESSAGE("NEED TO UPDATE HISTORY");
-}
-   
-DBG_LEAVE();
-}
-
-
-
-
-gint window_history_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-DBG_ENTER();
-
-
-if(p_dialer_data->window_history==0)
-{
-
-	 history_create_menu_history (p_dialer_data);
-
-	MokoFingerWindow* window=NULL;
-      MokoFingerToolBox *tools = NULL;
-	GtkWidget* button;
-	GtkWidget* image;
-
-//now the container--window
-     window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-     p_dialer_data->window_history=window;
-
-    
-     moko_finger_window_set_contents(window, create_window_history_content(p_dialer_data));
-
-     g_signal_connect ((gpointer) window, "show",
-	                    G_CALLBACK (on_window_history_show),
-	                    p_dialer_data);
-    g_signal_connect ((gpointer) window, "hide",
-	                    G_CALLBACK (on_window_history_hide),
-	                    p_dialer_data);
-
-    
-     
-     gtk_widget_show_all( GTK_WIDGET(window) );
-
-//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
-
-
- //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all???
-   gtk_widget_show(GTK_WIDGET(moko_finger_window_get_wheel(window)));
-    
-    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)),
-		    "press_left_up",
-		    G_CALLBACK(openmoko_history_wheel_press_left_up_cb),
-		    p_dialer_data);
-    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)),
-		    "press_right_down",
-		    G_CALLBACK(openmoko_history_wheel_press_right_down_cb),
-		    p_dialer_data);
-
-
-
-        tools = moko_finger_window_get_toolbox(window);
-     
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("phone.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-        g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_call_clicked), p_dialer_data);
-	
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("sms.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_sms_clicked), p_dialer_data);
-	
-
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("delete.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_delete_clicked), p_dialer_data);
-	gtk_widget_show(GTK_WIDGET(tools));
-
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("tony.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_back_clicked), p_dialer_data);
-	gtk_widget_show(GTK_WIDGET(tools));
-	
-	p_dialer_data->wheel_history=moko_finger_window_get_wheel(window);
-	p_dialer_data->toolbox_history=tools;
-
-	gtk_widget_hide(window);
-
-	DBG_LEAVE();
-}
-else
-{
-	//here we have to refresh it.
-	DBG_TRACE();
-}
-    return 1;
-}
-
-void on_treeviewHistory_cursor_changed      (GtkTreeView     *treeview,
-                                        gpointer         user_data)
-{
-GtkTreeIter iter;
-GtkTreeModel* model;
-GtkTreeSelection * selection;
-HISTORY_ENTRY * p;
-int hasname;
-MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	
-selection = gtk_tree_view_get_selection(p_dialer_data->treeview_history);
- 
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- {
- 	 p_dialer_data->g_currentselected=0;
-	 return ;
- }
-	
-gtk_tree_model_get(model,&iter,COLUMN_ENTRYPOINTER,&p,-1);
-
- p_dialer_data->g_currentselected=p;
-
-gtk_tree_model_get(model,&iter,COLUMN_HASNAME,&hasname,-1);
-history_update_counter(p_dialer_data);
-
-}
-
-
-
-GtkWidget* create_window_history_content (MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-  GtkWidget *treeviewHistory;
-  GtkWidget *vbox=gtk_vbox_new(FALSE,0); 
-  //FIRST of all, the top title area;
-  GtkWidget *eventboxTop = gtk_event_box_new ();
-  gtk_widget_show (eventboxTop);
-  gtk_box_pack_start(GTK_BOX(vbox),eventboxTop,FALSE,FALSE,5);
-  gtk_widget_set_size_request (eventboxTop, 480, 64);
-  gtk_widget_set_name(eventboxTop,"gtkeventbox-black");
-	
-  GtkWidget *  hbox67 = gtk_hbox_new (FALSE, 0);
-  gtk_widget_show (hbox67);
-  gtk_container_add (GTK_CONTAINER (eventboxTop), hbox67);
-
-  GtkWidget * eventboxLeftTop = gtk_event_box_new ();
-  gtk_widget_show (eventboxLeftTop);
-  gtk_box_pack_start (GTK_BOX (hbox67), eventboxLeftTop, FALSE, TRUE, 0);
-  gtk_widget_set_name(eventboxLeftTop,"gtkeventbox-black");
-
-
-
-  GtkWidget * imageLeftMenu =file_new_image_from_relative_path("all.png");
-  gtk_widget_show (imageLeftMenu);
-  gtk_container_add (GTK_CONTAINER (eventboxLeftTop), imageLeftMenu);
-
-  GtkWidget *labelHistoryTitle = gtk_label_new (("History-"));
-  gtk_widget_show (labelHistoryTitle);
-  gtk_box_pack_start (GTK_BOX (hbox67), labelHistoryTitle, FALSE, FALSE, 0);
-  gtk_widget_set_size_request (labelHistoryTitle, 221, -1);
-  gtk_label_set_justify (GTK_LABEL (labelHistoryTitle), GTK_JUSTIFY_RIGHT);
-  gtk_misc_set_alignment (GTK_MISC (labelHistoryTitle), 1, 0.5);
-
-  GtkWidget *labelFilter = gtk_label_new (("All"));
-  gtk_widget_show (labelFilter);
-  gtk_box_pack_start (GTK_BOX (hbox67), labelFilter, TRUE, TRUE, 0);
-  gtk_misc_set_alignment (GTK_MISC (labelFilter), 0, 0.5);
-  p_dialer_data->label_filter_history=labelFilter;
-
-  GtkWidget *labelCounter = gtk_label_new (("1/21"));
-  gtk_widget_show (labelCounter);
-  gtk_box_pack_start (GTK_BOX (hbox67), labelCounter, TRUE, TRUE, 0);
-  gtk_label_set_justify (GTK_LABEL (labelCounter), GTK_JUSTIFY_RIGHT);
-  gtk_misc_set_alignment (GTK_MISC (labelCounter), 0.8, 0.5);
-  p_dialer_data->label_counter_history=labelCounter;
- 
-    g_signal_connect ((gpointer) eventboxTop, "button_release_event",
-                    G_CALLBACK (on_eventboxTop_button_release_event),
-                    p_dialer_data);
-
-  GtkWidget *align=gtk_alignment_new(0,0,1,1);
-  gtk_alignment_set_padding(align, 0, 150, 0, 0); //FIXME too many numbers has to be retrieved from style
-  
-  GtkWidget *scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
-  gtk_widget_show (scrolledwindow);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
- 
-  treeviewHistory = gtk_tree_view_new ();
-  gtk_container_add (GTK_CONTAINER (align), scrolledwindow);
-  gtk_container_add (GTK_CONTAINER (scrolledwindow), treeviewHistory);
-
-  gtk_widget_show (treeviewHistory);
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeviewHistory), FALSE);
-  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeviewHistory), FALSE);
-//   gtk_misc_set_alignment (GTK_MISC (treeviewHistory), 0.5, 0.5);
-  gtk_box_pack_start(GTK_BOX(vbox),align,TRUE,TRUE,0);
-
-
-  gtk_widget_set_name(treeviewHistory,"gtktreeview-black");
-  p_dialer_data->treeview_history=treeviewHistory;
-   history_build_history_list_view(p_dialer_data);
-  gtk_widget_set_size_request (scrolledwindow, -1, 400);    
-//  gtk_misc_set_alignment (GTK_MISC (treeviewHistory),1,0.1);
-
-
-  g_signal_connect ((gpointer) treeviewHistory, "cursor_changed",
-                    G_CALLBACK (on_treeviewHistory_cursor_changed),
-                    p_dialer_data);
-
-
-  return vbox;
-}
-
-
-/**
- * @brief re-filter the treeview widget by current history type,a callback when the history treeview refreshes
- *
- * this callback will be called for every treemodel iters,whenever the treeview filter is refreshing
- *
- * @param model GtkTreeModel *, the background database of the treeview
- * @param iter GtkTreeIter *, the iterator of every item of the model.
- * @param  data gpointer , of no use currently
- * @return boolean
- * @retval TRUE means the iter will be displayed
- * @retval  FALSE means the iter will not be displayed
- */
-static gboolean history_view_filter_visible_function(GtkTreeModel *model,GtkTreeIter *iter,gpointer data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )data;
-	HISTORY_TYPE type;
-	if(p_dialer_data->g_history_filter_type==ALL)
-		return TRUE;
-	gtk_tree_model_get(model,iter,COLUMN_TYPE,&type,-1);
-	if(type==p_dialer_data->g_history_filter_type)
-		return TRUE;
-	else
-		return FALSE;
-}
-
-
-
-/**
- * @brief find the treeview in the window, fill-in the data and show it on the screen.
- *
- *
- *
- * @param window GtkWidget* the window which contains the history treeview. but it's not necessarilly
- *to be a window, any widget that can help to lookup the treeview will be OK.
- * @return 
- * @retval 0 error occured
- * @retval 1 everything is OK
- */
-
-gint history_build_history_list_view(MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-	GtkListStore * list_store;
-	
-	GtkTreeIter iter;
-	HISTORY_ENTRY * entry;
-	
-	//copied
-	GtkTreeViewColumn   *col;
-  	GtkCellRenderer     *renderer;
-  	
-  	//GtkTreeModel        *model;
-	GtkWidget           *contactview=NULL;
-	
-	//DBG_ENTER();
-	//DBG_MESSAGE("History:%d",g_historylist.length);
-	
-	//DBG_TRACE();
-  p_dialer_data->g_history_filter_type=ALL;
-  contactview = p_dialer_data->treeview_history;
-
-  if(contactview == NULL)
-    return 0;
-//pack image and label
-  col = gtk_tree_view_column_new ();
-
-  gtk_tree_view_column_set_title (col, ("Title"));
-  gtk_tree_view_column_set_resizable (col, TRUE);
- 
-	
-  
-  renderer = gtk_cell_renderer_pixbuf_new ();
-  gtk_tree_view_column_pack_start (col, renderer, FALSE);
-  gtk_tree_view_column_set_attributes (col, renderer, 
-  "pixbuf",COLUMN_TYPEICON,NULL);
-
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (col, renderer, FALSE);
-  gtk_tree_view_column_set_attributes(col, renderer, 
-  "text",COLUMN_TIME,NULL);
- 
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (col, renderer, FALSE);
-  gtk_tree_view_column_set_attributes(col, renderer, 
-  "text",COLUMN_SEPRATE,NULL);
- 
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (col, renderer, TRUE);
-  gtk_tree_view_column_set_attributes(col, renderer, 
-  "text",COLUMN_NAME_NUMBER,NULL);
-
-
-   gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col);
-
-
-	entry=p_dialer_data->g_historylist.first;
-	
-	list_store=gtk_list_store_new(N_COLUMN,	G_TYPE_INT,GDK_TYPE_PIXBUF,
-					G_TYPE_STRING,	G_TYPE_STRING,	
-					G_TYPE_STRING,	G_TYPE_INT,G_TYPE_POINTER,G_TYPE_INT,-1);
-	//we will use a filter to facilitate the filtering in treeview without rebuilding the database.				
-	p_dialer_data->g_list_store_filter=gtk_tree_model_filter_new(GTK_TREE_MODEL(list_store),NULL);
-	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(p_dialer_data->g_list_store_filter),
-	history_view_filter_visible_function,p_dialer_data,NULL);
-
-//load the three icons to memory.
-GError *error=NULL;	
-		p_dialer_data->g_iconReceived=create_pixbuf("received.png",&error);
-  		if(error)
-				{
-					DBG_WARN("Cound not load icon :%s",error->message);
-					g_error_free(error);
-					p_dialer_data->g_iconReceived=NULL;
-					error=NULL;
-				}
-
-		p_dialer_data->g_iconDialed=create_pixbuf("dialed.png",&error);
-		if(error)
-				{
-					DBG_WARN("Cound not load icon :%s",error->message);
-					g_error_free(error);
-					p_dialer_data->g_iconDialed=NULL;
-					error=NULL;
-				}
-
-  
-		 p_dialer_data->g_iconMissed=create_pixbuf("missed.png",&error);
-		if(error)
-				{
-					DBG_WARN("Cound not load icon :%s",error->message);
-					g_error_free(error);
-					p_dialer_data->g_iconMissed=NULL;
-					error=NULL;
-				}
-
-
-	while(entry)
-	{
-		//DBG_MESSAGE(entry->number);
-		gtk_list_store_append(list_store,&iter);
-		gtk_list_store_set(list_store,&iter,COLUMN_TYPE,entry->type,COLUMN_SEPRATE,"--",
-		COLUMN_TIME,entry->time,COLUMN_DURATION,entry->durationsec,COLUMN_ENTRYPOINTER,entry,COLUMN_HASNAME,0,-1);
-		if(entry->name==0)
-		{
-		//DBG_MESSAGE(entry->number);
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->number,-1);
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,0,-1);
-		}
-		else
-		{
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->name,-1);		
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,1,-1);
-		}
-		switch(entry->type)
-		{
-			case INCOMING:
-			{
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconReceived,-1);		
-			//	icon=gdk_pixbuf_new_from_file("./received.png",&error);
-				break;
-			}
-			case OUTGOING:
-			{//	icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconDialed,-1);		
-				break;
-			}
-			case MISSED:
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconMissed,-1);		
-				break;
-			}
-
-			default:
-			
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconMissed,-1);		
-				break;
-			}
-		}
-						
-
-		
-		entry=entry->next;
-	}
-	
-  gtk_tree_view_set_model (GTK_TREE_VIEW(contactview),GTK_TREE_MODEL(p_dialer_data->g_list_store_filter));
-
-  g_object_unref (list_store);
-
-  return 1;
-}
-
-
-/**
- * @brief update the counter display widget - labelCounter
- *
- * @param widget GtkWidget*, any widget in the same window with treeviewHistory and labelCounter
- *
- * @return 1
- */
-gint history_update_counter(MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-DBG_ENTER();
-GtkTreeIter iter;
-GtkTreeModel* model;
-GtkTreeSelection * selection;
-GtkTreePath *path;
-GtkTreeView * treeview;
-int count=0;
-int nth=0;
-char * pathstring;
-char display[10];
-	
-treeview=GTK_TREE_VIEW(p_dialer_data->treeview_history);
-if(!p_dialer_data->treeview_history)
-{
-DBG_WARN("COUNTER NOT READY ");
-return 0;
-}
-
-
-model=gtk_tree_view_get_model(treeview);	
-
-count=gtk_tree_model_iter_n_children(model,NULL);
-	
-selection = gtk_tree_view_get_selection(treeview);
- 
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-{
-	nth=0;
-}
-else
-{
-path=gtk_tree_model_get_path(model,&iter);
-pathstring=gtk_tree_path_to_string(path);
-nth=atoi(pathstring)+1;
-gtk_tree_path_free(path);	
-
-}
-	
-GtkWidget *labelcounter;
-labelcounter=p_dialer_data->label_counter_history;
-sprintf(display,"%d/%d",nth,count);
-gtk_label_set_text(GTK_LABEL(labelcounter),display);
-return 1;	
-
-}
-
-GtkWidget* history_create_menu_history (MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-if(!p_dialer_data->menu_history)
-{
-  GtkWidget *menu_history;
-  GtkWidget *all_calls;
-  GtkWidget *imageAll;
-  GtkWidget *separator1;
-  GtkWidget *missed_calls;
-  GtkWidget *imageMissed;
-  GtkWidget *separator3;
-  GtkWidget *dialed_calls;
-  GtkWidget *imageDialed;
-  GtkWidget *separator2;
-  GtkWidget *received_calls;
-  GtkWidget *imageReceived;
-
-  menu_history = gtk_menu_new ();
-  gtk_container_set_border_width (GTK_CONTAINER (menu_history), 2);
-
-  all_calls = gtk_image_menu_item_new_with_mnemonic (("Calls All"));
-  gtk_widget_show (all_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), all_calls);
-  gtk_widget_set_size_request (all_calls, 250, 60);
-
-
-  imageAll =file_new_image_from_relative_path("all.png");
-  gtk_widget_show (imageAll);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (all_calls), imageAll);
-
-  separator1 = gtk_separator_menu_item_new ();
-  gtk_widget_show (separator1);
-  gtk_container_add (GTK_CONTAINER (menu_history), separator1);
-  gtk_widget_set_size_request (separator1, 120, -1);
-  gtk_widget_set_sensitive (separator1, FALSE);
-
-  missed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Missed "));
-  gtk_widget_show (missed_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), missed_calls);
-  gtk_widget_set_size_request (missed_calls, 120, 60);
-
-  //imageMissed = gtk_image_new_from_stock ("gtk-goto-bottom", GTK_ICON_SIZE_MENU);
-  imageMissed =file_new_image_from_relative_path("missed.png");
-  
-  gtk_widget_show (imageMissed);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (missed_calls), imageMissed);
-
-  separator3 = gtk_separator_menu_item_new ();
-  gtk_widget_show (separator3);
-  gtk_container_add (GTK_CONTAINER (menu_history), separator3);
-  gtk_widget_set_size_request (separator3, 120, -1);
-  gtk_widget_set_sensitive (separator3, FALSE);
-
-  dialed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Dialed"));
-  gtk_widget_show (dialed_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), dialed_calls);
-  gtk_widget_set_size_request (dialed_calls, 120, 60);
-
- // imageDialed = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU);
-  imageDialed =file_new_image_from_relative_path("dialed.png");
-  gtk_widget_show (imageDialed);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialed_calls), imageDialed);
-
-  separator2 = gtk_separator_menu_item_new ();
-  gtk_widget_show (separator2);
-  gtk_container_add (GTK_CONTAINER (menu_history), separator2);
-  gtk_widget_set_size_request (separator2, 120, -1);
-  gtk_widget_set_sensitive (separator2, FALSE);
-
-  received_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Received "));
-  gtk_widget_show (received_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), received_calls);
-  gtk_widget_set_size_request (received_calls, 120, 60);
-
-//  imageReceived = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU);
- imageReceived=file_new_image_from_relative_path("received.png");
-  gtk_widget_show (imageReceived);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (received_calls), imageReceived);
-
-  g_signal_connect ((gpointer) all_calls, "activate",
-                    G_CALLBACK (on_all_calls_activate),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) missed_calls, "activate",
-                    G_CALLBACK (on_missed_calls_activate),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) dialed_calls, "activate",
-                    G_CALLBACK (on_dialed_calls_activate),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) received_calls, "activate",
-                    G_CALLBACK (on_received_calls_activate),
-                    p_dialer_data);
-
-p_dialer_data->menu_history=menu_history;
-  return menu_history;
-}
-else
-	return p_dialer_data->menu_history;
-}
-
-
-
-/**
- * @brief add an entry to the history treeview
- *
- *
- *
- * @param entry HISTORY_ENTRY *, the history entry to be added to the treeview.
- * @return 
- * @retval 0 error occured
- * @retval 1 everything is OK
- */
-gint history_list_view_add(MOKO_DIALER_APP_DATA* appdata,HISTORY_ENTRY * entry)
-{
-DBG_ENTER();
-if(entry==0)
-	{
-		DBG_ERROR("THE ENTRY IS ZERO");
-		return 0;
-	}
-
-if(appdata->treeview_history==0)
-{
-		DBG_WARN("not ready");
-		return 0;
-
-}
-	//
-GtkTreeIter iter; //iter of the filter store
-GtkTreeModel* model;
-GtkListStore* list_store;
-GtkTreeView* treeview;
-
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
-
-model=gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(appdata->g_list_store_filter));	
-
-list_store=GTK_LIST_STORE(model);
-	//
-	
-	
-	//DBG_MESSAGE(entry->number);
-		gtk_list_store_insert(list_store,&iter,0);
-		gtk_list_store_set(list_store,&iter,COLUMN_TYPE,entry->type,COLUMN_SEPRATE,"--",
-		COLUMN_TIME,entry->time,COLUMN_DURATION,entry->durationsec,COLUMN_ENTRYPOINTER,entry,COLUMN_HASNAME,0,-1);
-		if(entry->name==0)
-		{
-		//DBG_MESSAGE(entry->number);
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->number,-1);
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,0,-1);
-		}
-		else
-		{
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->name,-1);		
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,1,-1);
-		}
-		switch(entry->type)
-		{
-			case INCOMING:
-			{
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconReceived,-1);		
-			//	icon=gdk_pixbuf_new_from_file("./received.png",&error);
-				break;
-			}
-			case OUTGOING:
-			{//	icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconDialed,-1);		
-				break;
-			}
-			case MISSED:
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconMissed,-1);		
-				break;
-			}
-
-			default:
-			
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconMissed,-1);		
-				break;
-			}
-		}
-history_update_counter(appdata); 
-return 1;	
-}
-
-
-gint add_histroy_entry(MOKO_DIALER_APP_DATA* appdata,HISTORY_TYPE type,const char *name,const char *number,const char *picpath,  char *time,char *date,int durationsec)
-{
-//DBG_ENTER();
-
-	//DBG_MESSAGE("History add:%s,%s,%s,%s,%s,%d",name,number,picpath,time,date,durationsec);
- HISTORY_ENTRY * pentry=history_add_entry(&(appdata->g_historylist),type,name,number,picpath,time,date,durationsec);	
- return history_list_view_add(appdata,pentry);	
-}
-
-
+//DBG_ENTER();
+    //DBG_MESSAGE("History add:%s,%s,%s,%s,%s,%d",name,number,picpath,time,date,durationsec);
+    HISTORY_ENTRY * pentry =
+    history_add_entry (&(appdata->g_historylist), type, name, number, picpath,
+                       time, date, durationsec);
+  return history_list_view_add (appdata, pentry);
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,44 +1,49 @@
-/*  openmoko-dialer-window-history.h
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #include "moko-dialer-includes.h"
-
- #ifndef _OPENMOKO_DIALER_WINDOW_HISTORY_H
-#define _OPENMOKO_DIALER_WINDOW_HISTORY_H
-
-#ifdef __cplusplus
-
-
-
-extern "C"
-
-{
-#endif
-
-
- GtkWidget* create_window_history_content (MOKO_DIALER_APP_DATA* p_dialer_data);
-gint window_history_init( MOKO_DIALER_APP_DATA* p_dialer_data);
-gint history_build_history_list_view(MOKO_DIALER_APP_DATA* p_dialer_data);
-void window_history_prepare(MOKO_DIALER_APP_DATA * appdata);
-GtkWidget* history_create_menu_history (MOKO_DIALER_APP_DATA* p_dialer_data);
-gint add_histroy_entry(MOKO_DIALER_APP_DATA* appdata,HISTORY_TYPE type,const char *name,const char *number,const char *picpath,  char *time,char *date,int durationsec);
-gint history_list_view_add(MOKO_DIALER_APP_DATA* appdata,HISTORY_ENTRY * entry);
-#ifdef __cplusplus
-}
-#endif
-
-#endif 
+/*  openmoko-dialer-window-history.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-includes.h"
+
+#ifndef _OPENMOKO_DIALER_WINDOW_HISTORY_H
+#define _OPENMOKO_DIALER_WINDOW_HISTORY_H
+
+#ifdef __cplusplus
+
+
+
+extern "C"
+{
+#endif
+
+
+  GtkWidget *create_window_history_content (MOKO_DIALER_APP_DATA *
+                                            p_dialer_data);
+  gint window_history_init (MOKO_DIALER_APP_DATA * p_dialer_data);
+  gint history_build_history_list_view (MOKO_DIALER_APP_DATA * p_dialer_data);
+  void window_history_prepare (MOKO_DIALER_APP_DATA * appdata);
+  GtkWidget *history_create_menu_history (MOKO_DIALER_APP_DATA *
+                                          p_dialer_data);
+  gint add_histroy_entry (MOKO_DIALER_APP_DATA * appdata, HISTORY_TYPE type,
+                          const char *name, const char *number,
+                          const char *picpath, char *time, char *date,
+                          int durationsec);
+  gint history_list_view_add (MOKO_DIALER_APP_DATA * appdata,
+                              HISTORY_ENTRY * entry);
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,305 +1,317 @@
-/*   openmoko-dialer-window-incoming.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
-#include <libmokoui/moko-finger-tool-box.h>
-#include <libmokoui/moko-finger-window.h>
-#include <libmokoui/moko-finger-wheel.h>
-#include <libmokoui/moko-pixmap-button.h>
-
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkvbox.h>
-#include "contacts.h"
-#include "openmoko-dialer-main.h"
-#include "moko-dialer-status.h"
-#include "openmoko-dialer-window-incoming.h"
-
-void cb_answer_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-
-appdata->g_state.callstate=STATE_TALKING;
-gsm_answer();
-
-gtk_widget_hide(appdata->window_incoming);
-
-if(!appdata->window_talking)
-	window_talking_init(appdata);
-
-//transfer the contact info
-window_talking_prepare(appdata);
-
-
-gtk_widget_show(appdata->window_talking);
-
-DBG_LEAVE();
-}
-
-void cb_ignore_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-DBG_MESSAGE("We will mute the phone for this call.");
-appdata->g_state.callstate=STATE_IGNORED;
-DBG_LEAVE();
-}
-
-void cb_reject_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-gsm_hangup();
-appdata->g_state.callstate=STATE_REJECTED;
-gtk_widget_hide(appdata->window_incoming);
-DBG_LEAVE();
-}
-
-void window_incoming_prepare(MOKO_DIALER_APP_DATA * appdata)
-{
-if(!appdata)
-{
-DBG_WARN("appdata=NULL!");
-return;
-}
-
-if(appdata->window_incoming==0)
-{
-window_incoming_init(appdata);
-}
-
-   moko_dialer_status_set_person_number(appdata->status_incoming, appdata->g_peer_info.number);
-if(appdata->g_peer_info.hasname)
-{
-   moko_dialer_status_set_person_image(appdata->status_incoming, appdata->g_peer_info.picpath);  
-   moko_dialer_status_set_person_name(appdata->status_incoming, appdata->g_peer_info.name);
-}
-else
-{
-   moko_dialer_status_set_person_image(appdata->status_incoming, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);  
-   moko_dialer_status_set_person_name(appdata->status_incoming, "");
-
-}
-
-
-
-}
-
-gint window_incoming_fails(MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-DBG_LEAVE();     
-}
-
-gint timer_incoming_time_out(MOKO_DIALER_APP_DATA * appdata)
-{
-//DBG_ENTER();
-TIMER_DATA* timer_data=&(appdata->g_timer_data);
-
-/*	
-timer_data->ticks++;
-timer_data->hour=timer_data->ticks/3600;
-timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60;
-timer_data->sec=timer_data->ticks%60;
-
-
-sprintf(timer_data->timestring,"%02d:%02d:%02d",timer_data->hour,timer_data->min,timer_data->sec);
-//ok,we update the label now.
-moko_dialer_status_set_status_label(appdata->status_incoming,timer_data->timestring);
-moko_dialer_status_update_icon(appdata->status_incoming);
-*/
-if(event_get_keep_calling())
-{
-	event_reset_keep_calling();
-	timer_data->ticks=0;
-}
-else
-{	//we count 4 before we confirm that there are no calling at all.
-	if(timer_data->ticks>=3)
-	{
-		DBG_MESSAGE("THE CALLER aborted, we quit.");
-		gsm_hangup();
-		appdata->g_state.callstate=STATE_MISSED;
-		appdata->g_state.historytype=MISSED;
-		gdk_threads_enter();
-		gtk_widget_hide(appdata->window_incoming);
-		gdk_threads_leave();
-		return 0; //don't lookout the timeout.
-	}
-	else
-	{
-	DBG_MESSAGE("ticks=%d",timer_data->ticks);
-	timer_data->ticks++;
-	}
-}
-
-return 1;
-
-
-}
-
-
-
-void
-on_window_incoming_hide                 (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-if(appdata->g_timer_data.ptimer!=0)
-{
-gtk_timeout_remove(appdata->g_timer_data.ptimer);
-appdata->g_timer_data.ptimer=0;
-}
-
-event_reset_clip_signaled();
-event_reset_incoming_signaled();
-event_reset_keep_calling();
-
-if(appdata->g_state.callstate!=STATE_TALKING)
-{//	add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0);
-
-add_histroy_entry(appdata,appdata->g_state.historytype,
-	appdata->g_peer_info.name,
-	appdata->g_peer_info.number,
-	appdata->g_peer_info.picpath,
-	appdata->g_state.starttime,
-	appdata->g_state.startdate,
-	0);
-
-}
-
-}
-
-gint window_incoming_setup_timer(MOKO_DIALER_APP_DATA * appdata)
-{
-time_t timep;
-struct tm *p;
-time(&timep);
-p=localtime(&timep);
-
-sprintf(appdata->g_state.starttime,"%02d:%02d:%02d",p->tm_hour,p->tm_min,p->tm_sec);
-sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year,p->tm_mon,p->tm_mday);
-
-if(appdata->g_timer_data.ptimer!=0)
-{
-gtk_timeout_remove(appdata->g_timer_data.ptimer);
-appdata->g_timer_data.ptimer=0;
-}
-
-memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data));
-
-appdata->g_timer_data.stopsec=0;
-
-appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_incoming_time_out,appdata);
-
-
-}
-
-void
-on_window_incoming_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-
-appdata->g_state.callstate=STATE_INCOMING;
-window_incoming_setup_timer(appdata);
-
-
-}
-
-
-gint window_incoming_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-DBG_ENTER();
-MokoFingerWindow* window;
-GtkWidget* vbox;
-MokoDialerStatus * status;
-
-if(p_dialer_data->window_incoming==0)
-{
-
-  vbox = gtk_vbox_new( FALSE, 0 );
-   status=moko_dialer_status_new();
-   moko_dialer_status_add_status_icon(status,"status0.png");
-   moko_dialer_status_add_status_icon(status,"status1.png");
-   moko_dialer_status_add_status_icon(status,"status2.png");
-   moko_dialer_status_set_icon_by_index(status,0);
-   
-   gtk_box_pack_start( GTK_BOX(vbox),status, FALSE, FALSE, 0 );
-
- 	
-    GtkHBox *  hbox2 = gtk_hbox_new( FALSE, 0 );
-    GtkButton* button = gtk_button_new_with_label("Answer");
-    g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_answer_button_clicked), p_dialer_data );
-
-    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10);
-
-  button = gtk_button_new_with_label("Ignore");
-  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_ignore_button_clicked), p_dialer_data );
-  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 10 );
-
-
-
-button = gtk_button_new_with_label("Reject");
- g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_reject_button_clicked), p_dialer_data );
- gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10);
-
-
-
-
-   gtk_box_pack_start( GTK_BOX(vbox),hbox2, FALSE, FALSE, 50 );
-
-
-//currently     MokoDialogWindow is not finished, wating...
-//   MokoDialogWindow* window = (MokoDialogWindow *)(moko_dialog_window_new());
-//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) );
-
-    window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-    moko_finger_window_set_contents(window, GTK_WIDGET(vbox) );
-
-
-     gtk_widget_show_all( GTK_WIDGET(window) );
-
-
-     gtk_widget_hide( GTK_WIDGET(window) );   
-
-
-   moko_dialer_status_set_title_label(status, "Incoming call");
-   moko_dialer_status_set_status_label(status, "");
-
-   p_dialer_data->window_incoming=window;
-   p_dialer_data->status_incoming=status;
-   
-//   DBG_MESSAGE("p_dialer_data->status_incoming=0X%x",p_dialer_data->status_incoming);
-
-
-  g_signal_connect ((gpointer) window, "show",
-                    G_CALLBACK (on_window_incoming_show),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) window, "hide",
-                    G_CALLBACK (on_window_incoming_hide),
-                    p_dialer_data);
-
-}
-
-
-DBG_LEAVE();
-    return 1;
-}
-
+/*   openmoko-dialer-window-incoming.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkvbox.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "moko-dialer-status.h"
+#include "openmoko-dialer-window-incoming.h"
+
+void
+cb_answer_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+  appdata->g_state.callstate = STATE_TALKING;
+  gsm_answer ();
+
+  gtk_widget_hide (appdata->window_incoming);
+
+  if (!appdata->window_talking)
+    window_talking_init (appdata);
+
+//transfer the contact info
+  window_talking_prepare (appdata);
+
+
+  gtk_widget_show (appdata->window_talking);
+
+  DBG_LEAVE ();
+}
+
+void
+cb_ignore_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  DBG_MESSAGE ("We will mute the phone for this call.");
+  appdata->g_state.callstate = STATE_IGNORED;
+  DBG_LEAVE ();
+}
+
+void
+cb_reject_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  gsm_hangup ();
+  appdata->g_state.callstate = STATE_REJECTED;
+  gtk_widget_hide (appdata->window_incoming);
+  DBG_LEAVE ();
+}
+
+void
+window_incoming_prepare (MOKO_DIALER_APP_DATA * appdata)
+{
+  if (!appdata)
+  {
+    DBG_WARN ("appdata=NULL!");
+    return;
+  }
+
+  if (appdata->window_incoming == 0)
+  {
+    window_incoming_init (appdata);
+  }
+
+  moko_dialer_status_set_person_number (appdata->status_incoming,
+                                        appdata->g_peer_info.number);
+  if (appdata->g_peer_info.hasname)
+  {
+    moko_dialer_status_set_person_image (appdata->status_incoming,
+                                         appdata->g_peer_info.picpath);
+    moko_dialer_status_set_person_name (appdata->status_incoming,
+                                        appdata->g_peer_info.name);
+  }
+  else
+  {
+    moko_dialer_status_set_person_image (appdata->status_incoming,
+                                         MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+    moko_dialer_status_set_person_name (appdata->status_incoming, "");
+
+  }
+
+
+
+}
+
+gint
+window_incoming_fails (MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  DBG_LEAVE ();
+}
+
+gint
+timer_incoming_time_out (MOKO_DIALER_APP_DATA * appdata)
+{
+//DBG_ENTER();
+  TIMER_DATA *timer_data = &(appdata->g_timer_data);
+
+/*	
+timer_data->ticks++;
+timer_data->hour=timer_data->ticks/3600;
+timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60;
+timer_data->sec=timer_data->ticks%60;
+
+
+sprintf(timer_data->timestring,"%02d:%02d:%02d",timer_data->hour,timer_data->min,timer_data->sec);
+//ok,we update the label now.
+moko_dialer_status_set_status_label(appdata->status_incoming,timer_data->timestring);
+moko_dialer_status_update_icon(appdata->status_incoming);
+*/
+  if (event_get_keep_calling ())
+  {
+    event_reset_keep_calling ();
+    timer_data->ticks = 0;
+  }
+  else
+  {                             //we count 4 before we confirm that there are no calling at all.
+    if (timer_data->ticks >= 3)
+    {
+      DBG_MESSAGE ("THE CALLER aborted, we quit.");
+      gsm_hangup ();
+      appdata->g_state.callstate = STATE_MISSED;
+      appdata->g_state.historytype = MISSED;
+      gdk_threads_enter ();
+      gtk_widget_hide (appdata->window_incoming);
+      gdk_threads_leave ();
+      return 0;                 //don't lookout the timeout.
+    }
+    else
+    {
+      DBG_MESSAGE ("ticks=%d", timer_data->ticks);
+      timer_data->ticks++;
+    }
+  }
+
+  return 1;
+
+
+}
+
+
+
+void
+on_window_incoming_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  if (appdata->g_timer_data.ptimer != 0)
+  {
+    gtk_timeout_remove (appdata->g_timer_data.ptimer);
+    appdata->g_timer_data.ptimer = 0;
+  }
+
+  event_reset_clip_signaled ();
+  event_reset_incoming_signaled ();
+  event_reset_keep_calling ();
+
+  if (appdata->g_state.callstate != STATE_TALKING)
+  {                             //     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0);
+
+    add_histroy_entry (appdata, appdata->g_state.historytype,
+                       appdata->g_peer_info.name,
+                       appdata->g_peer_info.number,
+                       appdata->g_peer_info.picpath,
+                       appdata->g_state.starttime,
+                       appdata->g_state.startdate, 0);
+
+  }
+
+}
+
+gint
+window_incoming_setup_timer (MOKO_DIALER_APP_DATA * appdata)
+{
+  time_t timep;
+  struct tm *p;
+  time (&timep);
+  p = localtime (&timep);
+
+  sprintf (appdata->g_state.starttime, "%02d:%02d:%02d", p->tm_hour,
+           p->tm_min, p->tm_sec);
+  sprintf (appdata->g_state.startdate, "%04d/%02d/%02d", p->tm_year,
+           p->tm_mon, p->tm_mday);
+
+  if (appdata->g_timer_data.ptimer != 0)
+  {
+    gtk_timeout_remove (appdata->g_timer_data.ptimer);
+    appdata->g_timer_data.ptimer = 0;
+  }
+
+  memset (&(appdata->g_timer_data), 0, sizeof (appdata->g_timer_data));
+
+  appdata->g_timer_data.stopsec = 0;
+
+  appdata->g_timer_data.ptimer =
+    gtk_timeout_add (1000, timer_incoming_time_out, appdata);
+
+
+}
+
+void
+on_window_incoming_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+
+  appdata->g_state.callstate = STATE_INCOMING;
+  window_incoming_setup_timer (appdata);
+
+
+}
+
+
+gint
+window_incoming_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  DBG_ENTER ();
+  MokoFingerWindow *window;
+  GtkWidget *vbox;
+  MokoDialerStatus *status;
+
+  if (p_dialer_data->window_incoming == 0)
+  {
+
+    vbox = gtk_vbox_new (FALSE, 0);
+    status = moko_dialer_status_new ();
+    moko_dialer_status_add_status_icon (status, "status0.png");
+    moko_dialer_status_add_status_icon (status, "status1.png");
+    moko_dialer_status_add_status_icon (status, "status2.png");
+    moko_dialer_status_set_icon_by_index (status, 0);
+
+    gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, FALSE, 0);
+
+
+    GtkHBox *hbox2 = gtk_hbox_new (FALSE, 0);
+    GtkButton *button = gtk_button_new_with_label ("Answer");
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_answer_button_clicked), p_dialer_data);
+
+    gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 10);
+
+    button = gtk_button_new_with_label ("Ignore");
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_ignore_button_clicked), p_dialer_data);
+    gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 10);
+
+
+
+    button = gtk_button_new_with_label ("Reject");
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_reject_button_clicked), p_dialer_data);
+    gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 10);
+
+
+
+
+    gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 50);
+
+
+//currently     MokoDialogWindow is not finished, wating...
+//   MokoDialogWindow* window = (MokoDialogWindow *)(moko_dialog_window_new());
+//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) );
+
+    window = MOKO_FINGER_WINDOW (moko_finger_window_new ());
+    moko_finger_window_set_contents (window, GTK_WIDGET (vbox));
+
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+
+    gtk_widget_hide (GTK_WIDGET (window));
+
+
+    moko_dialer_status_set_title_label (status, "Incoming call");
+    moko_dialer_status_set_status_label (status, "");
+
+    p_dialer_data->window_incoming = window;
+    p_dialer_data->status_incoming = status;
+
+//   DBG_MESSAGE("p_dialer_data->status_incoming=0X%x",p_dialer_data->status_incoming);
+
+
+    g_signal_connect ((gpointer) window, "show",
+                      G_CALLBACK (on_window_incoming_show), p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+                      G_CALLBACK (on_window_incoming_hide), p_dialer_data);
+
+  }
+
+
+  DBG_LEAVE ();
+  return 1;
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,41 +1,40 @@
-/*  openmoko-dialer-window-outgoing.h
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #include "moko-dialer-includes.h"
-
- #ifndef _OPENMOKO_DIALER_WINDOW_INCOMING_H
-#define _OPENMOKO_DIALER_WINDOW_INCOMING_H
-
-#ifdef __cplusplus
-
-
-
-extern "C"
-
-{
-#endif
-
-
-
-gint window_incoming_init( MOKO_DIALER_APP_DATA* p_dialer_data);
-
-void window_incoming_prepare(MOKO_DIALER_APP_DATA * appdata);
-#ifdef __cplusplus
-}
-#endif
-
-#endif 
+/*  openmoko-dialer-window-outgoing.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-includes.h"
+
+#ifndef _OPENMOKO_DIALER_WINDOW_INCOMING_H
+#define _OPENMOKO_DIALER_WINDOW_INCOMING_H
+
+#ifdef __cplusplus
+
+
+
+extern "C"
+{
+#endif
+
+
+
+  gint window_incoming_init (MOKO_DIALER_APP_DATA * p_dialer_data);
+
+  void window_incoming_prepare (MOKO_DIALER_APP_DATA * appdata);
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,313 +1,330 @@
-/*   openmoko-dialer-window-outgoing.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-
-#include <libmokoui/moko-finger-tool-box.h>
-#include <libmokoui/moko-finger-window.h>
-#include <libmokoui/moko-finger-wheel.h>
-#include <libmokoui/moko-pixmap-button.h>
-
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkvbox.h>
-#include "contacts.h"
-#include "openmoko-dialer-main.h"
-#include "moko-dialer-status.h"
-#include "openmoko-dialer-window-outgoing.h"
-
-void cb_speaker_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-//moko_dialer_status_update_icon(appdata->status_outgoing);
-
-
-appdata->g_state.callstate=STATE_TALKING;
-
-gtk_widget_hide(appdata->window_outgoing);
-
-if(!appdata->window_talking)
-	window_talking_init(appdata);
-
-//transfer the contact info
-window_talking_prepare(appdata);
-
-//start dialling.
-
-
-gtk_widget_show(appdata->window_talking);
-
-
-DBG_LEAVE();
-}
-
-void cb_redial_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-gtk_widget_hide(appdata->buttonRedial);
-gtk_widget_show( appdata->buttonSpeaker);
-moko_dialer_status_set_title_label(appdata->status_outgoing, "Outgoing call");
- moko_dialer_status_set_status_label(appdata->status_outgoing, "Calling ... (00:00:00)");
-window_outgoing_setup_timer(appdata);
-
-appdata->g_state.callstate=STATE_CALLING;
-appdata->g_state.historytype=OUTGOING;	
-gsm_dial(appdata->g_peer_info.number);
-
-DBG_LEAVE();
-}
-
-void cb_cancel_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-gsm_hangup();
-appdata->g_state.callstate=STATE_FAILED;
-gtk_widget_hide(appdata->window_outgoing);
-DBG_LEAVE();
-}
-
-void window_outgoing_prepare(MOKO_DIALER_APP_DATA * appdata)
-{
-if(appdata->window_outgoing==0)
-	window_outgoing_init( appdata);
-
-	
- moko_dialer_status_set_person_number(appdata->status_outgoing, appdata->g_peer_info.number);
-if(appdata->g_peer_info.hasname)
-{
-   moko_dialer_status_set_person_image(appdata->status_outgoing, appdata->g_peer_info.picpath);  
-   moko_dialer_status_set_person_name(appdata->status_outgoing, appdata->g_peer_info.name);
-}
-else
-{
-   moko_dialer_status_set_person_image(appdata->status_outgoing, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);  
-   moko_dialer_status_set_person_name(appdata->status_outgoing, "");
-
-}
-strcpy(appdata->g_state.lastnumber,appdata->g_peer_info.number);
-
-
-}
-
-gint window_outgoing_fails(MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-     moko_dialer_status_set_error(appdata->status_outgoing);
-     moko_dialer_status_set_title_label(appdata->status_outgoing, "Call Failure");
-     gtk_widget_hide( appdata->buttonSpeaker);
-     gtk_widget_show(appdata->buttonRedial);
-DBG_LEAVE();     
-}
-
-gint timer_outgoing_time_out(MOKO_DIALER_APP_DATA * appdata)
-{
-//DBG_ENTER();
-TIMER_DATA* timer_data=&(appdata->g_timer_data);
-
-	
-timer_data->ticks++;
-timer_data->hour=timer_data->ticks/3600;
-timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60;
-timer_data->sec=timer_data->ticks%60;
-
-
-sprintf(timer_data->timestring,"Calling ... (%02d:%02d:%02d)",timer_data->hour,timer_data->min,timer_data->sec);
-
-//ok,we update the label now.
-
-
-moko_dialer_status_set_status_label(appdata->status_outgoing,timer_data->timestring);
-moko_dialer_status_update_icon(appdata->status_outgoing);
-
-if(timer_data->stopsec!=0&&timer_data->ticks>=timer_data->stopsec)
-{
-
-timer_data->timeout=1;
-gtk_timeout_remove(timer_data->ptimer);
-timer_data->ptimer=0;
-//maybe it failes
-window_outgoing_fails(appdata);
-return 0;//0 stops the timer.
-}
-else
-return 1;
-}
-
-
-
-void
-on_window_outgoing_hide                 (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-if(appdata->g_timer_data.ptimer!=0)
-{
-gtk_timeout_remove(appdata->g_timer_data.ptimer);
-appdata->g_timer_data.ptimer=0;
-}
-if(appdata->g_state.callstate!=STATE_TALKING)
-{//	add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0);
-
-add_histroy_entry(appdata,appdata->g_state.historytype,
-	appdata->g_peer_info.name,
-	appdata->g_peer_info.number,
-	appdata->g_peer_info.picpath,
-	appdata->g_state.starttime,
-	appdata->g_state.startdate,
-	0);
-
-}
-
-
-
-}
-
-gint window_outgoing_setup_timer(MOKO_DIALER_APP_DATA * appdata)
-{
-time_t timep;
-struct tm *p;
-time(&timep);
-p=localtime(&timep);
-
-sprintf(appdata->g_state.starttime,"%02d:%02d:%02d",p->tm_hour,p->tm_min,p->tm_sec);
-sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year,p->tm_mon,p->tm_mday);
-
-if(appdata->g_timer_data.ptimer!=0)
-{
-gtk_timeout_remove(appdata->g_timer_data.ptimer);
-appdata->g_timer_data.ptimer=0;
-}
-
-memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data));
-// 1:30 timeout
-appdata->g_timer_data.stopsec=90;
-
-appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_outgoing_time_out,appdata);
-
-
-}
-
-void
-on_window_outgoing_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-
-
-window_outgoing_setup_timer(appdata);
-
-
-appdata->g_state.callstate=STATE_CALLING;
-appdata->g_state.historytype=OUTGOING;	
-gsm_dial(appdata->g_peer_info.number);
-
-
-}
-
-
-gint window_outgoing_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-DBG_ENTER();
-MokoFingerWindow* window;
-GtkWidget* vbox;
-MokoDialerStatus * status;
-
-if(p_dialer_data->window_outgoing==0)
-{
-
-  vbox = gtk_vbox_new( FALSE, 0 );
-   status=moko_dialer_status_new();
-   moko_dialer_status_add_status_icon(status,"status0.png");
-   moko_dialer_status_add_status_icon(status,"status1.png");
-   moko_dialer_status_add_status_icon(status,"status2.png");
-   moko_dialer_status_set_icon_by_index(status,0);
-   
-   gtk_box_pack_start( GTK_BOX(vbox),status, FALSE, FALSE, 0 );
-
- 	
-    GtkHBox *  hbox2 = gtk_hbox_new( FALSE, 0 );
-    GtkButton* button = gtk_button_new_with_label("Speaker");
-    g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_speaker_button_clicked), p_dialer_data );
-p_dialer_data->buttonSpeaker=button;
-//gtk_widget_set_size_request(button,100,32);
-    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 40 );
-
-  button = gtk_button_new_with_label("Redial");
-    p_dialer_data->buttonRedial=button;
-  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_redial_button_clicked), p_dialer_data );
-//gtk_widget_set_size_request(button,100,32);
-  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 40 );
-//gtk_widget_set_size_request(button,60,24);
-
-
-button = gtk_button_new_with_label("Cancel");
-  p_dialer_data->buttonCancel=button;
- g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_cancel_button_clicked), p_dialer_data );
-//gtk_widget_set_size_request(button,100,32);
- gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 40);
-
-
-
-
-   gtk_box_pack_start( GTK_BOX(vbox),hbox2, FALSE, FALSE, 50 );
-
-
-//currently     MokoDialogWindow is not finished, wating...
-//   MokoDialogWindow* window = (MokoDialogWindow *)(moko_dialog_window_new());
-//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) );
-
-    window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-    moko_finger_window_set_contents(window, GTK_WIDGET(vbox) );
-
-
-     gtk_widget_show_all( GTK_WIDGET(window) );
-
-     gtk_widget_hide( p_dialer_data->buttonRedial);
-
-
-     gtk_widget_hide( GTK_WIDGET(window) );   
-
-
-   moko_dialer_status_set_title_label(status, "Outgoing call");
-   moko_dialer_status_set_status_label(status, "Calling ... (00:00:00)");
-
-   p_dialer_data->window_outgoing=window;
-   p_dialer_data->status_outgoing=status;
-   
-//   DBG_MESSAGE("p_dialer_data->status_outgoing=0X%x",p_dialer_data->status_outgoing);
-
-
-  g_signal_connect ((gpointer) window, "show",
-                    G_CALLBACK (on_window_outgoing_show),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) window, "hide",
-                    G_CALLBACK (on_window_outgoing_hide),
-                    p_dialer_data);
-
-}
-
-
-
-// gtk_widget_show(p_dialer_data->window_outgoing);
-
-DBG_LEAVE();
-    return 1;
-}
-
+/*   openmoko-dialer-window-outgoing.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkvbox.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "moko-dialer-status.h"
+#include "openmoko-dialer-window-outgoing.h"
+
+void
+cb_speaker_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+//moko_dialer_status_update_icon(appdata->status_outgoing);
+
+
+  appdata->g_state.callstate = STATE_TALKING;
+
+  gtk_widget_hide (appdata->window_outgoing);
+
+  if (!appdata->window_talking)
+    window_talking_init (appdata);
+
+//transfer the contact info
+  window_talking_prepare (appdata);
+
+//start dialling.
+
+
+  gtk_widget_show (appdata->window_talking);
+
+
+  DBG_LEAVE ();
+}
+
+void
+cb_redial_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  gtk_widget_hide (appdata->buttonRedial);
+  gtk_widget_show (appdata->buttonSpeaker);
+  moko_dialer_status_set_title_label (appdata->status_outgoing,
+                                      "Outgoing call");
+  moko_dialer_status_set_status_label (appdata->status_outgoing,
+                                       "Calling ... (00:00:00)");
+  window_outgoing_setup_timer (appdata);
+
+  appdata->g_state.callstate = STATE_CALLING;
+  appdata->g_state.historytype = OUTGOING;
+  gsm_dial (appdata->g_peer_info.number);
+
+  DBG_LEAVE ();
+}
+
+void
+cb_cancel_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  gsm_hangup ();
+  appdata->g_state.callstate = STATE_FAILED;
+  gtk_widget_hide (appdata->window_outgoing);
+  DBG_LEAVE ();
+}
+
+void
+window_outgoing_prepare (MOKO_DIALER_APP_DATA * appdata)
+{
+  if (appdata->window_outgoing == 0)
+    window_outgoing_init (appdata);
+
+
+  moko_dialer_status_set_person_number (appdata->status_outgoing,
+                                        appdata->g_peer_info.number);
+  if (appdata->g_peer_info.hasname)
+  {
+    moko_dialer_status_set_person_image (appdata->status_outgoing,
+                                         appdata->g_peer_info.picpath);
+    moko_dialer_status_set_person_name (appdata->status_outgoing,
+                                        appdata->g_peer_info.name);
+  }
+  else
+  {
+    moko_dialer_status_set_person_image (appdata->status_outgoing,
+                                         MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+    moko_dialer_status_set_person_name (appdata->status_outgoing, "");
+
+  }
+  strcpy (appdata->g_state.lastnumber, appdata->g_peer_info.number);
+
+
+}
+
+gint
+window_outgoing_fails (MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  moko_dialer_status_set_error (appdata->status_outgoing);
+  moko_dialer_status_set_title_label (appdata->status_outgoing,
+                                      "Call Failure");
+  gtk_widget_hide (appdata->buttonSpeaker);
+  gtk_widget_show (appdata->buttonRedial);
+  DBG_LEAVE ();
+}
+
+gint
+timer_outgoing_time_out (MOKO_DIALER_APP_DATA * appdata)
+{
+//DBG_ENTER();
+  TIMER_DATA *timer_data = &(appdata->g_timer_data);
+
+
+  timer_data->ticks++;
+  timer_data->hour = timer_data->ticks / 3600;
+  timer_data->min = (timer_data->ticks - timer_data->hour * 3600) / 60;
+  timer_data->sec = timer_data->ticks % 60;
+
+
+  sprintf (timer_data->timestring, "Calling ... (%02d:%02d:%02d)",
+           timer_data->hour, timer_data->min, timer_data->sec);
+
+//ok,we update the label now.
+
+
+  moko_dialer_status_set_status_label (appdata->status_outgoing,
+                                       timer_data->timestring);
+  moko_dialer_status_update_icon (appdata->status_outgoing);
+
+  if (timer_data->stopsec != 0 && timer_data->ticks >= timer_data->stopsec)
+  {
+
+    timer_data->timeout = 1;
+    gtk_timeout_remove (timer_data->ptimer);
+    timer_data->ptimer = 0;
+//maybe it failes
+    window_outgoing_fails (appdata);
+    return 0;                   //0 stops the timer.
+  }
+  else
+    return 1;
+}
+
+
+
+void
+on_window_outgoing_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  if (appdata->g_timer_data.ptimer != 0)
+  {
+    gtk_timeout_remove (appdata->g_timer_data.ptimer);
+    appdata->g_timer_data.ptimer = 0;
+  }
+  if (appdata->g_state.callstate != STATE_TALKING)
+  {                             //     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0);
+
+    add_histroy_entry (appdata, appdata->g_state.historytype,
+                       appdata->g_peer_info.name,
+                       appdata->g_peer_info.number,
+                       appdata->g_peer_info.picpath,
+                       appdata->g_state.starttime,
+                       appdata->g_state.startdate, 0);
+
+  }
+
+
+
+}
+
+gint
+window_outgoing_setup_timer (MOKO_DIALER_APP_DATA * appdata)
+{
+  time_t timep;
+  struct tm *p;
+  time (&timep);
+  p = localtime (&timep);
+
+  sprintf (appdata->g_state.starttime, "%02d:%02d:%02d", p->tm_hour,
+           p->tm_min, p->tm_sec);
+  sprintf (appdata->g_state.startdate, "%04d/%02d/%02d", p->tm_year,
+           p->tm_mon, p->tm_mday);
+
+  if (appdata->g_timer_data.ptimer != 0)
+  {
+    gtk_timeout_remove (appdata->g_timer_data.ptimer);
+    appdata->g_timer_data.ptimer = 0;
+  }
+
+  memset (&(appdata->g_timer_data), 0, sizeof (appdata->g_timer_data));
+// 1:30 timeout
+  appdata->g_timer_data.stopsec = 90;
+
+  appdata->g_timer_data.ptimer =
+    gtk_timeout_add (1000, timer_outgoing_time_out, appdata);
+
+
+}
+
+void
+on_window_outgoing_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+
+
+  window_outgoing_setup_timer (appdata);
+
+
+  appdata->g_state.callstate = STATE_CALLING;
+  appdata->g_state.historytype = OUTGOING;
+  gsm_dial (appdata->g_peer_info.number);
+
+
+}
+
+
+gint
+window_outgoing_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  DBG_ENTER ();
+  MokoFingerWindow *window;
+  GtkWidget *vbox;
+  MokoDialerStatus *status;
+
+  if (p_dialer_data->window_outgoing == 0)
+  {
+
+    vbox = gtk_vbox_new (FALSE, 0);
+    status = moko_dialer_status_new ();
+    moko_dialer_status_add_status_icon (status, "status0.png");
+    moko_dialer_status_add_status_icon (status, "status1.png");
+    moko_dialer_status_add_status_icon (status, "status2.png");
+    moko_dialer_status_set_icon_by_index (status, 0);
+
+    gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, FALSE, 0);
+
+
+    GtkHBox *hbox2 = gtk_hbox_new (FALSE, 0);
+    GtkButton *button = gtk_button_new_with_label ("Speaker");
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_speaker_button_clicked), p_dialer_data);
+    p_dialer_data->buttonSpeaker = button;
+//gtk_widget_set_size_request(button,100,32);
+    gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 40);
+
+    button = gtk_button_new_with_label ("Redial");
+    p_dialer_data->buttonRedial = button;
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_redial_button_clicked), p_dialer_data);
+//gtk_widget_set_size_request(button,100,32);
+    gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 40);
+//gtk_widget_set_size_request(button,60,24);
+
+
+    button = gtk_button_new_with_label ("Cancel");
+    p_dialer_data->buttonCancel = button;
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_cancel_button_clicked), p_dialer_data);
+//gtk_widget_set_size_request(button,100,32);
+    gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 40);
+
+
+
+
+    gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 50);
+
+
+//currently     MokoDialogWindow is not finished, wating...
+//   MokoDialogWindow* window = (MokoDialogWindow *)(moko_dialog_window_new());
+//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) );
+
+    window = MOKO_FINGER_WINDOW (moko_finger_window_new ());
+    moko_finger_window_set_contents (window, GTK_WIDGET (vbox));
+
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+    gtk_widget_hide (p_dialer_data->buttonRedial);
+
+
+    gtk_widget_hide (GTK_WIDGET (window));
+
+
+    moko_dialer_status_set_title_label (status, "Outgoing call");
+    moko_dialer_status_set_status_label (status, "Calling ... (00:00:00)");
+
+    p_dialer_data->window_outgoing = window;
+    p_dialer_data->status_outgoing = status;
+
+//   DBG_MESSAGE("p_dialer_data->status_outgoing=0X%x",p_dialer_data->status_outgoing);
+
+
+    g_signal_connect ((gpointer) window, "show",
+                      G_CALLBACK (on_window_outgoing_show), p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+                      G_CALLBACK (on_window_outgoing_hide), p_dialer_data);
+
+  }
+
+
+
+// gtk_widget_show(p_dialer_data->window_outgoing);
+
+  DBG_LEAVE ();
+  return 1;
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,41 +1,40 @@
-/*  openmoko-dialer-window-outgoing.h
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #include "moko-dialer-includes.h"
-
- #ifndef _OPENMOKO_DIALER_WINDOW_OUTGOING_H
-#define _OPENMOKO_DIALER_WINDOW_OUTGOING_H
-
-#ifdef __cplusplus
-
-
-
-extern "C"
-
-{
-#endif
-
-
-
-gint window_outgoing_init( MOKO_DIALER_APP_DATA* p_dialer_data);
-
-void window_outgoing_prepare(MOKO_DIALER_APP_DATA * appdata);
-#ifdef __cplusplus
-}
-#endif
-
-#endif 
+/*  openmoko-dialer-window-outgoing.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-includes.h"
+
+#ifndef _OPENMOKO_DIALER_WINDOW_OUTGOING_H
+#define _OPENMOKO_DIALER_WINDOW_OUTGOING_H
+
+#ifdef __cplusplus
+
+
+
+extern "C"
+{
+#endif
+
+
+
+  gint window_outgoing_init (MOKO_DIALER_APP_DATA * p_dialer_data);
+
+  void window_outgoing_prepare (MOKO_DIALER_APP_DATA * appdata);
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,378 +1,402 @@
-/*   openmoko-dialer-window-talking.c
- *
- *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
-#include "alsa.h"
-#include <libmokoui/moko-finger-tool-box.h>
-#include <libmokoui/moko-finger-window.h>
-#include <libmokoui/moko-finger-wheel.h>
-#include <libmokoui/moko-pixmap-button.h>
-
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkvbox.h>
-#include "contacts.h"
-#include "openmoko-dialer-main.h"
-#include "moko-dialer-status.h"
-#include "openmoko-dialer-window-talking.h"
-
-void
-openmoko_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
- gint l , r;
- alsa_get_volume(&l, &r);
-alsa_set_volume(l+10, r+10);
-
- alsa_get_volume(&l, &r);
- g_print("l = %d, r = %d\n", l, r);
-
-/*
-    l = 90; 
-    r = 90;
-
-*/    
-
-}
-
-void
-openmoko_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
- gint l , r;
-  alsa_get_volume(&l, &r);
-alsa_set_volume(l-10, r-10);
- alsa_get_volume(&l, &r);
- g_print("l = %d, r = %d\n", l, r);
-
-DBG_ENTER();
-}
-
-
-void cb_tool_button_speaker_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-  DBG_ENTER();
-}
-
-void cb_tool_button_dtmf_talk_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-	DBG_ENTER();
-	
-	appdata->dtmf_in_talking_window=!appdata->dtmf_in_talking_window;
-	if(appdata->dtmf_in_talking_window)
-		{
-		
-			
-			moko_pixmap_button_set_finger_toolbox_btn_center_image(button, appdata->imageTALK);
-		       gtk_widget_hide(appdata->content_talk);
-			gtk_widget_show(appdata->content_dtmf);
-		}
-	else
-		{
-			moko_pixmap_button_set_finger_toolbox_btn_center_image(button, appdata->imageDTMF);
-			gtk_widget_hide(appdata->content_dtmf);
-		       gtk_widget_show(appdata->content_talk);
-		       
-
-		}
-
-  
-}
-
-void cb_tool_button_hangup_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-     gsm_hangup();
-     gtk_widget_hide(appdata->window_talking);
-
-}
-
-
-void
-on_dtmf_panel_user_input(GtkWidget * widget,gchar parac,
-                                        gpointer         user_data)
-{
-char input[2];
-input[0]=parac;
-input[1]=0;
-char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
-
-
-MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
-MokoDialerTextview *moko_dtmf_text_view=appdata->moko_dtmf_text_view;
-
-moko_dialer_textview_insert(moko_dtmf_text_view, input);
-
-
-gsm_dtmf_send(input[0]);
-//lgsm_voice_dtmf(lgsmh, buf[1]);
-
-}
-
-
-
-void window_talking_prepare(MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-   moko_dialer_status_set_person_number(appdata->status_talking, appdata->g_peer_info.number);
-if(appdata->g_peer_info.hasname)
-{
-   moko_dialer_status_set_person_image(appdata->status_talking, appdata->g_peer_info.picpath);  
-   moko_dialer_status_set_person_name(appdata->status_talking, appdata->g_peer_info.name);
-}
-else
-{
-   moko_dialer_status_set_person_image(appdata->status_talking, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);  
-   moko_dialer_status_set_person_name(appdata->status_talking, "");
-
-}
-
-DBG_LEAVE();
-
-}
-
-gint timer_talking_time_out(MOKO_DIALER_APP_DATA * appdata)
-{
-//DBG_ENTER();
-TIMER_DATA* timer_data=&(appdata->g_timer_data);
-
-	
-timer_data->ticks++;
-timer_data->hour=timer_data->ticks/3600;
-timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60;
-timer_data->sec=timer_data->ticks%60;
-
-
-sprintf(timer_data->timestring,"Talking (%02d:%02d:%02d)",timer_data->hour,timer_data->min,timer_data->sec);
-
-//ok,we update the label now.
-
-
-moko_dialer_status_set_status_label(appdata->status_talking,timer_data->timestring);
-moko_dialer_status_update_icon(appdata->status_talking);
-
-if(timer_data->stopsec!=0&&timer_data->ticks>=timer_data->stopsec)
-{
-
-timer_data->timeout=1;
-gtk_timeout_remove(timer_data->ptimer);
-timer_data->ptimer=0;
-return 0;//0 stops the timer.
-}
-else
-return 1;
-}
-
-void
-on_window_talking_hide                 (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-if(appdata->g_timer_data.ptimer!=0)
-{
-gtk_timeout_remove(appdata->g_timer_data.ptimer);
-appdata->g_timer_data.ptimer=0;
-}
-
-gtk_widget_hide(appdata->wheel_talking);
-gtk_widget_hide(appdata->toolbox_talking);
-
-//DBG_MESSAGE("%s, %s",appdata->g_state.starttime,appdata->g_state.startdate);
-add_histroy_entry(appdata,appdata->g_state.historytype,
-	appdata->g_peer_info.name,
-	appdata->g_peer_info.number,
-	appdata->g_peer_info.picpath,
-	appdata->g_state.starttime,
-	appdata->g_state.startdate,
-	appdata->g_timer_data.ticks);
-
-
-}
-
-void
-on_window_talking_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-
-appdata->dtmf_in_talking_window=TRUE;
-	//hide the talking button in talking mode.
-
-time_t timep;
-struct tm *p;
-time(&timep);
-p=localtime(&timep);
-
-sprintf(appdata->g_state.starttime,"%02d:%02d:%02d",p->tm_hour,p->tm_min,p->tm_sec);
-sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year+1900,p->tm_mon,p->tm_mday);
-
-memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data));
-
-appdata->g_timer_data.stopsec=0;
-
-appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_talking_time_out,appdata);
-
-if(appdata->wheel_talking)
-gtk_widget_show(appdata->wheel_talking);
-
-if(appdata->toolbox_talking)
-gtk_widget_show(appdata->toolbox_talking);
-
-
-   
-DBG_LEAVE();
-}
-
-
-
-
-gint window_talking_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-DBG_ENTER();
-
-
-if(p_dialer_data->window_talking==0)
-{
-
-	MokoFingerWindow* window=NULL;
-	GtkWidget* vbox=gtk_vbox_new( FALSE, 0 );;
-	MokoDialerStatus * status=NULL;
-	GtkWidget* content_talk= NULL;
-	GtkWidget* content_dtmf= NULL;
-      MokoFingerToolBox *tools = NULL;
-      MokoDialerPanel* mokodialerpanel=NULL;
-      GtkWidget *button;
-      GtkWidget* image;
-
-
-//first, the talking content.
-
-   content_talk = gtk_vbox_new( FALSE, 0 );
-   status=moko_dialer_status_new();
-   moko_dialer_status_add_status_icon(status,"status0.png");
-   moko_dialer_status_add_status_icon(status,"status1.png");
-   moko_dialer_status_add_status_icon(status,"status2.png");
-   moko_dialer_status_set_icon_by_index(status,0);
-   
-   
-   moko_dialer_status_set_title_label(status, "In Call");
-   moko_dialer_status_set_status_label(status, "Talking ...(00:00:00)");
-
-   gtk_box_pack_start( GTK_BOX(content_talk),status, FALSE, FALSE, 0 );
-
-
-   p_dialer_data->status_talking=status;
-   p_dialer_data->content_talk= content_talk;
-
-   gtk_box_pack_start( GTK_BOX(vbox),content_talk, FALSE, FALSE, 0 );
-   
-  
-//now the dtmf content
-  	content_dtmf= gtk_vbox_new( FALSE, 0 );
-  	GtkEventBox* eventbox1 = gtk_event_box_new ();
-	gtk_widget_show (eventbox1);
-	gtk_widget_set_name(GTK_WIDGET(eventbox1),"gtkeventbox-black");
-
-   	MokoDialerTextview * mokotextview=moko_dialer_textview_new();
-
-  	gtk_container_add (GTK_CONTAINER (eventbox1), mokotextview);
-
-   	p_dialer_data->moko_dtmf_text_view=mokotextview;
-    
-  	gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(eventbox1), FALSE,FALSE, 2 );
-
-
-
-	 mokodialerpanel=moko_dialer_panel_new();
-
-   	gtk_widget_set_size_request (mokodialerpanel, 380, 384);
-   	g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_input",  G_CALLBACK (on_dtmf_panel_user_input),p_dialer_data);
-    	gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(mokodialerpanel), TRUE, TRUE, 5 );
-  
-   	gtk_box_pack_start( GTK_BOX(vbox),content_dtmf, FALSE, FALSE, 0 );
-   	p_dialer_data->content_dtmf=content_dtmf;
-
-
-//now the container--window
-     window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-     p_dialer_data->window_talking=window;
-     moko_finger_window_set_contents(window, GTK_WIDGET(vbox) );
-    g_signal_connect ((gpointer) window, "show",
-	                    G_CALLBACK (on_window_talking_show),
-	                    p_dialer_data);
-    g_signal_connect ((gpointer) window, "hide",
-	                    G_CALLBACK (on_window_talking_hide),
-	                    p_dialer_data);
-
-     
-     gtk_widget_show_all( GTK_WIDGET(window) );
-
-//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
-
-   gtk_widget_hide(content_dtmf);
-
-
- //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all???
-   gtk_widget_show(GTK_WIDGET(moko_finger_window_get_wheel(window)));
-    
-    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)),
-		    "press_left_up",
-		    G_CALLBACK(openmoko_wheel_press_left_up_cb),
-		    p_dialer_data);
-    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)),
-		    "press_right_down",
-		    G_CALLBACK(openmoko_wheel_press_right_down_cb),
-		    p_dialer_data);
-
-
-
-        tools = moko_finger_window_get_toolbox(window);
-     
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("speaker.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-        g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_speaker_clicked), p_dialer_data);
-	
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("dtmf.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_dtmf_talk_clicked), p_dialer_data);
-	p_dialer_data->imageDTMF=image;
-	p_dialer_data->imageTALK=file_new_image_from_relative_path("talking.png");
-	
-
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("tony.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_hangup_clicked), p_dialer_data);
-	gtk_widget_show(GTK_WIDGET(tools));
-
-	p_dialer_data->dtmf_in_talking_window=0;
-	p_dialer_data->wheel_talking=moko_finger_window_get_wheel(window);
-	p_dialer_data->toolbox_talking=tools;
-
-
-	DBG_LEAVE();
-}
-    return 1;
-}
-
+/*   openmoko-dialer-window-talking.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "alsa.h"
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkvbox.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "moko-dialer-status.h"
+#include "openmoko-dialer-window-talking.h"
+
+void
+openmoko_wheel_press_left_up_cb (GtkWidget * widget,
+                                 MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  gint l, r;
+  alsa_get_volume (&l, &r);
+  alsa_set_volume (l + 10, r + 10);
+
+  alsa_get_volume (&l, &r);
+  g_print ("l = %d, r = %d\n", l, r);
+
+/*
+    l = 90; 
+    r = 90;
+
+*/
+
+}
+
+void
+openmoko_wheel_press_right_down_cb (GtkWidget * widget,
+                                    MOKO_DIALER_APP_DATA * appdata)
+{
+  gint l, r;
+  alsa_get_volume (&l, &r);
+  alsa_set_volume (l - 10, r - 10);
+  alsa_get_volume (&l, &r);
+  g_print ("l = %d, r = %d\n", l, r);
+
+  DBG_ENTER ();
+}
+
+
+void
+cb_tool_button_speaker_clicked (GtkButton * button,
+                                MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+}
+
+void
+cb_tool_button_dtmf_talk_clicked (GtkButton * button,
+                                  MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+  appdata->dtmf_in_talking_window = !appdata->dtmf_in_talking_window;
+  if (appdata->dtmf_in_talking_window)
+  {
+
+
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button,
+                                                            appdata->
+                                                            imageTALK);
+    gtk_widget_hide (appdata->content_talk);
+    gtk_widget_show (appdata->content_dtmf);
+  }
+  else
+  {
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button,
+                                                            appdata->
+                                                            imageDTMF);
+    gtk_widget_hide (appdata->content_dtmf);
+    gtk_widget_show (appdata->content_talk);
+
+
+  }
+
+
+}
+
+void
+cb_tool_button_hangup_clicked (GtkButton * button,
+                               MOKO_DIALER_APP_DATA * appdata)
+{
+  gsm_hangup ();
+  gtk_widget_hide (appdata->window_talking);
+
+}
+
+
+void
+on_dtmf_panel_user_input (GtkWidget * widget, gchar parac, gpointer user_data)
+{
+  char input[2];
+  input[0] = parac;
+  input[1] = 0;
+  char codesinput[MOKO_DIALER_MAX_NUMBER_LEN + 1];
+
+
+  MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data;
+  MokoDialerTextview *moko_dtmf_text_view = appdata->moko_dtmf_text_view;
+
+  moko_dialer_textview_insert (moko_dtmf_text_view, input);
+
+
+  gsm_dtmf_send (input[0]);
+//lgsm_voice_dtmf(lgsmh, buf[1]);
+
+}
+
+
+
+void
+window_talking_prepare (MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  moko_dialer_status_set_person_number (appdata->status_talking,
+                                        appdata->g_peer_info.number);
+  if (appdata->g_peer_info.hasname)
+  {
+    moko_dialer_status_set_person_image (appdata->status_talking,
+                                         appdata->g_peer_info.picpath);
+    moko_dialer_status_set_person_name (appdata->status_talking,
+                                        appdata->g_peer_info.name);
+  }
+  else
+  {
+    moko_dialer_status_set_person_image (appdata->status_talking,
+                                         MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+    moko_dialer_status_set_person_name (appdata->status_talking, "");
+
+  }
+
+  DBG_LEAVE ();
+
+}
+
+gint
+timer_talking_time_out (MOKO_DIALER_APP_DATA * appdata)
+{
+//DBG_ENTER();
+  TIMER_DATA *timer_data = &(appdata->g_timer_data);
+
+
+  timer_data->ticks++;
+  timer_data->hour = timer_data->ticks / 3600;
+  timer_data->min = (timer_data->ticks - timer_data->hour * 3600) / 60;
+  timer_data->sec = timer_data->ticks % 60;
+
+
+  sprintf (timer_data->timestring, "Talking (%02d:%02d:%02d)",
+           timer_data->hour, timer_data->min, timer_data->sec);
+
+//ok,we update the label now.
+
+
+  moko_dialer_status_set_status_label (appdata->status_talking,
+                                       timer_data->timestring);
+  moko_dialer_status_update_icon (appdata->status_talking);
+
+  if (timer_data->stopsec != 0 && timer_data->ticks >= timer_data->stopsec)
+  {
+
+    timer_data->timeout = 1;
+    gtk_timeout_remove (timer_data->ptimer);
+    timer_data->ptimer = 0;
+    return 0;                   //0 stops the timer.
+  }
+  else
+    return 1;
+}
+
+void
+on_window_talking_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  if (appdata->g_timer_data.ptimer != 0)
+  {
+    gtk_timeout_remove (appdata->g_timer_data.ptimer);
+    appdata->g_timer_data.ptimer = 0;
+  }
+
+  gtk_widget_hide (appdata->wheel_talking);
+  gtk_widget_hide (appdata->toolbox_talking);
+
+//DBG_MESSAGE("%s, %s",appdata->g_state.starttime,appdata->g_state.startdate);
+  add_histroy_entry (appdata, appdata->g_state.historytype,
+                     appdata->g_peer_info.name,
+                     appdata->g_peer_info.number,
+                     appdata->g_peer_info.picpath,
+                     appdata->g_state.starttime,
+                     appdata->g_state.startdate, appdata->g_timer_data.ticks);
+
+
+}
+
+void
+on_window_talking_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+  appdata->dtmf_in_talking_window = TRUE;
+  //hide the talking button in talking mode.
+
+  time_t timep;
+  struct tm *p;
+  time (&timep);
+  p = localtime (&timep);
+
+  sprintf (appdata->g_state.starttime, "%02d:%02d:%02d", p->tm_hour,
+           p->tm_min, p->tm_sec);
+  sprintf (appdata->g_state.startdate, "%04d/%02d/%02d", p->tm_year + 1900,
+           p->tm_mon, p->tm_mday);
+
+  memset (&(appdata->g_timer_data), 0, sizeof (appdata->g_timer_data));
+
+  appdata->g_timer_data.stopsec = 0;
+
+  appdata->g_timer_data.ptimer =
+    gtk_timeout_add (1000, timer_talking_time_out, appdata);
+
+  if (appdata->wheel_talking)
+    gtk_widget_show (appdata->wheel_talking);
+
+  if (appdata->toolbox_talking)
+    gtk_widget_show (appdata->toolbox_talking);
+
+
+
+  DBG_LEAVE ();
+}
+
+
+
+
+gint
+window_talking_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  DBG_ENTER ();
+
+
+  if (p_dialer_data->window_talking == 0)
+  {
+
+    MokoFingerWindow *window = NULL;
+    GtkWidget *vbox = gtk_vbox_new (FALSE, 0);;
+    MokoDialerStatus *status = NULL;
+    GtkWidget *content_talk = NULL;
+    GtkWidget *content_dtmf = NULL;
+    MokoFingerToolBox *tools = NULL;
+    MokoDialerPanel *mokodialerpanel = NULL;
+    GtkWidget *button;
+    GtkWidget *image;
+
+
+//first, the talking content.
+
+    content_talk = gtk_vbox_new (FALSE, 0);
+    status = moko_dialer_status_new ();
+    moko_dialer_status_add_status_icon (status, "status0.png");
+    moko_dialer_status_add_status_icon (status, "status1.png");
+    moko_dialer_status_add_status_icon (status, "status2.png");
+    moko_dialer_status_set_icon_by_index (status, 0);
+
+
+    moko_dialer_status_set_title_label (status, "In Call");
+    moko_dialer_status_set_status_label (status, "Talking ...(00:00:00)");
+
+    gtk_box_pack_start (GTK_BOX (content_talk), status, FALSE, FALSE, 0);
+
+
+    p_dialer_data->status_talking = status;
+    p_dialer_data->content_talk = content_talk;
+
+    gtk_box_pack_start (GTK_BOX (vbox), content_talk, FALSE, FALSE, 0);
+
+
+//now the dtmf content
+    content_dtmf = gtk_vbox_new (FALSE, 0);
+    GtkEventBox *eventbox1 = gtk_event_box_new ();
+    gtk_widget_show (eventbox1);
+    
gtk_widget_set_name (GTK_WIDGET (eventbox1), "gtkeventbox-black");
+
+    MokoDialerTextview *mokotextview = moko_dialer_textview_new ();
+
+    gtk_container_add (GTK_CONTAINER (eventbox1), mokotextview);
+
+    p_dialer_data->moko_dtmf_text_view = mokotextview;
+
+    gtk_box_pack_start (GTK_BOX (content_dtmf), GTK_WIDGET (eventbox1), FALSE,
+                        FALSE, 2);
+
+
+
+    mokodialerpanel = moko_dialer_panel_new ();
+
+    gtk_widget_set_size_request (mokodialerpanel, 380, 384);
+    g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_input",
+                      G_CALLBACK (on_dtmf_panel_user_input), p_dialer_data);
+    gtk_box_pack_start (GTK_BOX (content_dtmf), GTK_WIDGET (mokodialerpanel),
+                        TRUE, TRUE, 5);
+
+    gtk_box_pack_start (GTK_BOX (vbox), content_dtmf, FALSE, FALSE, 0);
+    p_dialer_data->content_dtmf = content_dtmf;
+
+
+//now the container--window
+    window = MOKO_FINGER_WINDOW (moko_finger_window_new ());
+    p_dialer_data->window_talking = window;
+    moko_finger_window_set_contents (window, GTK_WIDGET (vbox));
+    g_signal_connect ((gpointer) window, "show",
+                      G_CALLBACK (on_window_talking_show), p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+                      G_CALLBACK (on_window_talking_hide), p_dialer_data);
+
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
+
+    gtk_widget_hide (content_dtmf);
+
+
+    //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all???
+    gtk_widget_show (GTK_WIDGET (moko_finger_window_get_wheel (window)));
+
+    g_signal_connect (G_OBJECT (moko_finger_window_get_wheel (window)),
+                      "press_left_up",
+                      G_CALLBACK (openmoko_wheel_press_left_up_cb),
+                      p_dialer_data);
+    g_signal_connect (G_OBJECT (moko_finger_window_get_wheel (window)),
+                      "press_right_down",
+                      G_CALLBACK (openmoko_wheel_press_right_down_cb),
+                      p_dialer_data);
+
+
+
+    tools = moko_finger_window_get_toolbox (window);
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("speaker.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_speaker_clicked),
+                      p_dialer_data);
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("dtmf.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_dtmf_talk_clicked),
+                      p_dialer_data);
+    p_dialer_data->imageDTMF = image;
+    p_dialer_data->imageTALK =
+      file_new_image_from_relative_path ("talking.png");
+
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("tony.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_hangup_clicked),
+                      p_dialer_data);
+    gtk_widget_show (GTK_WIDGET (tools));
+
+    p_dialer_data->dtmf_in_talking_window = 0;
+    p_dialer_data->wheel_talking = moko_finger_window_get_wheel (window);
+    p_dialer_data->toolbox_talking = tools;
+
+
+    DBG_LEAVE ();
+  }
+  return 1;
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,41 +1,40 @@
-/*  openmoko-dialer-window-outgoing.h
- *
- *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
- *
- *  Copyright (C) 2006 FIC Shanghai Lab
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Public License as published by
- *  the Free Software Foundation; version 2.1 of the license.
- *
- *  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 Lesser Public License for more details.
- *
- *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
- */
- #include "moko-dialer-includes.h"
-
- #ifndef _OPENMOKO_DIALER_WINDOW_TALKING_H
-#define _OPENMOKO_DIALER_WINDOW_TALKING_H
-
-#ifdef __cplusplus
-
-
-
-extern "C"
-
-{
-#endif
-
-
- 
-gint window_talking_init( MOKO_DIALER_APP_DATA* p_dialer_data);
-
-void window_talking_prepare(MOKO_DIALER_APP_DATA * appdata);
-#ifdef __cplusplus
-}
-#endif
-
-#endif 
+/*  openmoko-dialer-window-outgoing.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  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 Lesser Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+#include "moko-dialer-includes.h"
+
+#ifndef _OPENMOKO_DIALER_WINDOW_TALKING_H
+#define _OPENMOKO_DIALER_WINDOW_TALKING_H
+
+#ifdef __cplusplus
+
+
+
+extern "C"
+{
+#endif
+
+
+
+  gint window_talking_init (MOKO_DIALER_APP_DATA * p_dialer_data);
+
+  void window_talking_prepare (MOKO_DIALER_APP_DATA * appdata);
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c	2007-02-01 12:21:39 UTC (rev 648)
@@ -7,33 +7,39 @@
 #define PIN_SIZE 32
 
 static char *pin;
-static char pinbuf[PIN_SIZE+1];
+static char pinbuf[PIN_SIZE + 1];
 
-static int pin_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+static int
+pin_handler (struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
-	int rc;
+  int rc;
 
-	printf("EVENT: PIN request (type=%u) ", aux->u.pin.type);
+  printf ("EVENT: PIN request (type=%u) ", aux->u.pin.type);
 
-	/* FIXME: read pin from STDIN and send it back via lgsm_pin */
-	if (aux->u.pin.type == 1 && pin) {
-		printf("Auto-responding with pin `%s'\n", pin);
-		lgsm_pin(lh, pin);
-	} else {
-		do {
-			printf("Please enter PIN: ");
-			rc = fscanf(stdin, "%32s", &pinbuf);
-		} while (rc < 1);
+  /* FIXME: read pin from STDIN and send it back via lgsm_pin */
+  if (aux->u.pin.type == 1 && pin)
+  {
+    printf ("Auto-responding with pin `%s'\n", pin);
+    lgsm_pin (lh, pin);
+  }
+  else
+  {
+    do
+    {
+      printf ("Please enter PIN: ");
+      rc = fscanf (stdin, "%32s", &pinbuf);
+    }
+    while (rc < 1);
 
-		return lgsm_pin(lh, pinbuf);
-	}
+    return lgsm_pin (lh, pinbuf);
+  }
 
-	return 0;
+  return 0;
 }
 
-int pin_init(struct lgsm_handle *lh, const char *pin_preset)
+int
+pin_init (struct lgsm_handle *lh, const char *pin_preset)
 {
-	pin = pin_preset;
-	return lgsm_evt_handler_register(lh, GSMD_EVT_PIN, &pin_handler);
+  pin = pin_preset;
+  return lgsm_evt_handler_register (lh, GSMD_EVT_PIN, &pin_handler);
 }
-

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h	2007-02-01 03:31:43 UTC (rev 647)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h	2007-02-01 12:21:39 UTC (rev 648)
@@ -1,2 +1,2 @@
 
-extern int pin_init(struct lgsm_handle *lh, const char *pin_preset);
+extern int pin_init (struct lgsm_handle *lh, const char *pin_preset);





More information about the commitlog mailing list