Added a menu allowing to filter tasks given their completion state
This commit is contained in:
parent
ec8238e796
commit
bd1f7cd75e
74
po/fr.po
74
po/fr.po
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Todo 0.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2010-08-01 03:49+0200\n"
|
||||
"POT-Creation-Date: 2010-09-04 19:24+0200\n"
|
||||
"PO-Revision-Date: 2010-04-23 14:35+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: French\n"
|
||||
|
@ -20,114 +20,130 @@ msgstr ""
|
|||
msgid "Usage: todo\n"
|
||||
msgstr "Usage: todo\n"
|
||||
|
||||
#: ../src/todo.c:70
|
||||
#: ../src/todo.c:73
|
||||
msgid "Done"
|
||||
msgstr "Effectuée"
|
||||
|
||||
#: ../src/todo.c:72
|
||||
#: ../src/todo.c:75
|
||||
msgid "Title"
|
||||
msgstr "Titre"
|
||||
|
||||
#: ../src/todo.c:74
|
||||
#: ../src/todo.c:77
|
||||
msgid "Beginning"
|
||||
msgstr "Départ"
|
||||
|
||||
#: ../src/todo.c:75
|
||||
#: ../src/todo.c:78
|
||||
msgid "Completion"
|
||||
msgstr "Fin"
|
||||
|
||||
#: ../src/todo.c:85
|
||||
#: ../src/todo.c:88
|
||||
msgid "Unknown"
|
||||
msgstr "Inconnue"
|
||||
|
||||
#: ../src/todo.c:86
|
||||
#: ../src/todo.c:89
|
||||
msgid "Low"
|
||||
msgstr "Faible"
|
||||
|
||||
#: ../src/todo.c:87
|
||||
#: ../src/todo.c:90
|
||||
msgid "Medium"
|
||||
msgstr "Moyenne"
|
||||
|
||||
#: ../src/todo.c:88
|
||||
#: ../src/todo.c:91
|
||||
msgid "High"
|
||||
msgstr "Haute"
|
||||
|
||||
#: ../src/todo.c:89
|
||||
#: ../src/todo.c:92
|
||||
msgid "Urgent"
|
||||
msgstr "Urgent"
|
||||
|
||||
#: ../src/todo.c:105
|
||||
#: ../src/todo.c:108
|
||||
msgid "_New"
|
||||
msgstr "_Nouvelle"
|
||||
|
||||
#: ../src/todo.c:107 ../src/todo.c:142
|
||||
#: ../src/todo.c:110 ../src/todo.c:154
|
||||
msgid "_Edit"
|
||||
msgstr "Modifier"
|
||||
|
||||
#: ../src/todo.c:110
|
||||
#: ../src/todo.c:113
|
||||
msgid "_Close"
|
||||
msgstr "_Fermer"
|
||||
|
||||
#: ../src/todo.c:117 ../src/todo.c:120
|
||||
#: ../src/todo.c:120 ../src/todo.c:123
|
||||
msgid "_Select all"
|
||||
msgstr "Tout sélectionner"
|
||||
|
||||
#: ../src/todo.c:124
|
||||
#: ../src/todo.c:127
|
||||
msgid "_Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
#: ../src/todo.c:126
|
||||
#: ../src/todo.c:129
|
||||
msgid "_Preferences"
|
||||
msgstr "_Préférences"
|
||||
|
||||
#: ../src/todo.c:133 ../src/todo.c:135
|
||||
#: ../src/todo.c:135
|
||||
msgid "_All tasks"
|
||||
msgstr "_Toutes les tâches"
|
||||
|
||||
#: ../src/todo.c:136
|
||||
msgid "_Completed tasks"
|
||||
msgstr "Tâches _complétées"
|
||||
|
||||
#: ../src/todo.c:138
|
||||
msgid "_Remaining tasks"
|
||||
msgstr "Tâches _restantes"
|
||||
|
||||
#: ../src/todo.c:145 ../src/todo.c:147
|
||||
msgid "_About"
|
||||
msgstr "À _propos"
|
||||
|
||||
#: ../src/todo.c:141
|
||||
#: ../src/todo.c:153
|
||||
msgid "_File"
|
||||
msgstr "_Fichier"
|
||||
|
||||
#: ../src/todo.c:143
|
||||
#: ../src/todo.c:155
|
||||
msgid "_View"
|
||||
msgstr "_Vue"
|
||||
|
||||
#: ../src/todo.c:156
|
||||
msgid "_Help"
|
||||
msgstr "_Aide"
|
||||
|
||||
#: ../src/todo.c:151 ../src/todo.c:396
|
||||
#: ../src/todo.c:164 ../src/todo.c:432
|
||||
msgid "New task"
|
||||
msgstr "Nouvelle tâche"
|
||||
|
||||
#: ../src/todo.c:152
|
||||
#: ../src/todo.c:165
|
||||
msgid "Edit task"
|
||||
msgstr "Modifier la tâche"
|
||||
|
||||
#: ../src/todo.c:155 ../src/todo.c:158
|
||||
#: ../src/todo.c:168 ../src/todo.c:171
|
||||
msgid "Select all"
|
||||
msgstr "Tout sélectionner"
|
||||
|
||||
#: ../src/todo.c:161
|
||||
#: ../src/todo.c:174
|
||||
msgid "Delete task"
|
||||
msgstr "Supprimer la tâche"
|
||||
|
||||
#: ../src/todo.c:165
|
||||
#: ../src/todo.c:178
|
||||
msgid "Preferences"
|
||||
msgstr "Préférences"
|
||||
|
||||
#: ../src/todo.c:204
|
||||
#: ../src/todo.c:223
|
||||
msgid "Todo"
|
||||
msgstr "Todo"
|
||||
|
||||
#: ../src/todo.c:301
|
||||
#: ../src/todo.c:328
|
||||
msgid "Priority"
|
||||
msgstr "Priorité"
|
||||
|
||||
#: ../src/todo.c:357 ../src/todo.c:362
|
||||
#: ../src/todo.c:393 ../src/todo.c:398
|
||||
msgid "Error"
|
||||
msgstr "Erreur"
|
||||
|
||||
#: ../src/todo.c:449
|
||||
#: ../src/todo.c:485
|
||||
msgid "Are you sure you want to delete the selected task(s)?"
|
||||
msgstr "Voulez-vous vraiment supprimer la sélection?"
|
||||
|
||||
#: ../src/todo.c:657 ../src/todo.c:662
|
||||
#: ../src/todo.c:693 ../src/todo.c:698
|
||||
msgid "Question"
|
||||
msgstr "Question"
|
||||
|
|
|
@ -86,6 +86,34 @@ void on_edit_select_all(gpointer data)
|
|||
}
|
||||
|
||||
|
||||
/* view menu */
|
||||
/* on_view_all_tasks */
|
||||
void on_view_all_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_ALL_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* on_view_completed_tasks */
|
||||
void on_view_completed_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_COMPLETED_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* on_view_remaining_tasks */
|
||||
void on_view_remaining_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_REMAINING_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* help menu */
|
||||
/* on_help_about */
|
||||
void on_help_about(gpointer data)
|
||||
|
|
|
@ -35,6 +35,11 @@ void on_edit_select_all(gpointer data);
|
|||
void on_edit_delete(gpointer data);
|
||||
void on_edit_preferences(gpointer data);
|
||||
|
||||
/* view menu */
|
||||
void on_view_all_tasks(gpointer data);
|
||||
void on_view_completed_tasks(gpointer data);
|
||||
void on_view_remaining_tasks(gpointer data);
|
||||
|
||||
/* help menu */
|
||||
void on_help_about(gpointer data);
|
||||
|
||||
|
|
86
src/todo.c
86
src/todo.c
|
@ -46,6 +46,9 @@ struct _Todo
|
|||
GtkWidget * scrolled;
|
||||
GtkListStore * store;
|
||||
GtkListStore * priorities;
|
||||
GtkTreeModel * filter;
|
||||
GtkTreeModel * filter_sort;
|
||||
TodoView filter_view;
|
||||
GtkWidget * view;
|
||||
GtkWidget * statusbar;
|
||||
GtkWidget * about;
|
||||
|
@ -127,6 +130,15 @@ static DesktopMenu _edit_menu[] =
|
|||
GTK_STOCK_PREFERENCES, GDK_CONTROL_MASK, GDK_P },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static DesktopMenu _view_menu[] =
|
||||
{
|
||||
{ N_("_All tasks"), G_CALLBACK(on_view_all_tasks), NULL, 0, 0 },
|
||||
{ N_("_Completed tasks"), G_CALLBACK(on_view_completed_tasks), NULL, 0,
|
||||
0 },
|
||||
{ N_("_Remaining tasks"), G_CALLBACK(on_view_remaining_tasks), NULL, 0,
|
||||
0 },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static DesktopMenu _help_menu[] =
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
|
@ -140,6 +152,7 @@ static DesktopMenubar _menubar[] =
|
|||
{
|
||||
{ N_("_File"), _file_menu },
|
||||
{ N_("_Edit"), _edit_menu },
|
||||
{ N_("_View"), _view_menu },
|
||||
{ N_("_Help"), _help_menu },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
@ -171,11 +184,17 @@ static DesktopToolbar _toolbar[] =
|
|||
|
||||
/* prototypes */
|
||||
static int _todo_confirm(GtkWidget * window, char const * message);
|
||||
static gboolean _todo_get_iter(Todo * todo, GtkTreeIter * iter,
|
||||
GtkTreePath * path);
|
||||
static char * _todo_task_get_directory(void);
|
||||
static char * _todo_task_get_filename(char const * filename);
|
||||
static char * _todo_task_get_new_filename(void);
|
||||
static void _todo_task_save(Todo * todo, GtkTreeIter * iter);
|
||||
|
||||
/* callbacks */
|
||||
static gboolean _on_todo_filter_view(GtkTreeModel * model, GtkTreeIter * iter,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
|
@ -256,7 +275,15 @@ static void _new_view(Todo * todo)
|
|||
0, _todo_priorities[i].priority,
|
||||
1, _todo_priorities[i].title, -1);
|
||||
}
|
||||
todo->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(todo->store));
|
||||
todo->filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(todo->store),
|
||||
NULL);
|
||||
todo->filter_view = TODO_VIEW_ALL_TASKS;
|
||||
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(
|
||||
todo->filter), _on_todo_filter_view, todo,
|
||||
NULL);
|
||||
todo->filter_sort = gtk_tree_model_sort_new_with_model(todo->filter);
|
||||
todo->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
||||
todo->filter_sort));
|
||||
if((sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(todo->view)))
|
||||
!= NULL)
|
||||
gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
|
||||
|
@ -323,6 +350,15 @@ void todo_delete(Todo * todo)
|
|||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* todo_set_view */
|
||||
void todo_set_view(Todo * todo, TodoView view)
|
||||
{
|
||||
todo->filter_view = view;
|
||||
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(todo->filter));
|
||||
}
|
||||
|
||||
|
||||
/* useful */
|
||||
/* todo_about */
|
||||
void todo_about(Todo * todo)
|
||||
|
@ -473,7 +509,7 @@ static void _task_delete_selected_foreach(GtkTreeRowReference * reference,
|
|||
return;
|
||||
if((path = gtk_tree_row_reference_get_path(reference)) == NULL)
|
||||
return;
|
||||
if(gtk_tree_model_get_iter(model, &iter, path) == TRUE)
|
||||
if(_todo_get_iter(todo, &iter, path) == TRUE)
|
||||
{
|
||||
gtk_tree_model_get(model, &iter, TD_COL_TASK, &task, -1);
|
||||
task_unlink(task);
|
||||
|
@ -586,7 +622,7 @@ void todo_task_set_priority(Todo * todo, GtkTreePath * path,
|
|||
size_t i;
|
||||
TodoPriority tp = TODO_PRIORITY_UNKNOWN;
|
||||
|
||||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
_todo_get_iter(todo, &iter, path);
|
||||
gtk_tree_model_get(model, &iter, TD_COL_TASK, &task, -1);
|
||||
task_set_priority(task, priority);
|
||||
for(i = 0; _todo_priorities[i].title != NULL; i++)
|
||||
|
@ -608,7 +644,7 @@ void todo_task_set_title(Todo * todo, GtkTreePath * path, char const * title)
|
|||
GtkTreeIter iter;
|
||||
Task * task;
|
||||
|
||||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
_todo_get_iter(todo, &iter, path);
|
||||
gtk_tree_model_get(model, &iter, TD_COL_TASK, &task, -1);
|
||||
task_set_title(task, title);
|
||||
gtk_list_store_set(todo->store, &iter, TD_COL_TITLE, title, -1);
|
||||
|
@ -626,7 +662,7 @@ void todo_task_toggle_done(Todo * todo, GtkTreePath * path)
|
|||
struct tm t;
|
||||
char completion[32] = "";
|
||||
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(todo->store), &iter, path);
|
||||
_todo_get_iter(todo, &iter, path);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(todo->store), &iter,
|
||||
TD_COL_TASK, &task, TD_COL_DONE, &done, -1);
|
||||
done = !done;
|
||||
|
@ -668,6 +704,23 @@ static int _todo_confirm(GtkWidget * window, char const * message)
|
|||
}
|
||||
|
||||
|
||||
/* todo_get_iter */
|
||||
static gboolean _todo_get_iter(Todo * todo, GtkTreeIter * iter,
|
||||
GtkTreePath * path)
|
||||
{
|
||||
GtkTreeIter p;
|
||||
|
||||
if(gtk_tree_model_get_iter(GTK_TREE_MODEL(todo->filter_sort), iter,
|
||||
path) == FALSE)
|
||||
return FALSE;
|
||||
gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(
|
||||
todo->filter_sort), &p, iter);
|
||||
gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(
|
||||
todo->filter), iter, &p);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* todo_task_get_directory */
|
||||
static char * _todo_task_get_directory(void)
|
||||
{
|
||||
|
@ -743,3 +796,26 @@ static void _todo_task_save(Todo * todo, GtkTreeIter * iter)
|
|||
gtk_tree_model_get(model, iter, TD_COL_TASK, &task, -1);
|
||||
task_save(task);
|
||||
}
|
||||
|
||||
|
||||
/* callbacks */
|
||||
/* on_todo_filter_view */
|
||||
static gboolean _on_todo_filter_view(GtkTreeModel * model, GtkTreeIter * iter,
|
||||
gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
gboolean done = FALSE;
|
||||
|
||||
switch(todo->filter_view)
|
||||
{
|
||||
case TODO_VIEW_COMPLETED_TASKS:
|
||||
gtk_tree_model_get(model, iter, TD_COL_DONE, &done, -1);
|
||||
return done ? TRUE : FALSE;
|
||||
case TODO_VIEW_REMAINING_TASKS:
|
||||
gtk_tree_model_get(model, iter, TD_COL_DONE, &done, -1);
|
||||
return done ? FALSE : TRUE;
|
||||
default:
|
||||
case TODO_VIEW_ALL_TASKS:
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
10
src/todo.h
10
src/todo.h
|
@ -35,11 +35,21 @@ typedef enum _TodoPriority
|
|||
TODO_PRIORITY_URGENT
|
||||
} TodoPriority;
|
||||
|
||||
typedef enum _TodoView
|
||||
{
|
||||
TODO_VIEW_ALL_TASKS,
|
||||
TODO_VIEW_COMPLETED_TASKS,
|
||||
TODO_VIEW_REMAINING_TASKS
|
||||
} TodoView;
|
||||
|
||||
|
||||
/* functions */
|
||||
Todo * todo_new(void);
|
||||
void todo_delete(Todo * todo);
|
||||
|
||||
/* accessors */
|
||||
void todo_set_view(Todo * todo, TodoView view);
|
||||
|
||||
/* useful */
|
||||
void todo_about(Todo * todo);
|
||||
int todo_error(Todo * todo, char const * message, int ret);
|
||||
|
|
Loading…
Reference in New Issue
Block a user