r430 - in trunk/src/target/OM-2007/applications/openmoko-dialer: . data src
tony_guan at gta01.hmw-consulting.de
tony_guan at gta01.hmw-consulting.de
Tue Dec 19 10:38:38 CET 2006
Author: tony_guan
Date: 2006-12-19 10:37:50 +0100 (Tue, 19 Dec 2006)
New Revision: 430
Added:
trunk/src/target/OM-2007/applications/openmoko-dialer/data/10086.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/chaowei.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/dialed.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/ken.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/missed.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/received.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/sally.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/steven.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/tony.png
trunk/src/target/OM-2007/applications/openmoko-dialer/data/unkown.png
trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c
trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h
Modified:
trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac
trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am
trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am
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/error.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-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/openmoko-dialer-main.c
Log:
MokoAutolist finished, integrated, added the common.h/c to hold common functions.
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac 2006-12-19 09:37:50 UTC (rev 430)
@@ -1,5 +1,5 @@
AC_PREREQ(2.53)
-AC_INIT(%(APPNAME), %(APPVERSION), %(APPCONTACT))
+AC_INIT(openmoko-dialer, %(APPVERSION), %(APPCONTACT))
AM_INIT_AUTOMAKE()
AC_CONFIG_SRCDIR(src/openmoko-dialer-main.c)
AM_CONFIG_HEADER(config.h)
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/10086.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/10086.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am 2006-12-19 09:37:50 UTC (rev 430)
@@ -1,5 +1,17 @@
-EXTRA_DIST =
-
+EXTRA_DIST = tony.png\
+ steven.png\
+ ken.png\
+ sally.png\
+ 10086.png\
+ chaowei.png\
+ unkown.png
resourcedir = $(pkgdatadir)
-resource_DATA =
+resource_DATA = tony.png\
+ steven.png\
+ ken.png\
+ sally.png\
+ 10086.png\
+ chaowei.png\
+ unkown.png
+
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/chaowei.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/chaowei.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/dialed.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/dialed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/ken.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/ken.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/missed.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/missed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/received.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/received.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/sally.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/sally.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/steven.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/steven.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/tony.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/tony.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/unkown.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/unkown.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am 2006-12-19 09:37:50 UTC (rev 430)
@@ -8,7 +8,8 @@
moko-dialer-textview.c\
moko-dialer-tip.c\
moko-dialer-autolist.c\
-contacts.c
+contacts.c\
+common.c
openmoko_dialer_LDADD = @OPENMOKO_LIBS@
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c 2006-12-19 09:37:50 UTC (rev 430)
@@ -0,0 +1,135 @@
+/* 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.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 "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
+ {
+ 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;
+ }
+
+/*
+GtkImage *image=GTK_IMAGE(widget);
+
+struct stat statdata;
+
+if(image==NULL)
+ {
+ DBG_ERROR("Can not find widget ");
+ return 0;
+ }
+ if(lstat(path,&statdata)==-1)
+ {
+ gtk_image_set_from_stock(image,"icon_dialer_people",GTK_ICON_SIZE_LARGE_TOOLBAR);
+ }
+ else
+ gtk_image_set_from_file(image,path);
+ return 1;
+*/
+
+}
+
+
Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h 2006-12-19 09:37:50 UTC (rev 430)
@@ -0,0 +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);
+
+#endif
+
+
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c 2006-12-19 09:37:50 UTC (rev 430)
@@ -275,31 +275,31 @@
{
DIALER_CONTACT* contact;
if(head==0)return 0;
- contact=contact_new_contact("Tony Guan","./tony.png");
+ 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=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=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=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=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","");
+ contact=contact_new_contact("10086","10086.png");
contact_add_entry(contact,"work","10086");
contact_add_contact_to_list(head,contact);
@@ -407,7 +407,7 @@
while(contacts!= 0)
{
- DBG_MESSAGE("CONTACT: name:%s",contacts->name);
+ DBG_MESSAGE("%s",contacts->name);
entry=contacts->entry;
while(entry)
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h 2006-12-19 09:37:50 UTC (rev 430)
@@ -34,15 +34,7 @@
#endif
-/**
- * @brief the structure for intelligent search results.
- */
-typedef struct dialer_ready_contact
-{
- char name[MOKO_DIALER_MAX_DISP_NAME_LEN+1];///<the name of the result.
- char picpath[MOKO_DIALER_MAX_PATH_LEN+1];///<the picture path of the contact.
- char number[MOKO_DIALER_MAX_NUMBER_LEN+1];///<the number which contains the input digits.
-}DIALER_READY_CONTACT;
+
/**
* @brief phone number entry for the contact structure in open dialer.
@@ -69,6 +61,15 @@
/**
+ * @brief the structure for intelligent search results.
+ */
+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 {
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/error.h 2006-12-19 09:37:50 UTC (rev 430)
@@ -45,7 +45,7 @@
#ifdef _FIC_DEBUG
/** @brief Define a debug message output */
-#define DBG_MESSAGE(x...) {if(DBG_MESSAGE_ON) {g_print("MESSAGE:\n");g_print(x);g_print("\n");}}
+#define DBG_MESSAGE(x...) {if(DBG_MESSAGE_ON) {g_print(x);g_print("\n");}}
/** @brief Define a error message output */
#define DBG_ERROR(x...) {if(DBG_ERROR_ON) {g_print("%s : %s : %d\nERROR:\n",__FILE__,__FUNCTION__,__LINE__);g_print(x);g_print("\n");}}
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 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c 2006-12-19 09:37:50 UTC (rev 430)
@@ -18,12 +18,13 @@
#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
};
@@ -54,61 +55,47 @@
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_selected),
NULL,NULL,
- g_cclosure_marshal_VOID__CHAR,
- G_TYPE_NONE, 1,g_type_from_name("gchar"));
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,g_type_from_name("gpointer"));
- // G_TYPE_NONE, 0);
-g_print("moko_dialer_autolist:signal register end,got the id :%d\n", moko_dialer_autolist_signals[SELECTED_SIGNAL]);
+
+
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__CHAR,
- G_TYPE_NONE, 1,g_type_from_name("gchar"));
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,g_type_from_name("gpointer"));
- // G_TYPE_NONE, 0);
+//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);
-g_print("moko_dialer_autolist:signal register end,got the id :%d\n", moko_dialer_autolist_signals[CONFIRMED_SIGNAL]);
+
}
static void
moko_dialer_autolist_init (MokoDialerAutolist *moko_dialer_autolist)
{
-DBG_ENTER();
-
-
- GtkWidget * imagePerson;
- GtkWidget * tip;
- imagePerson = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (imagePerson);
- gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0);
-
-//insert the tips
-
- for(int 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_autolist->tips[i]=tip;
-
- gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, TRUE, 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);
-
- }
+//DBG_ENTER();
+for(int i=0;i<MOKO_DIALER_MAX_TIPS;i++)
+ moko_dialer_autolist->tips[i]=0;
+moko_dialer_autolist-> tipscreated=FALSE;
moko_dialer_autolist->head=0;
-//here we begin to initialize the contacts data.
-
-
+moko_dialer_autolist->g_alternatecount=0;
+moko_dialer_autolist->imagePerson=0;
}
/**
@@ -123,7 +110,7 @@
moko_dialer_autolist->head=head;
-contact_print_contact_list(moko_dialer_autolist->head);
+//contact_print_contact_list(moko_dialer_autolist->head);
return TRUE;
}
@@ -140,7 +127,7 @@
int moko_dialer_autolist_fill_alternative(MokoDialerAutolist *moko_dialer_autolist,gint count)
{
gint i;
-DBG_ENTER();
+//DBG_ENTER();
moko_dialer_autolist->g_alternatecount=count;
@@ -150,8 +137,9 @@
//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].name);
+ 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]);
}
@@ -160,18 +148,26 @@
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);
}
- // i=strlen(codestring);
- // settextviewCodesSensentiveString(text_view,readycontacts[0].number+i);
+ //we set the first one as defaultly selected
+ moko_dialer_autolist_set_select(moko_dialer_autolist, 0);
}
else
{
+
//no alternative, hide all 3 labels.
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);
+ //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;
}
@@ -185,10 +181,10 @@
DIALER_CONTACT_ENTRY* entry;
- int inserted=0;
+ gint inserted=0;
- int len;
+ gint len;
if(string)
len=strlen(string);
@@ -196,59 +192,80 @@
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];
+ if(file_create_data_path_for_the_file("unkown.png",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_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0);
+ moko_dialer_autolist->imagePerson=imagePerson;
+
+ for(int 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);
+
+ 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_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();
+// DBG_TRACE();
while(contacts!= NULL&&inserted<MOKO_DIALER_MAX_TIPS)
{
- DBG_TRACE();
+ // DBG_TRACE();
entry=contacts->entry;
// DBG_TRACE();
while(entry!=NULL&&inserted<MOKO_DIALER_MAX_TIPS)
{
- DBG_TRACE();
+// 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
-
- DBG_MESSAGE("%dth contacts:%s,%s,%s",inserted,contacts->name,entry->desc,entry->content);
-
- if(strlen(contacts->name)<=MOKO_DIALER_MAX_DISP_NAME_LEN)
- strcpy(moko_dialer_autolist->readycontacts[inserted].name,contacts->name);
- if(strlen(contacts->picpath)<=MOKO_DIALER_MAX_PATH_LEN)
- strcpy(moko_dialer_autolist->readycontacts[inserted].picpath,contacts->picpath);
- if(strlen(entry->content)<=MOKO_DIALER_MAX_NUMBER_LEN)
- strcpy(moko_dialer_autolist->readycontacts[inserted].number,entry->content);
-
-/*
- strncpy(readycontacts[inserted].name,contacts->name,MAXDISPNAMELEN);
- strncpy(readycontacts[inserted].picpath,contacts->picpath,MAXPATHLEN);
- strncpy(readycontacts[inserted].number,entry->content,MAXDIALNUMBERLEN);
-*/
- DBG_MESSAGE("insert=%d,%s,%s,%s",inserted,moko_dialer_autolist->readycontacts[inserted].name,moko_dialer_autolist->readycontacts[inserted].picpath,moko_dialer_autolist->readycontacts[inserted].number);
-
- inserted++;
+ moko_dialer_autolist->readycontacts[inserted].p_contact=contacts;
+ moko_dialer_autolist->readycontacts[inserted].p_entry=entry;
+ inserted++;
//break;
}
- entry=entry->next;
+ entry=entry->next;
}
contacts= contacts->next;
}
-DBG_MESSAGE("inserted=%d",inserted);
+//DBG_MESSAGE("inserted=%d",inserted);
moko_dialer_autolist_fill_alternative(moko_dialer_autolist,inserted);
-/*
-if(ret>0&&autofill!=0)
- setselected(text_view,1);
-else
- setselected(text_view,0);
-*/
+
DBG_LEAVE();
return inserted;
}
@@ -256,29 +273,80 @@
gboolean on_tip_press_event (MokoDialerTip *tip,GdkEventButton *event,gpointer user_data)
{
-DBG_ENTER();
+//DBG_ENTER();
MokoDialerAutolist *moko_dialer_autolist;
moko_dialer_autolist=(MokoDialerAutolist *)user_data;
+
gint selected=moko_dialer_tip_get_index(tip);
-moko_dialer_tip_set_selected( tip, TRUE);
-if(selected!=-1)
+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_set_select(MokoDialerAutolist *moko_dialer_autolist,gint selected)
+{
+
+if(selected!=-1&&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(gint 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);
+ if(i!=selected)
+ {//hide the others
+ gtk_widget_hide( moko_dialer_autolist->tips[i]);
+ }
}
+ //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);
+ gtk_widget_show(moko_dialer_autolist->imagePerson);
+ //just change the selected attribute of the tips
+ for(gint 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);
}
+ //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;
+ }
+
}
-//emit new message for the textview to add string.
- return FALSE;
-}
-
-
GtkWidget* moko_dialer_autolist_new()
{
DBG_ENTER();
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 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h 2006-12-19 09:37:50 UTC (rev 430)
@@ -53,6 +53,7 @@
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.
@@ -65,16 +66,19 @@
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,gchar parac);
- void (* moko_dialer_autolist_confirmed) (MokoDialerAutolist *moko_dialer_autolist,gchar parac);
+ 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);
};
@@ -82,6 +86,7 @@
GtkWidget* moko_dialer_autolist_new();
+gboolean moko_dialer_autolist_set_select(MokoDialerAutolist *moko_dialer_autolist,gint selected);
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 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c 2006-12-19 09:37:50 UTC (rev 430)
@@ -42,38 +42,7 @@
object_class = (GtkObjectClass*) class;
-g_print("moko_dialer_textview:start signal register\n");
- class->moko_dialer_textview_input = NULL;
- class->moko_dialer_textview_hold= NULL;
-
-
- moko_dialer_textview_signals[CLICKED_SIGNAL] =
- g_signal_new ("user_input",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (MokoDialerTextviewClass, moko_dialer_textview_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_textview:signal register end,got the id :%d\n", moko_dialer_textview_signals[CLICKED_SIGNAL]);
-
- moko_dialer_textview_signals[HOLD_SIGNAL] =
- g_signal_new ("user_hold",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (MokoDialerTextviewClass, moko_dialer_textview_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_textview:signal register end,got the id :%d\n", moko_dialer_textview_signals[HOLD_SIGNAL]);
-
}
@@ -213,7 +182,7 @@
* @retval
*/
- int moko_dialer_textview_insert(MokoDialerTextview *moko_dialer_textview, const gchar* number)
+ gint moko_dialer_textview_insert(MokoDialerTextview *moko_dialer_textview, const gchar* number)
{
gint len=0;
@@ -283,7 +252,7 @@
//get the input section of the textview
//if ALL=true, get whole text
//else only get the inputed digits.
-int moko_dialer_textview_get_input(MokoDialerTextview *moko_dialer_textview,gchar* input,int ALL)
+gint moko_dialer_textview_get_input(MokoDialerTextview *moko_dialer_textview,gchar* input,int ALL)
{
gchar* codestring;
GtkTextBuffer *buffer;
@@ -407,5 +376,25 @@
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);
+
+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 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h 2006-12-19 09:37:50 UTC (rev 430)
@@ -56,8 +56,6 @@
struct _MokoDialerTextviewClass
{
GtkTextViewClass parent_class;
- void (* moko_dialer_textview_input) (MokoDialerTextview *moko_dialer_textview,gchar parac);
- void (* moko_dialer_textview_hold) (MokoDialerTextview *moko_dialer_textview,gchar parac);
};
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 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.c 2006-12-19 09:37:50 UTC (rev 430)
@@ -95,10 +95,12 @@
priv->label=label;
gdk_color_parse("black",&color);
+
gtk_widget_modify_fg(GTK_WIDGET(dialertip),GTK_STATE_NORMAL,&color);
- return GTK_WIDGET(dialertip);
+// gtk_widget_hide(GTK_WIDGET(dialertip));
+ return GTK_WIDGET(dialertip);
}
@@ -178,7 +180,7 @@
}
-gboolean moko_dialer_tip_set_selected(MokoDialerTip* tip,gboolean selected)
+gboolean moko_dialer_tip_set_selected(GtkWidget* tip,gboolean selected)
{
g_return_val_if_fail(MOKO_IS_DIALER_TIP(tip),FALSE);
@@ -205,7 +207,7 @@
}
-gboolean moko_dialer_tip_is_selected(MokoDialerTip* tip)
+gboolean moko_dialer_tip_is_selected(GtkWidget* tip)
{
g_return_val_if_fail(MOKO_IS_DIALER_TIP(tip),FALSE);
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 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-tip.h 2006-12-19 09:37:50 UTC (rev 430)
@@ -54,8 +54,7 @@
struct _MokoDialerTipClass
{
GtkEventBoxClass parent_class;
- void (* moko_dialer_tip_input) (MokoDialerTip *moko_dialer_tip,gchar parac);
- void (* moko_dialer_tip_hold) (MokoDialerTip *moko_dialer_tip,gchar parac);
+
};
@@ -69,6 +68,9 @@
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/openmoko-dialer-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c 2006-12-19 02:32:39 UTC (rev 429)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c 2006-12-19 09:37:50 UTC (rev 430)
@@ -28,10 +28,59 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkvbox.h>
-
+#include "contacts.h"
#include "openmoko-dialer-main.h"
void
+on_dialer_autolist_user_selected(GtkWidget * widget,gpointer para_pointer,
+ gpointer user_data)
+{
+gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
+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");
+
+}
+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_panel_user_input(GtkWidget * widget,gchar parac,
gpointer user_data)
{
@@ -44,26 +93,19 @@
MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
MokoDialerTextview *moko_dialer_text_view=appdata->moko_dialer_text_view;
-//DBG_TRACE();
moko_dialer_textview_insert(moko_dialer_text_view, input);
-//DBG_TRACE();
-
moko_dialer_textview_get_input(moko_dialer_text_view,codesinput, 0);
-//DBG_MESSAGE("codesinput:%s,appdata->moko_dialer_autolist=0x%x",codesinput,appdata->moko_dialer_autolist);
-
moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,codesinput);
-//DBG_TRACE();
-//g_print("on_dialer_panel_user_input:%c\n", parac);
}
void
on_dialer_panel_user_hold(GtkWidget * widget,gchar parac,
gpointer user_data)
{
-//g_print("on_dialer_panel_user_hold:%c\n", parac);
+g_print("on_dialer_panel_user_hold:%c\n", parac);
}
@@ -100,6 +142,7 @@
/* connect close event */
g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK( gtk_main_quit ), NULL );
+
/* contents */
vbox = gtk_vbox_new( FALSE, 0 );
@@ -107,6 +150,23 @@
GtkHBox* hbox = gtk_hbox_new( TRUE, 10 );
+ 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_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(autolist), FALSE, FALSE, 5 );
+
+
+ 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);
+
+
MokoDialerTextview * mokotextview=moko_dialer_textview_new();
p_dialer_data->moko_dialer_text_view=mokotextview;
@@ -131,10 +191,6 @@
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(hbox), TRUE, TRUE, 5 );
- 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_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(autolist), TRUE, TRUE, 5 );
More information about the commitlog
mailing list