Changeset 2094
- Timestamp:
- 05/29/07 17:00:58 (6 years ago)
- Location:
- trunk/src/target/OM-2007/applications/openmoko-dialer/src
- Files:
-
- 3 edited
-
dialer-main.h (modified) (1 diff)
-
dialer-window-history.c (modified) (11 diffs)
-
dialer-window-history.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h
r2069 r2094 91 91 gboolean history_need_to_update; 92 92 93 GtkListStore *g_list_store; /* The actual list store */ 93 94 GtkTreeModel *g_list_store_filter; ///<the list store used by the gtktreeview, for displaying the history list dynamically. 94 95 gint g_history_filter_type; 96 95 97 GdkPixbuf *g_iconReceived, *g_iconMissed, *g_iconDialed; ///<the global pixbuf for the 3 icons displayed in the history window.}DIALER_APP_DATA; 96 98 } MokoDialerData; -
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
r2078 r2094 24 24 25 25 #include <gtk/gtk.h> 26 #include <string.h> 26 27 27 28 #include "common.h" … … 33 34 /* call types */ 34 35 typedef enum { 35 ALL ,36 ALL =0, 36 37 MISSED, 37 38 OUTGOING, … … 39 40 } CallFilter; 40 41 42 #define HISTORY_CALL_INCOMING_ICON "moko-history-call-in" 43 #define HISTORY_CALL_OUTGOING_ICON "moko-history-call-out" 44 #define HISTORY_CALL_MISSED_ICON "moko-history-call-missed" 45 41 46 /* function declarations */ 42 47 … … 46 51 static GtkWidget *history_create_menu_history (MokoDialerData * p_dialer_data); 47 52 static gint history_build_history_list_view (MokoDialerData * p_dialer_data); 48 53 static void on_entry_added_cb (MokoJournal *journal, 54 MokoJournalEntry *entry, 55 MokoDialerData * p_dialer_data); 49 56 50 57 /** … … 62 69 CallFilter type) 63 70 { 71 p_dialer_data->g_history_filter_type = type; 72 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER 73 (p_dialer_data->g_list_store_filter)); 74 64 75 return 0; 65 76 } … … 556 567 GtkTreeIter * iter, gpointer data) 557 568 { 558 /*559 569 MokoDialerData *p_dialer_data = (MokoDialerData *) data; 560 570 CallFilter type; 561 571 if (p_dialer_data->g_history_filter_type == ALL) 562 572 return TRUE; 563 gtk_tree_model_get (model, iter, COLUMN_TYPE, &type, -1); 573 574 gtk_tree_model_get (model, iter, HISTORY_CALL_TYPE_COLUMN, &type, -1); 575 564 576 if (type == p_dialer_data->g_history_filter_type) 565 577 return TRUE; 566 578 else 567 579 return FALSE; 568 */580 569 581 return TRUE; 570 582 } … … 621 633 /* Set up a list store for the history items */ 622 634 /* UID, DSTART, MISSED, DIRECTION */ 623 list_store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT); 624 625 626 //we will use a filter to facilitate the filtering in treeview without rebuilding the database. 627 p_dialer_data->g_list_store_filter = 635 list_store = gtk_list_store_new (5, G_TYPE_STRING, 636 G_TYPE_INT, 637 G_TYPE_STRING, 638 G_TYPE_STRING, 639 G_TYPE_INT); 640 641 p_dialer_data->g_list_store = list_store; 642 643 /* We setup the default filter */ 644 p_dialer_data->g_history_filter_type = ALL; 645 646 //we will use a filter to facilitate the filtering in treeview without rebuilding the database. p_dialer_data->g_list_store_filter = 647 p_dialer_data->g_list_store_filter = 628 648 gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL); 629 649 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER … … 646 666 * here 647 667 */ 648 if (!p_dialer_data->journal || !moko_journal_get_nb_entries (p_dialer_data->journal)) 668 if (!p_dialer_data->journal) 669 { 670 g_print ("there is no journal\n"); 649 671 return 1; 650 651 j_entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY); 652 653 /* Bail out if we couldn't get the entry. Do we need to display a warning here? */ 654 if (!j_entry) 655 return 0; 672 } 673 /* We register callbacks for when an entry is added, so we can keep the 674 history up-to-date */ 675 moko_journal_set_entry_added_callback (p_dialer_data->journal, 676 (MokoJournalEntryAddedFunc)on_entry_added_cb, 677 (gpointer)p_dialer_data); 678 679 if (!moko_journal_get_nb_entries (p_dialer_data->journal)) 680 { 681 g_print ("there are no entries in the journal\n"); 682 return 1; 683 } 656 684 657 685 while (moko_journal_get_entry_at (p_dialer_data->journal, i, &j_entry)) … … 660 688 gchar *icon_name; 661 689 const gchar *display_text; 662 int dstart;690 time_t dstart; 663 691 enum MessageDirection direction; 664 692 gboolean was_missed; 665 693 const MokoTime *time; 666 694 MokoJournalVoiceInfo *info = NULL; 695 CallFilter type; 696 697 /* We're not interested in anything other than voice entrys */ 698 if (moko_journal_entry_get_type (j_entry) != VOICE_JOURNAL_ENTRY) 699 { 700 i++; 701 continue; 702 } 703 667 704 uid = moko_journal_entry_get_contact_uid (j_entry); 668 705 moko_journal_entry_get_direction (j_entry, &direction); 669 706 time = moko_journal_entry_get_dtstart (j_entry); 670 was_missed = moko_journal_voice_info_get_was_missed ((MokoJournalVoiceInfo*) j_entry); 671 number = moko_journal_voice_info_get_distant_number ((MokoJournalVoiceInfo*)j_entry); 672 707 dstart = moko_time_as_timet (time); 708 moko_journal_entry_get_voice_info (j_entry, &info); 709 was_missed = moko_journal_voice_info_get_was_missed (info); 710 number = moko_journal_voice_info_get_distant_number (info); 711 712 /* If the number is null, the number may have been stored in the summary*/ 713 if (strcmp (number, "NULL") == 0) 714 number = moko_journal_entry_get_summary (j_entry); 715 716 /* Load the correct icon */ 673 717 if (direction == DIRECTION_OUT) 674 icon_name = "call-in"; 718 { 719 icon_name = HISTORY_CALL_OUTGOING_ICON; 720 type = OUTGOING; 721 } 675 722 else 723 { 676 724 if (was_missed) 677 icon_name = "call-missed"; 725 { 726 icon_name = HISTORY_CALL_MISSED_ICON; 727 type = MISSED; 728 } 678 729 else 679 icon_name = "call-out"; 680 730 { 731 icon_name = HISTORY_CALL_INCOMING_ICON; 732 type = INCOMING; 733 } 734 } 681 735 /* display text should be either the contact name, or the number if the 682 736 * contact name is not know */ 683 737 /* FIXME: look up uid */ 684 738 display_text = number; 685 739 686 740 gtk_list_store_insert_with_values (list_store, NULL, 0, 687 741 HISTORY_NUMBER_COLUMN, number, … … 689 743 HISTORY_ICON_NAME_COLUMN, icon_name, 690 744 HISTORY_DISPLAY_TEXT_COLUMN, display_text, 745 HISTORY_CALL_TYPE_COLUMN, type, 691 746 -1); 692 693 747 i++; 694 748 } … … 854 908 } 855 909 856 910 static void 911 on_entry_added_cb (MokoJournal *journal, 912 MokoJournalEntry *j_entry, 913 MokoDialerData * p_dialer_data) 914 { 915 GtkListStore *list_store; 916 const gchar *uid, *number; 917 gchar *icon_name; 918 const gchar *display_text; 919 time_t dstart; 920 enum MessageDirection direction; 921 gboolean was_missed; 922 const MokoTime *time; 923 MokoJournalVoiceInfo *info = NULL; 924 CallFilter type; 925 926 g_return_if_fail (p_dialer_data); 927 /* We're not interested in anything other than voice entrys */ 928 if (moko_journal_entry_get_type (j_entry) != VOICE_JOURNAL_ENTRY) 929 { 930 return; 931 } 932 /* Get the list store*/ 933 list_store = p_dialer_data->g_list_store; 934 935 uid = moko_journal_entry_get_contact_uid (j_entry); 936 moko_journal_entry_get_direction (j_entry, &direction); 937 time = moko_journal_entry_get_dtstart (j_entry); 938 dstart = moko_time_as_timet (time); 939 moko_journal_entry_get_voice_info (j_entry, &info); 940 was_missed = moko_journal_voice_info_get_was_missed (info); 941 number = moko_journal_voice_info_get_distant_number (info); 942 943 /* If the number is null, the number may have been stored in the summary*/ 944 if (strcmp (number, "NULL") == 0) 945 number = moko_journal_entry_get_summary (j_entry); 946 947 /* Load the correct icon */ 948 if (direction == DIRECTION_OUT) 949 { 950 icon_name = HISTORY_CALL_OUTGOING_ICON; 951 type = OUTGOING; 952 } 953 else 954 { 955 if (was_missed) 956 { 957 icon_name = HISTORY_CALL_MISSED_ICON; 958 type = MISSED; 959 } 960 else 961 { 962 icon_name = HISTORY_CALL_INCOMING_ICON; 963 type = INCOMING; 964 } 965 } 966 967 /* display text should be either the contact name, or the number if the 968 * contact name is not know */ 969 /* FIXME: look up uid */ 970 display_text = number; 971 972 gtk_list_store_insert_with_values (list_store, NULL, 0, 973 HISTORY_NUMBER_COLUMN, number, 974 HISTORY_DSTART_COLUMN, dstart, 975 HISTORY_ICON_NAME_COLUMN, icon_name, 976 HISTORY_DISPLAY_TEXT_COLUMN, display_text, 977 HISTORY_CALL_TYPE_COLUMN, type, 978 -1); 979 } 980 981 -
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.h
r1880 r2094 26 26 HISTORY_ICON_NAME_COLUMN, /* icon name for display */ 27 27 HISTORY_DISPLAY_TEXT_COLUMN, /* name or number for display */ 28 HISTORY_CALL_TYPE_COLUMN /* Used for identifying the type of call */ 28 29 }; 29 30
Note: See TracChangeset
for help on using the changeset viewer.
