Changeset 2094


Ignore:
Timestamp:
05/29/07 17:00:58 (6 years ago)
Author:
thomas
Message:

Patch by: Neil J Patel <njp@…>

  • Uses correct icons for the history view.
  • Checks that the entry it is loading is a voice entry.
  • Properly loads all voice information.
  • Fixed list-store types.
  • Uses correct icons for incoming/outgoing/missed calls.
  • Connects to the 'entry-added' callback in MokoJournal? to update its view when entries are added.
  • Fixed filtering so you can now use the menu at the top to filter the list of calls.
Location:
trunk/src/target/OM-2007/applications/openmoko-dialer/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h

    r2069 r2094  
    9191  gboolean history_need_to_update; 
    9292 
     93  GtkListStore *g_list_store; /* The actual list store */ 
    9394  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   
    9597  GdkPixbuf *g_iconReceived, *g_iconMissed, *g_iconDialed;      ///<the global pixbuf for the 3 icons displayed in the history window.}DIALER_APP_DATA; 
    9698} MokoDialerData; 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c

    r2078 r2094  
    2424 
    2525#include <gtk/gtk.h> 
     26#include <string.h> 
    2627 
    2728#include "common.h" 
     
    3334/* call types */ 
    3435typedef enum { 
    35   ALL, 
     36  ALL =0, 
    3637  MISSED, 
    3738  OUTGOING, 
     
    3940} CallFilter; 
    4041 
     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 
    4146/* function declarations */ 
    4247 
     
    4651static GtkWidget *history_create_menu_history (MokoDialerData * p_dialer_data); 
    4752static gint history_build_history_list_view (MokoDialerData * p_dialer_data); 
    48  
     53static void on_entry_added_cb (MokoJournal *journal,  
     54                               MokoJournalEntry *entry, 
     55                               MokoDialerData * p_dialer_data); 
    4956 
    5057/** 
     
    6269                            CallFilter type) 
    6370{ 
     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 
    6475 return 0; 
    6576} 
     
    556567                                      GtkTreeIter * iter, gpointer data) 
    557568{ 
    558   /* 
    559569  MokoDialerData *p_dialer_data = (MokoDialerData *) data; 
    560570  CallFilter type; 
    561571  if (p_dialer_data->g_history_filter_type == ALL) 
    562572    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   
    564576  if (type == p_dialer_data->g_history_filter_type) 
    565577    return TRUE; 
    566578  else 
    567579    return FALSE; 
    568     */ 
     580     
    569581  return TRUE; 
    570582} 
     
    621633  /* Set up a list store for the history items */ 
    622634  /* 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 =  
    628648    gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL); 
    629649  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER 
     
    646666   * here 
    647667   */ 
    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"); 
    649671    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  } 
    656684 
    657685  while (moko_journal_get_entry_at (p_dialer_data->journal, i, &j_entry)) 
     
    660688    gchar *icon_name; 
    661689    const gchar *display_text; 
    662     int dstart; 
     690    time_t dstart; 
    663691    enum MessageDirection direction; 
    664692    gboolean was_missed; 
    665693    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     
    667704    uid = moko_journal_entry_get_contact_uid (j_entry); 
    668705    moko_journal_entry_get_direction (j_entry, &direction); 
    669706    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 */ 
    673717    if (direction == DIRECTION_OUT) 
    674       icon_name = "call-in"; 
     718    { 
     719      icon_name = HISTORY_CALL_OUTGOING_ICON; 
     720      type = OUTGOING; 
     721    } 
    675722    else 
     723    { 
    676724      if (was_missed) 
    677         icon_name = "call-missed"; 
     725      { 
     726        icon_name = HISTORY_CALL_MISSED_ICON; 
     727        type = MISSED; 
     728      } 
    678729      else 
    679         icon_name = "call-out"; 
    680  
     730      {  
     731        icon_name = HISTORY_CALL_INCOMING_ICON; 
     732        type = INCOMING;       
     733      } 
     734    } 
    681735    /* display text should be either the contact name, or the number if the 
    682736     * contact name is not know */ 
    683737    /* FIXME: look up uid */ 
    684738    display_text = number; 
    685  
     739     
    686740    gtk_list_store_insert_with_values (list_store, NULL, 0, 
    687741        HISTORY_NUMBER_COLUMN, number, 
     
    689743        HISTORY_ICON_NAME_COLUMN, icon_name, 
    690744        HISTORY_DISPLAY_TEXT_COLUMN, display_text, 
     745        HISTORY_CALL_TYPE_COLUMN, type, 
    691746        -1); 
    692  
    693747    i++; 
    694748  } 
     
    854908} 
    855909 
    856  
     910static void 
     911on_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  
    2626  HISTORY_ICON_NAME_COLUMN, /* icon name for display */ 
    2727  HISTORY_DISPLAY_TEXT_COLUMN, /* name or number for display */ 
     28  HISTORY_CALL_TYPE_COLUMN /* Used for identifying the type of call */ 
    2829}; 
    2930 
Note: See TracChangeset for help on using the changeset viewer.