r438 - trunk/src/target/OM-2007/applications/openmoko-dialer/src
tony_guan at gta01.hmw-consulting.de
tony_guan at gta01.hmw-consulting.de
Wed Dec 20 11:37:19 CET 2006
Author: tony_guan
Date: 2006-12-20 11:36:51 +0100 (Wed, 20 Dec 2006)
New Revision: 438
Added:
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
Modified:
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/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-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-digit-button.c
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
Log:
MokoAutolist refined,buttons added, deletebutton function added,window-dialer finished
Now this application can do some DEMO job, unless some of the colors or effect still remain not perfect. Please look at it first.
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-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am 2006-12-20 10:36:51 UTC (rev 438)
@@ -9,7 +9,8 @@
moko-dialer-tip.c\
moko-dialer-autolist.c\
contacts.c\
-common.c
+common.c\
+openmoko-dialer-window-dialer.c
openmoko_dialer_LDADD = @OPENMOKO_LIBS@
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-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c 2006-12-20 10:36:51 UTC (rev 438)
@@ -375,7 +375,7 @@
int contact_string_has_sensentive (char * content, char *string)
{
int i;
- g_printf("hassensentive:%s,%s\n",content,string);
+// g_printf("hassensentive:%s,%s\n",content,string);
if(content==0)
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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -86,9 +86,7 @@
int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number);
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(gchar* content,gchar *string);
-
-
+int contact_string_has_sensentive (char * content, char *string);
#ifdef __cplusplus
}
#endif
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-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c 2006-12-20 10:36:51 UTC (rev 438)
@@ -96,7 +96,8 @@
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.
@@ -114,6 +115,26 @@
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.
+ for(gint 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
*
@@ -121,15 +142,17 @@
*
* @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)
+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)
@@ -151,20 +174,15 @@
moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
}
- //we set the first one as defaultly selected
- moko_dialer_autolist_set_select(moko_dialer_autolist, 0);
+ if(selectdefault)
+ {
+ //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);
+ 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);
@@ -172,8 +190,9 @@
return 1;
}
-
-gint moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *moko_dialer_autolist,gchar * string)
+//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
@@ -190,7 +209,7 @@
len=strlen(string);
else
len=0;
- DBG_TRACE();
+// DBG_TRACE();
//insert the tips here to avoid the _show_all show it from the start.
GtkWidget * imagePerson;
@@ -207,9 +226,13 @@
{
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;
+ 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;
for(int i=0;i<MOKO_DIALER_MAX_TIPS;i++)
{
@@ -222,10 +245,13 @@
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_set_size_request (tip, 20, 20);
gtk_widget_hide(tip);
@@ -264,9 +290,9 @@
}
//DBG_MESSAGE("inserted=%d",inserted);
-moko_dialer_autolist_fill_alternative(moko_dialer_autolist,inserted);
+moko_dialer_autolist_fill_alternative(moko_dialer_autolist,inserted,selectdefault);
-DBG_LEAVE();
+//DBG_LEAVE();
return inserted;
}
@@ -295,10 +321,32 @@
}
+
+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)
{
-if(selected!=-1&&selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount)
+ if(selected==-1)
+ {
+
+ //set the selected status to be false
+ for(gint 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]))
@@ -312,8 +360,9 @@
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);
+// 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]));
}
@@ -333,8 +382,9 @@
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);
+// 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;
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-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -62,7 +62,7 @@
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
- gint g_selected;///<indicates the offset of the selected ready contacts list
+ gboolean selected;///<indicates wether some tip is currently selected.
gint g_alternatecount;///<indicates how many alternative is ready in the ready list array.
@@ -88,8 +88,11 @@
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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -23,7 +23,7 @@
#define MOKO_DIALER_MAX_PATH_LEN (128)
//MAXDISPNAMENUM MUST >=1 & <=9!
//only when user inputs at least MINSENSATIVELEN, should we start to search.
-#define MOKO_DIALER_MIN_SENSATIVE_LEN (1)
+#define MOKO_DIALER_MIN_SENSATIVE_LEN (3)
#define MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH ("./default.png")
#define MOKO_DIALER_MAX_TIPS (3)
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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -98,30 +98,5 @@
N_COLUMN
};
-typedef struct _dialer_data
-{
- //the global data area begins here
-
-MokoDialerTextview *moko_dialer_text_view;
-
-MokoDialerAutolist *moko_dialer_autolist;
-
-DIALER_CONTACTS_LIST_HEAD g_contactlist; ///< the whole list of the contacts from the contact book.
-
-HISTORY_LIST_HEAD g_historylist; ///< the whole list of the talk history
-
-GLOBAL_STATE g_state; ///< the global states holder. we count on it a lot.
-
-gint g_ptimeout; ///< the timer hanle
-
-TIMER_DATA g_timer_data;///< the data used by the timers
-
-// GtkListStore *g_list_store_filter;///<the list store used by the gtktreeview, for displaying the history list dynamically.
-
-// HISTORY_TYPE g_historyfiltertype;///<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;
-
#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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c 2006-12-20 10:36:51 UTC (rev 438)
@@ -14,6 +14,7 @@
* GNU Lesser Public License for more details.
*
* Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+
*/
#include "moko-dialer-textview.h"
@@ -49,8 +50,8 @@
static void moko_dialer_textview_init (MokoDialerTextview *moko_dialer_textview)
{
-GtkTextView *textview=0;
-GtkTextBuffer *buffer;
+ GtkTextView *textview=0;
+ GtkTextBuffer *buffer;
textview=&moko_dialer_textview->textview;
buffer = gtk_text_view_get_buffer (textview);
@@ -88,7 +89,7 @@
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;
}
@@ -261,7 +262,7 @@
GtkTextIter insertiter;
GtkTextMark *insertmark;
-DBG_ENTER();
+//DBG_ENTER();
/* Obtaining the buffer associated with the widget. */
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
@@ -278,19 +279,56 @@
strcpy(input,"");
return 0;
}
- DBG_TRACE();
+// 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);
+//DBG_MESSAGE("%s",codestring);
strcpy(input,codestring);
- DBG_TRACE();
+// DBG_TRACE();
g_free(codestring);
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)
@@ -306,8 +344,8 @@
gint offsetend;
gint offsetstart;
-DBG_ENTER();
-DBG_MESSAGE("Sensative string:%s",string);
+//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));
@@ -332,7 +370,7 @@
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;
@@ -361,6 +399,7 @@
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.
}
}
@@ -372,7 +411,7 @@
//gtk_widget_grab_focus(text_view);
//g_free (codestring );
-DBG_LEAVE();
+//DBG_LEAVE();
return 1;
}
@@ -391,6 +430,9 @@
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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -51,6 +51,7 @@
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
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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-digit-button.c 2006-12-20 10:36:51 UTC (rev 438)
@@ -70,7 +70,8 @@
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 (TRUE, 0);
+ GtkWidget * hbox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox);
gtk_container_add (GTK_CONTAINER (digitbutton), hbox);
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-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c 2006-12-20 10:36:51 UTC (rev 438)
@@ -30,92 +30,12 @@
#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)
-{
-char input[2];
-input[0]=parac;
-input[1]=0;
-char codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
-
-
-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);
-
-moko_dialer_textview_get_input(moko_dialer_text_view,codesinput, 0);
-
-moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,codesinput);
-
-}
-void
-on_dialer_panel_user_hold(GtkWidget * widget,gchar parac,
- gpointer user_data)
-{
-
-g_print("on_dialer_panel_user_hold:%c\n", parac);
-}
-
-
+#include "openmoko-dialer-window-dialer.h"
int main( int argc, char** argv )
{
MOKO_DIALER_APP_DATA* p_dialer_data;
p_dialer_data=calloc(1,sizeof(MOKO_DIALER_APP_DATA));
- GtkVBox* vbox = NULL;
- static MokoFingerToolBox* tools = NULL;
/* Initialize GTK+ */
gtk_init( &argc, &argv );
@@ -127,81 +47,9 @@
MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
g_set_application_name( "OpenMoko Dialer" );
- /* main window */
- MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+//init the dialer window
+ window_dialer_init(p_dialer_data);
- /* application menu */
- 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(gtk_main_quit), NULL );
-
- gtk_menu_shell_append( appmenu, closeitem );
- moko_finger_window_set_application_menu( window, appmenu );
-
- /* connect close event */
- 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( 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;
-
- gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(mokotextview), FALSE,FALSE, 5 );
-
-
- MokoDialerPanel* mokodialerpanel=moko_dialer_panel_new();
-
-
-
- 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 );
-
-
-
- gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(hbox), TRUE, TRUE, 5 );
-
-
-
-
-
-
-
- moko_finger_window_set_contents( window, GTK_WIDGET(vbox) );
-
- /* show everything and run main loop */
- gtk_widget_show_all( GTK_WIDGET(window) );
-
-
gtk_main();
contact_release_contact_list(&(p_dialer_data->g_contactlist));
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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -16,3 +16,32 @@
* Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
*/
#include "moko-dialer-includes.h"
+
+ typedef struct _dialer_data
+{
+ //the global data area begins here
+
+
+MokoDialerTextview *moko_dialer_text_view;
+
+MokoDialerAutolist *moko_dialer_autolist;
+
+DIALER_CONTACTS_LIST_HEAD g_contactlist; ///< the whole list of the contacts from the contact book.
+
+HISTORY_LIST_HEAD g_historylist; ///< the whole list of the talk history
+
+GLOBAL_STATE g_state; ///< the global states holder. we count on it a lot.
+
+gint g_ptimeout; ///< the timer hanle
+
+TIMER_DATA g_timer_data;///< the data used by the timers
+
+GtkWidget * window_dialer;
+
+// GtkListStore *g_list_store_filter;///<the list store used by the gtktreeview, for displaying the history list dynamically.
+
+// HISTORY_TYPE g_historyfiltertype;///<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;
+
Added: 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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c 2006-12-20 10:36:51 UTC (rev 438)
@@ -0,0 +1,282 @@
+/* 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.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 <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"
+
+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,"");
+}
+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];
+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);
+else
+ moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
+
+
+}
+
+}
+
+void cb_history_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+{
+ g_debug( "history button clicked" );
+}
+
+void cb_dialer_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+{
+ g_debug( "dialer button clicked" );
+}
+
+
+
+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)
+{
+char input[2];
+input[0]=parac;
+input[1]=0;
+char codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
+
+
+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);
+
+moko_dialer_textview_get_input(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,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)
+{
+
+ GtkVBox* vbox = NULL;
+
+
+ MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+
+ /* application menu */
+ 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(gtk_main_quit), NULL );
+
+ gtk_menu_shell_append( appmenu, closeitem );
+ moko_finger_window_set_application_menu( window, appmenu );
+
+ /* connect close event */
+ 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 );
+
+
+ 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;
+
+ 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
+
+/*
+ GtkWidget *iconimage = gtk_image_new();
+ file_load_person_image_from_relative_path( iconimage,"unkown.png");
+ //gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_BUTTON);
+ */
+// moko_pixmap_button_set_finger_toolbox_btn_center_image (button1, iconimage);
+ 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_action_btn_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_action_btn_center_stock(button3,"gtk-refresh");
+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_action_btn_center_stock(button2,"gtk-yes");
+ 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;
+}
+
Added: 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 2006-12-20 02:43:28 UTC (rev 437)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.h 2006-12-20 10:36:51 UTC (rev 438)
@@ -0,0 +1,20 @@
+/* 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"
+
+gint window_dialer_init( MOKO_DIALER_APP_DATA* p_dialer_data);
More information about the commitlog
mailing list