Changeset 2467


Ignore:
Timestamp:
07/05/07 13:27:10 (6 years ago)
Author:
njp
Message:

2007-07-05 Neil J. Patel <njp@…>

  • src/moko-history.c: (on_delete_clicked): Implemented the 'delete' action.
Location:
trunk/applications/openmoko-dialer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/applications/openmoko-dialer/ChangeLog

    r2462 r2467  
     12007-07-05  Neil J. Patel  <njp@o-hand.com> 
     2 
     3        * src/moko-history.c: (on_delete_clicked): 
     4        Implemented the 'delete' action. 
     5 
    162007-07-04  Neil J. Patel  <njp@o-hand.com> 
    27 
  • trunk/applications/openmoko-dialer/src/moko-history.c

    r2462 r2467  
    127127on_delete_clicked (GtkWidget *button, MokoHistory *history) 
    128128{ 
    129   g_print ("Delete clicked\n"); 
     129  MokoHistoryPrivate *priv; 
     130  GtkWidget *dialog; 
     131  GtkTreeIter iter0; 
     132  GtkTreeIter iter1; 
     133  GtkTreeIter iter2; 
     134  GtkTreeModel *filtered; 
     135  GtkTreeModel *sorted; 
     136  GtkTreeModel *store; 
     137  GtkTreeSelection *selection; 
     138  GtkTreeView *treeview; 
     139  GtkTreePath *path; 
     140  const gchar *uid; 
     141  gint result = 0; 
     142 
     143  g_return_if_fail (MOKO_IS_HISTORY (history)); 
     144  priv = history->priv; 
     145 
     146  treeview = GTK_TREE_VIEW (priv->treeview); 
     147  selection = gtk_tree_view_get_selection (treeview); 
     148 
     149  if (!gtk_tree_selection_get_selected (selection, &filtered, &iter0)) 
     150    ;//return; 
     151 
     152  //gtk_tree_model_get (filtered, &iter0, ENTRY_POINTER_COLUMN, &uid, -1); 
     153 
     154  /* Create a dialog */ 
     155  dialog = gtk_message_dialog_new (gtk_widget_get_ancestor(GTK_WIDGET (history), 
     156                                                            GTK_TYPE_WINDOW), 
     157                                   0, 
     158                                   GTK_MESSAGE_QUESTION, 
     159                                   GTK_BUTTONS_NONE, 
     160                                   "Are you sure you want to permanantly "\ 
     161                                   "delete this call?", NULL); 
     162 
     163  gtk_dialog_add_buttons (GTK_DIALOG (dialog), 
     164                          "Don't Delete", GTK_RESPONSE_CANCEL, 
     165                          GTK_STOCK_DELETE, GTK_RESPONSE_YES, 
     166                          NULL); 
     167  gtk_widget_set_name (dialog, "mokomessagedialog"); 
     168  gtk_container_set_border_width (GTK_CONTAINER (dialog), 0); 
     169 
     170  /* Just some tests 
     171  gtk_widget_set_size_request (dialog,  
     172                               GTK_WIDGET (history)->allocation.width, 
     173                               GTK_WIDGET (history)->allocation.height); 
     174 
     175  gtk_window_move (GTK_WINDOW (dialog), 
     176                   GTK_WIDGET (history)->allocation.x, 
     177                   GTK_WIDGET (history)->allocation.y); 
     178  */ 
     179   
     180  result = gtk_dialog_run (GTK_DIALOG (dialog)); 
     181  switch (result) 
     182  { 
     183    case GTK_RESPONSE_YES: 
     184      break; 
     185    default: 
     186      gtk_widget_destroy (dialog); 
     187      return; 
     188      break; 
     189  } 
     190 
     191  /* Remove the entry from the journal */ 
     192  if (moko_journal_remove_entry_by_uid (priv->journal, uid)) 
     193    moko_journal_write_to_storage (priv->journal); 
     194 
     195  /* Remove the row from the list store */ 
     196  path = gtk_tree_model_get_path (filtered, &iter0); 
     197  sorted = priv->sort_model; 
     198  gtk_tree_model_filter_convert_iter_to_child_iter ( 
     199                                              GTK_TREE_MODEL_FILTER (filtered), 
     200                                              &iter1, &iter0); 
     201 
     202  store = priv->main_model; 
     203  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (sorted), 
     204                                                  &iter2, &iter1); 
     205  gtk_list_store_remove (GTK_LIST_STORE (store), &iter2); 
     206  gtk_tree_view_set_cursor (treeview, path, 0, 0); 
     207 
     208  /* Clean up */ 
     209  gtk_tree_path_free (path); 
     210  gtk_widget_destroy (dialog); 
    130211} 
    131212 
Note: See TracChangeset for help on using the changeset viewer.