The start and completion/due dates can now be modified (not elegant but works)

This commit is contained in:
Pierre Pronchery 2011-01-29 23:25:06 +00:00
parent b4a05085ba
commit bc10a1cf9f
6 changed files with 137 additions and 19 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Todo 0.0.0\n" "Project-Id-Version: Todo 0.0.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-12-31 17:15+0100\n" "POT-Creation-Date: 2011-01-30 00:24+0100\n"
"PO-Revision-Date: 2010-04-23 14:35+0200\n" "PO-Revision-Date: 2010-04-23 14:35+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n" "Language-Team: French\n"
@ -20,19 +20,19 @@ msgstr ""
msgid "Usage: todo\n" msgid "Usage: todo\n"
msgstr "Usage: todo\n" msgstr "Usage: todo\n"
#: ../src/taskedit.c:64 #: ../src/taskedit.c:65
msgid "Edit task: " msgid "Edit task: "
msgstr "Modifier la tâche : " msgstr "Modifier la tâche : "
#: ../src/taskedit.c:74 #: ../src/taskedit.c:75
msgid "Title:" msgid "Title:"
msgstr "Titre:" msgstr "Titre:"
#: ../src/taskedit.c:84 #: ../src/taskedit.c:85
msgid "Priority:" msgid "Priority:"
msgstr "Priorité:" msgstr "Priorité:"
#: ../src/taskedit.c:94 #: ../src/taskedit.c:95
msgid "Description:" msgid "Description:"
msgstr "Description:" msgstr "Description:"
@ -124,7 +124,7 @@ msgstr "_Vue"
msgid "_Help" msgid "_Help"
msgstr "_Aide" msgstr "_Aide"
#: ../src/todo.c:166 ../src/todo.c:497 #: ../src/todo.c:166 ../src/todo.c:499
msgid "New task" msgid "New task"
msgstr "Nouvelle tâche" msgstr "Nouvelle tâche"
@ -164,19 +164,19 @@ msgstr "Tâches complétées"
msgid "Remaining tasks" msgid "Remaining tasks"
msgstr "Tâches restantes" msgstr "Tâches restantes"
#: ../src/todo.c:357 #: ../src/todo.c:359
msgid "Priority" msgid "Priority"
msgstr "Priorité" msgstr "Priorité"
#: ../src/todo.c:450 ../src/todo.c:455 #: ../src/todo.c:452 ../src/todo.c:457
msgid "Error" msgid "Error"
msgstr "Erreur" msgstr "Erreur"
#: ../src/todo.c:550 #: ../src/todo.c:552
msgid "Are you sure you want to delete the selected task(s)?" msgid "Are you sure you want to delete the selected task(s)?"
msgstr "Voulez-vous vraiment supprimer la sélection?" msgstr "Voulez-vous vraiment supprimer la sélection?"
#: ../src/todo.c:785 ../src/todo.c:790 #: ../src/todo.c:890 ../src/todo.c:895
msgid "Question" msgid "Question"
msgstr "Question" msgstr "Question"

View File

