From fa1d50623855f58ed95fba1f468d872a9e84e4d2 Mon Sep 17 00:00:00 2001 From: Russell Steinthal Date: Wed, 26 May 1999 15:25:04 +0000 Subject: Added preliminary support for todo item priorities: they can be set, displayed, and used as a sorting criterion. They are enabled/disabled using the properties page, as with due dates. svn path=/trunk/; revision=947 --- calendar/ChangeLog | 7 +++++ calendar/gncal-todo.c | 65 ++++++++++++++++++++++++++++++++++++++++------- calendar/gui/gncal-todo.c | 65 ++++++++++++++++++++++++++++++++++++++++------- calendar/gui/main.c | 1 + calendar/gui/main.h | 1 + calendar/gui/prop.c | 19 ++++++++++++-- calendar/main.c | 1 + calendar/main.h | 1 + calendar/prop.c | 19 ++++++++++++-- 9 files changed, 157 insertions(+), 22 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index c802b374a9..9fc078f648 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +1999-05-26 Russell Steinthal + + * gncal-todo.c main.c main.h prop.c: Added support for priorities + for todo items. Doesn't do much, but you can set them and sort by + them. (Use the properties box to enable them; should they be on + by default?) + 1999-05-25 Miguel de Icaza * main.c (parse_an_arg): Added missing break here. It was causing diff --git a/calendar/gncal-todo.c b/calendar/gncal-todo.c index 599f85a6c0..05611e14e8 100644 --- a/calendar/gncal-todo.c +++ b/calendar/gncal-todo.c @@ -14,6 +14,7 @@ #include "eventedit.h" int todo_show_due_date = 0; +int todo_show_priority = 0; int todo_due_date_overdue_highlight = 0; char *todo_overdue_font_text; gint todo_current_sort_column = 0; @@ -55,11 +56,14 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) GtkEntry *entry; GnomeDateEdit *due_date; GtkText *comment; + GtkSpinButton *priority; + ico = gtk_object_get_user_data (GTK_OBJECT (dialog)); todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo")); entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry")); due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date")); + priority = GTK_SPIN_BUTTON (gtk_object_get_data(GTK_OBJECT(dialog), "priority")); comment = GTK_TEXT(gtk_object_get_data (GTK_OBJECT(dialog), "comment")); if (ico->summary) g_free (ico->summary); @@ -67,6 +71,7 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) g_free (ico->comment); ico->dtend = gnome_date_edit_get_date (due_date); ico->summary = g_strdup (gtk_entry_get_text (entry)); + ico->priority = gtk_spin_button_get_value_as_int (priority); ico->comment = gtk_editable_get_chars( GTK_EDITABLE(comment), 0, -1); ico->user_data = NULL; @@ -118,7 +123,10 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) GtkWidget *comment_internal_box; GtkWidget *comment_sep; GtkWidget *w; - + GtkWidget *pri_box; + GtkWidget *pri_label; + GtkWidget *pri_spin; + GtkObject *pri_adj; GtkWidget *entry; @@ -138,6 +146,11 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0); gtk_widget_show (due_box); + pri_box = gtk_hbox_new (FALSE, 4); + gtk_container_border_width (GTK_CONTAINER (pri_box), 4); + gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0); + gtk_widget_show (pri_box); + comment_box = gtk_hbox_new (FALSE, 4); gtk_container_border_width (GTK_CONTAINER (comment_box), 4); gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0); @@ -168,7 +181,18 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0); gtk_widget_show (due_entry); - + pri_label = gtk_label_new (_("Priority:")); + gtk_box_pack_start (GTK_BOX (pri_box), pri_label, FALSE, FALSE, 0); + gtk_widget_show (pri_label); + + pri_adj = gtk_adjustment_new (5.0, 1.0, 9.0, 1.0, 3.0, 0.0); + pri_spin = gtk_spin_button_new (GTK_ADJUSTMENT(pri_adj), 0.0, 0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pri_spin), TRUE); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (pri_spin), FALSE); + gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (pri_spin), FALSE); + gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0); + gtk_widget_show (pri_spin); + comment_sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0); gtk_widget_show(comment_sep); @@ -199,8 +223,9 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo); gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry); gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry); + gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin); gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text); - + gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog); gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog); @@ -387,13 +412,15 @@ gncal_todo_init (GncalTodo *todo) GtkWidget *w; GtkWidget *sw; GtkWidget *hbox; - gchar *titles[2] = { + gchar *titles[3] = { N_("Summary"), - N_("Due Date") + N_("Due Date"), + N_("Priority") }; - char *tmp[2]; + char *tmp[3]; tmp[0] = _(titles[0]); tmp[1] = _(titles[1]); + tmp[2] = _(titles[2]); gtk_box_set_spacing (GTK_BOX (todo), 4); @@ -412,7 +439,7 @@ gncal_todo_init (GncalTodo *todo) gtk_widget_show (sw); - w = gtk_clist_new_with_titles(2, tmp); + w = gtk_clist_new_with_titles(3, tmp); todo->clist = GTK_CLIST (w); gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE); @@ -517,7 +544,7 @@ static void insert_in_clist (GncalTodo *todo, iCalObject *ico) { int i; - char *text[2]; + char *text[3]; static GtkStyle *overdue_style = NULL; @@ -546,7 +573,14 @@ insert_in_clist (GncalTodo *todo, iCalObject *ico) else text[1] = NULL; - + if(ico->priority && todo_show_priority) + { + text[2] = g_strdup_printf ("%d", ico->priority); + todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]); + } + else + text[2] = NULL; + i = gtk_clist_append (todo->clist, text); gtk_clist_set_row_data (todo->clist, i, ico); @@ -596,6 +630,11 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags) gtk_clist_set_column_visibility (todo->clist, 1, 1); else gtk_clist_set_column_visibility (todo->clist, 1, 0); + + if(todo_show_priority) + gtk_clist_set_column_visibility (todo->clist, 2, 1); + else + gtk_clist_set_column_visibility (todo->clist, 2, 0); /* free the memory locations that were used in the previous display */ for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){ @@ -621,3 +660,11 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags) gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL)); todo_list_redraw_in_progess = 0; } + + + + + + + + diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c index 599f85a6c0..05611e14e8 100644 --- a/calendar/gui/gncal-todo.c +++ b/calendar/gui/gncal-todo.c @@ -14,6 +14,7 @@ #include "eventedit.h" int todo_show_due_date = 0; +int todo_show_priority = 0; int todo_due_date_overdue_highlight = 0; char *todo_overdue_font_text; gint todo_current_sort_column = 0; @@ -55,11 +56,14 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) GtkEntry *entry; GnomeDateEdit *due_date; GtkText *comment; + GtkSpinButton *priority; + ico = gtk_object_get_user_data (GTK_OBJECT (dialog)); todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo")); entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry")); due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date")); + priority = GTK_SPIN_BUTTON (gtk_object_get_data(GTK_OBJECT(dialog), "priority")); comment = GTK_TEXT(gtk_object_get_data (GTK_OBJECT(dialog), "comment")); if (ico->summary) g_free (ico->summary); @@ -67,6 +71,7 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) g_free (ico->comment); ico->dtend = gnome_date_edit_get_date (due_date); ico->summary = g_strdup (gtk_entry_get_text (entry)); + ico->priority = gtk_spin_button_get_value_as_int (priority); ico->comment = gtk_editable_get_chars( GTK_EDITABLE(comment), 0, -1); ico->user_data = NULL; @@ -118,7 +123,10 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) GtkWidget *comment_internal_box; GtkWidget *comment_sep; GtkWidget *w; - + GtkWidget *pri_box; + GtkWidget *pri_label; + GtkWidget *pri_spin; + GtkObject *pri_adj; GtkWidget *entry; @@ -138,6 +146,11 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0); gtk_widget_show (due_box); + pri_box = gtk_hbox_new (FALSE, 4); + gtk_container_border_width (GTK_CONTAINER (pri_box), 4); + gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0); + gtk_widget_show (pri_box); + comment_box = gtk_hbox_new (FALSE, 4); gtk_container_border_width (GTK_CONTAINER (comment_box), 4); gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0); @@ -168,7 +181,18 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0); gtk_widget_show (due_entry); - + pri_label = gtk_label_new (_("Priority:")); + gtk_box_pack_start (GTK_BOX (pri_box), pri_label, FALSE, FALSE, 0); + gtk_widget_show (pri_label); + + pri_adj = gtk_adjustment_new (5.0, 1.0, 9.0, 1.0, 3.0, 0.0); + pri_spin = gtk_spin_button_new (GTK_ADJUSTMENT(pri_adj), 0.0, 0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pri_spin), TRUE); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (pri_spin), FALSE); + gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (pri_spin), FALSE); + gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0); + gtk_widget_show (pri_spin); + comment_sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0); gtk_widget_show(comment_sep); @@ -199,8 +223,9 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico) gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo); gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry); gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry); + gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin); gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text); - + gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog); gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog); @@ -387,13 +412,15 @@ gncal_todo_init (GncalTodo *todo) GtkWidget *w; GtkWidget *sw; GtkWidget *hbox; - gchar *titles[2] = { + gchar *titles[3] = { N_("Summary"), - N_("Due Date") + N_("Due Date"), + N_("Priority") }; - char *tmp[2]; + char *tmp[3]; tmp[0] = _(titles[0]); tmp[1] = _(titles[1]); + tmp[2] = _(titles[2]); gtk_box_set_spacing (GTK_BOX (todo), 4); @@ -412,7 +439,7 @@ gncal_todo_init (GncalTodo *todo) gtk_widget_show (sw); - w = gtk_clist_new_with_titles(2, tmp); + w = gtk_clist_new_with_titles(3, tmp); todo->clist = GTK_CLIST (w); gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE); @@ -517,7 +544,7 @@ static void insert_in_clist (GncalTodo *todo, iCalObject *ico) { int i; - char *text[2]; + char *text[3]; static GtkStyle *overdue_style = NULL; @@ -546,7 +573,14 @@ insert_in_clist (GncalTodo *todo, iCalObject *ico) else text[1] = NULL; - + if(ico->priority && todo_show_priority) + { + text[2] = g_strdup_printf ("%d", ico->priority); + todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]); + } + else + text[2] = NULL; + i = gtk_clist_append (todo->clist, text); gtk_clist_set_row_data (todo->clist, i, ico); @@ -596,6 +630,11 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags) gtk_clist_set_column_visibility (todo->clist, 1, 1); else gtk_clist_set_column_visibility (todo->clist, 1, 0); + + if(todo_show_priority) + gtk_clist_set_column_visibility (todo->clist, 2, 1); + else + gtk_clist_set_column_visibility (todo->clist, 2, 0); /* free the memory locations that were used in the previous display */ for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){ @@ -621,3 +660,11 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags) gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL)); todo_list_redraw_in_progess = 0; } + + + + + + + + diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 770608743a..dd26a87c87 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -148,6 +148,7 @@ init_calendar (void) todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type"); + todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority"); /* Done */ diff --git a/calendar/gui/main.h b/calendar/gui/main.h index 845fae6f35..96ffcaf33d 100644 --- a/calendar/gui/main.h +++ b/calendar/gui/main.h @@ -37,6 +37,7 @@ extern struct color_prop color_props[]; /* todo preferences */ extern int todo_show_due_date; extern int todo_due_date_overdue_highlight; +extern int todo_show_priority; extern char *todo_overdue_font_text; extern struct color_prop todo_overdue_highlight_color; extern gboolean todo_style_changed; diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c index ee97c58514..ca07252807 100644 --- a/calendar/gui/prop.c +++ b/calendar/gui/prop.c @@ -45,6 +45,8 @@ static GnomeCanvasItem *month_item; /* Widgets for the todo page */ static GtkWidget *due_date_show_button; static GtkWidget *due_date_overdue_highlight; +static GtkWidget *priority_show_button; + /* Callback used when the property box is closed -- just sets the prop_win variable to null. */ static int prop_cancel (void) @@ -115,11 +117,13 @@ prop_apply_todo(void) { todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active; todo_due_date_overdue_highlight = GTK_TOGGLE_BUTTON (due_date_overdue_highlight)->active; - + + todo_show_priority = GTK_TOGGLE_BUTTON (priority_show_button)->active; + /* storing the values */ gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date); gnome_config_set_bool("/calendar/Todo/highlight_overdue_tasks", todo_due_date_overdue_highlight); - + gnome_config_set_bool("/calendar/Todo/show_priority", todo_show_priority); /* need to sync our config changes. */ gnome_config_sync (); @@ -565,6 +569,7 @@ build_list_options_frame(void) due_date_show_button = gtk_check_button_new_with_label (_("Summary")); due_date_show_button = gtk_check_button_new_with_label (_("Due Date")); + priority_show_button = gtk_check_button_new_with_label (_("Priority")); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date); gtk_signal_connect (GTK_OBJECT(due_date_show_button), @@ -572,6 +577,13 @@ build_list_options_frame(void) (GtkSignalFunc) todo_option_set, NULL); gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0); + + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(priority_show_button), todo_show_priority); + gtk_signal_connect (GTK_OBJECT(priority_show_button), + "clicked", + (GtkSignalFunc) todo_option_set, + NULL); + gtk_box_pack_start (GTK_BOX (vbox), priority_show_button, FALSE, FALSE, 0); return frame; } static GtkWidget * @@ -689,3 +701,6 @@ color_spec_from_prop (ColorProp propnum) { return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b); } + + + diff --git a/calendar/main.c b/calendar/main.c index 770608743a..dd26a87c87 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -148,6 +148,7 @@ init_calendar (void) todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type"); + todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority"); /* Done */ diff --git a/calendar/main.h b/calendar/main.h index 845fae6f35..96ffcaf33d 100644 --- a/calendar/main.h +++ b/calendar/main.h @@ -37,6 +37,7 @@ extern struct color_prop color_props[]; /* todo preferences */ extern int todo_show_due_date; extern int todo_due_date_overdue_highlight; +extern int todo_show_priority; extern char *todo_overdue_font_text; extern struct color_prop todo_overdue_highlight_color; extern gboolean todo_style_changed; diff --git a/calendar/prop.c b/calendar/prop.c index ee97c58514..ca07252807 100644 --- a/calendar/prop.c +++ b/calendar/prop.c @@ -45,6 +45,8 @@ static GnomeCanvasItem *month_item; /* Widgets for the todo page */ static GtkWidget *due_date_show_button; static GtkWidget *due_date_overdue_highlight; +static GtkWidget *priority_show_button; + /* Callback used when the property box is closed -- just sets the prop_win variable to null. */ static int prop_cancel (void) @@ -115,11 +117,13 @@ prop_apply_todo(void) { todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active; todo_due_date_overdue_highlight = GTK_TOGGLE_BUTTON (due_date_overdue_highlight)->active; - + + todo_show_priority = GTK_TOGGLE_BUTTON (priority_show_button)->active; + /* storing the values */ gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date); gnome_config_set_bool("/calendar/Todo/highlight_overdue_tasks", todo_due_date_overdue_highlight); - + gnome_config_set_bool("/calendar/Todo/show_priority", todo_show_priority); /* need to sync our config changes. */ gnome_config_sync (); @@ -565,6 +569,7 @@ build_list_options_frame(void) due_date_show_button = gtk_check_button_new_with_label (_("Summary")); due_date_show_button = gtk_check_button_new_with_label (_("Due Date")); + priority_show_button = gtk_check_button_new_with_label (_("Priority")); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date); gtk_signal_connect (GTK_OBJECT(due_date_show_button), @@ -572,6 +577,13 @@ build_list_options_frame(void) (GtkSignalFunc) todo_option_set, NULL); gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0); + + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(priority_show_button), todo_show_priority); + gtk_signal_connect (GTK_OBJECT(priority_show_button), + "clicked", + (GtkSignalFunc) todo_option_set, + NULL); + gtk_box_pack_start (GTK_BOX (vbox), priority_show_button, FALSE, FALSE, 0); return frame; } static GtkWidget * @@ -689,3 +701,6 @@ color_spec_from_prop (ColorProp propnum) { return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b); } + + + -- cgit v1.2.3