@ -192,6 +192,15 @@ void on_task_activated(gpointer data)
} }
/* on_task_cursor_changed */
void on_task_cursor_changed(gpointer data)
{
Todo * todo = data;
todo_task_cursor_changed(todo);
}
/* on_task_done_toggled */ /* on_task_done_toggled */
void on_task_done_toggled(GtkCellRendererToggle * renderer, gchar * path, void on_task_done_toggled(GtkCellRendererToggle * renderer, gchar * path,
gpointer data) gpointer data)

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Todo */ /* This file is part of DeforaOS Desktop Todo */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -53,6 +53,7 @@ void on_view_as(gpointer data);
/* view */ /* view */
void on_task_activated(gpointer data); void on_task_activated(gpointer data);
void on_task_cursor_changed(gpointer data);
void on_task_done_toggled(GtkCellRendererToggle * renderer, gchar * path, void on_task_done_toggled(GtkCellRendererToggle * renderer, gchar * path,
gpointer data); gpointer data);
void on_task_priority_edited(GtkCellRendererText * renderer, gchar * path, void on_task_priority_edited(GtkCellRendererText * renderer, gchar * path,

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Todo */ /* This file is part of DeforaOS Desktop Todo */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -53,6 +53,7 @@ TaskEdit * taskedit_new(Todo * todo, Task * task)
GtkWidget * hbox; GtkWidget * hbox;
GtkWidget * scrolled; GtkWidget * scrolled;
GtkWidget * widget; GtkWidget * widget;
GtkWidget * entry;
GtkWidget * bbox; GtkWidget * bbox;
char const * description; char const * description;
@ -85,9 +86,9 @@ TaskEdit * taskedit_new(Todo * todo, Task * task)
gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
gtk_size_group_add_widget(group, widget); gtk_size_group_add_widget(group, widget);
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
taskedit->priority = gtk_entry_new(); taskedit->priority = gtk_combo_box_entry_new_text();
gtk_entry_set_text(GTK_ENTRY(taskedit->priority), task_get_priority( entry = gtk_bin_get_child(GTK_BIN(taskedit->priority));
task)); gtk_entry_set_text(GTK_ENTRY(entry), task_get_priority(task));
gtk_box_pack_start(GTK_BOX(hbox), taskedit->priority, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), taskedit->priority, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
/* description */ /* description */
@ -135,6 +136,7 @@ static void _on_taskedit_cancel(gpointer data)
static void _on_taskedit_ok(gpointer data) static void _on_taskedit_ok(gpointer data)
{ {
TaskEdit * taskedit = data; TaskEdit * taskedit = data;
GtkWidget * entry;
GtkTextBuffer * tbuf; GtkTextBuffer * tbuf;
GtkTextIter start; GtkTextIter start;
GtkTextIter end; GtkTextIter end;
@ -142,8 +144,8 @@ static void _on_taskedit_ok(gpointer data)
task_set_title(taskedit->task, gtk_entry_get_text(GTK_ENTRY( task_set_title(taskedit->task, gtk_entry_get_text(GTK_ENTRY(
taskedit->title))); taskedit->title)));
task_set_priority(taskedit->task, gtk_entry_get_text(GTK_ENTRY( entry = gtk_bin_get_child(GTK_BIN(taskedit->priority));
taskedit->priority))); task_set_priority(taskedit->task, gtk_entry_get_text(GTK_ENTRY(entry)));
tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(taskedit->description)); tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(taskedit->description));
gtk_text_buffer_get_start_iter(tbuf, &start); gtk_text_buffer_get_start_iter(tbuf, &start);
gtk_text_buffer_get_end_iter(tbuf, &end); gtk_text_buffer_get_end_iter(tbuf, &end);

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
static char _copyright[] = static char _copyright[] =
"Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>"; "Copyright (c) 2011 Pierre Pronchery <khorben@defora.org>";
/* This file is part of DeforaOS Desktop Todo */ /* This file is part of DeforaOS Desktop Todo */
static char const _license[] = static char const _license[] =
"This program is free software: you can redistribute it and/or modify\n" "This program is free software: you can redistribute it and/or modify\n"
@ -310,6 +310,8 @@ static void _new_view(Todo * todo)
if((sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(todo->view))) if((sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(todo->view)))
!= NULL) != NULL)
gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE); gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
g_signal_connect_swapped(G_OBJECT(todo->view), "cursor-changed",
G_CALLBACK(on_task_cursor_changed), todo);
g_signal_connect_swapped(G_OBJECT(todo->view), "row-activated", g_signal_connect_swapped(G_OBJECT(todo->view), "row-activated",
G_CALLBACK(on_task_activated), todo); G_CALLBACK(on_task_activated), todo);
/* done column */ /* done column */
@ -585,6 +587,109 @@ static void _task_delete_selected_foreach(GtkTreeRowReference * reference,
} }
/* todo_task_cursor_changed */
static void _task_cursor_changed_date_end(GtkWidget * widget, gpointer data);
static void _task_cursor_changed_date_start(GtkWidget * widget, gpointer data);
void todo_task_cursor_changed(Todo * todo)
{
GtkTreeModel * model = GTK_TREE_MODEL(todo->store);
GtkTreePath * path = NULL;
GtkTreeViewColumn * column = NULL;
GtkTreeIter iter;
Task * task = NULL;
gint id = -1;
GdkRectangle rect;
GtkWidget * popup;
GtkWidget * vbox;
time_t tim;
struct tm t;
GtkWidget * button;
GtkWidget * calendar;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(todo->view), &path, &column);
if(path == NULL)
return;
gtk_tree_model_get_iter(model, &iter, path);
gtk_tree_model_get(model, &iter, TD_COL_TASK, &task, -1);
if(column != NULL)
id = gtk_tree_view_column_get_sort_column_id(column);
if(id == TD_COL_END || id == TD_COL_START)
{
gtk_tree_view_get_cell_area(GTK_TREE_VIEW(todo->view), path,
column, &rect);
popup = gtk_window_new(GTK_WINDOW_POPUP);
vbox = gtk_vbox_new(FALSE, 4);
if((tim = (id == TD_COL_START) ? task_get_start(task)
: task_get_end(task)) == 0)
tim = time(NULL);
localtime_r(&tim, &t);
button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
g_signal_connect_swapped(G_OBJECT(button), "clicked",
G_CALLBACK(gtk_widget_destroy), popup);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, TRUE, 0);
calendar = gtk_calendar_new();
gtk_calendar_select_day(GTK_CALENDAR(calendar), t.tm_mday);
gtk_calendar_select_month(GTK_CALENDAR(calendar), t.tm_mon,
1900 + t.tm_year);
g_signal_connect(G_OBJECT(calendar),
"day-selected-double-click", G_CALLBACK(
(id == TD_COL_START)
? _task_cursor_changed_date_start
: _task_cursor_changed_date_end), task);
gtk_box_pack_start(GTK_BOX(vbox), calendar, FALSE, TRUE, 0);
gtk_window_set_modal(GTK_WINDOW(popup), TRUE);
gtk_window_set_transient_for(GTK_WINDOW(popup), GTK_WINDOW(
todo->window));
gtk_container_add(GTK_CONTAINER(popup), vbox);
gtk_window_get_position(GTK_WINDOW(todo->window), &rect.width,
&rect.height);
gtk_window_move(GTK_WINDOW(popup), rect.width + rect.x,
rect.height + rect.y);
gtk_widget_show_all(popup);
}
gtk_tree_path_free(path);
}
static time_t _task_cursor_changed_date_get(GtkWidget * widget, time_t time)
{
struct tm t;
unsigned int year;
unsigned int month;
unsigned int day;
localtime_r(&time, &t);
gtk_calendar_get_date(GTK_CALENDAR(widget), &year, &month, &day);
t.tm_year = year - 1900;
t.tm_mon = month;
t.tm_mday = day;
return mktime(&t);
}
static void _task_cursor_changed_date_end(GtkWidget * widget, gpointer data)
{
Task * task = data;
time_t time;
time = task_get_end(task);
time = _task_cursor_changed_date_get(widget, time);
task_set_end(task, time);
task_save(task);
}
static void _task_cursor_changed_date_start(GtkWidget * widget, gpointer data)
{
Task * task = data;
time_t time;
time = task_get_start(task);
time = _task_cursor_changed_date_get(widget, time);
task_set_start(task, time);
task_save(task);
}
/* todo_task_edit */ /* todo_task_edit */
void todo_task_edit(Todo * todo) void todo_task_edit(Todo * todo)
{ {

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Todo */ /* This file is part of DeforaOS Desktop Todo */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -67,6 +67,7 @@ void todo_task_set_priority(Todo * todo, GtkTreePath * path,
char const * priority); char const * priority);
void todo_task_set_title(Todo * todo, GtkTreePath * path, char const * title); void todo_task_set_title(Todo * todo, GtkTreePath * path, char const * title);
void todo_task_cursor_changed(Todo * todo);
void todo_task_edit(Todo * todo); void todo_task_edit(Todo * todo);
int todo_task_reload_all(Todo * todo); int todo_task_reload_all(Todo * todo);
void todo_task_save_all(Todo * todo); void todo_task_save_all(Todo * todo);