aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog24
-rw-r--r--calendar/cal-util/cal-component.c121
-rw-r--r--calendar/cal-util/cal-component.h2
-rw-r--r--calendar/gui/calendar-model.c26
-rw-r--r--calendar/gui/dialogs/task-editor-dialog.glade8
-rw-r--r--calendar/gui/dialogs/task-editor-dialog.glade.h36
-rw-r--r--calendar/gui/dialogs/task-editor.c49
-rw-r--r--calendar/gui/dialogs/task-page.glade8
8 files changed, 175 insertions, 99 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index a967f32527..4e5aa6c068 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,27 @@
+2001-01-05 JP Rosevear <jpr@helixcode.com>
+
+ * gui/dialogs/task-editor.c (get_widgets): get categories button
+ (init_widgets): listen for button click
+ (fill_widgets): fill in the categories area
+ (dialog_to_comp_object): set the cal component categories
+ (categories_clicked): throw up the categories dialog and update
+ when ok is clicked
+
+ * gui/dialogs/task-editor-dialog.glade: Tweak to name the categories
+ button and make it active
+
+ * gui/calendar-model.c (get_categories): We can get the string list of
+ categories directly now
+
+ * cal-util/cal-component.c (cal_component_get_categories): new function
+ to get the categories list as a string
+ (cal_component_set_categories): same but for setting
+ (free_icalcomponent): init the categories var
+ (scan_categories): kill
+ (scan_property): assign the prop to the categories var
+ (cal_component_get_categories_list): deal with renaming var to categories
+ (cal_component_set_categories_list): fix brokeness
+
2001-01-03 Federico Mena Quintero <federico@helixcode.com>
* gui/calendar-commands.c (new_calendar): Handle the case where
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 0c7ca50d9f..ef0c491870 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -42,10 +42,7 @@ struct _CalComponentPrivate {
icalproperty *status;
- struct categories {
- icalproperty *prop;
- };
- GSList *categories_list; /* list of struct categories */
+ icalproperty *categories;
icalproperty *classification;
@@ -244,7 +241,7 @@ free_icalcomponent (CalComponent *comp)
priv->status = NULL;
- priv->categories_list = free_slist (priv->categories_list);
+ priv->categories = NULL;
priv->classification = NULL;
priv->comment_list = NULL;
@@ -405,21 +402,6 @@ cal_component_clone (CalComponent *comp)
return new_comp;
}
-/* Scans the categories property */
-static void
-scan_categories (CalComponent *comp, icalproperty *prop)
-{
- CalComponentPrivate *priv;
- struct categories *categ;
-
- priv = comp->priv;
-
- categ = g_new (struct categories, 1);
- categ->prop = prop;
-
- priv->categories_list = g_slist_append (priv->categories_list, categ);
-}
-
/* Scans a date/time and timezone pair property */
static void
scan_datetime (CalComponent *comp, struct datetime *datetime, icalproperty *prop)
@@ -510,7 +492,7 @@ scan_property (CalComponent *comp, icalproperty *prop)
break;
case ICAL_CATEGORIES_PROPERTY:
- scan_categories (comp, prop);
+ priv->categories = prop;
break;
case ICAL_CLASS_PROPERTY:
@@ -1130,6 +1112,68 @@ cal_component_set_uid (CalComponent *comp, const char *uid)
}
/**
+ * cal_component_get_categories:
+ * @comp: A calendar component object.
+ * @categories:
+ *
+ *
+ **/
+void
+cal_component_get_categories (CalComponent *comp, const char **categories)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (categories != NULL);
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (priv->categories)
+ *categories = icalproperty_get_categories (priv->categories);
+ else
+ *categories = NULL;
+}
+
+/**
+ * cal_component_set_categories:
+ * @comp: A calendar component object.
+ * @categories:
+ *
+ *
+ **/
+void
+cal_component_set_categories (CalComponent *comp, const char *categories)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (!categories) {
+ if (priv->categories) {
+ icalcomponent_remove_property (priv->icalcomp, priv->categories);
+ icalproperty_free (priv->categories);
+ priv->url = NULL;
+ }
+
+ return;
+ }
+
+ if (priv->categories)
+ icalproperty_set_categories (priv->categories, (char *) categories);
+ else {
+ priv->categories = icalproperty_new_categories ((char *) categories);
+ icalcomponent_add_property (priv->icalcomp, priv->categories);
+ }
+}
+
+
+/**
* cal_component_get_categories_list:
* @comp: A calendar component object.
* @categ_list: Return value for the list of strings, where each string is a
@@ -1154,16 +1198,15 @@ cal_component_get_categories_list (CalComponent *comp, GSList **categ_list)
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
- if (!priv->categories_list) {
+ if (!priv->categories) {
*categ_list = NULL;
return;
}
- categories = icalproperty_get_categories (priv->categories_list);
+ categories = icalproperty_get_categories (priv->categories);
g_assert (categories != NULL);
cat_start = categories;
-
*categ_list = NULL;
for (p = categories; *p; p++)
@@ -1214,7 +1257,6 @@ void
cal_component_set_categories_list (CalComponent *comp, GSList *categ_list)
{
CalComponentPrivate *priv;
- struct categories *cat;
char *categories_str;
g_return_if_fail (comp != NULL);
@@ -1223,40 +1265,23 @@ cal_component_set_categories_list (CalComponent *comp, GSList *categ_list)
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
- /* Free the old list */
-
if (!categ_list) {
- if (priv->categories_list) {
- GSList *l;
-
- for (l = priv->categories_list; l; l = l->next) {
- struct categories *c;
-
- c = l->data;
- icalcomponent_remove_property (priv->icalcomp, c->prop);
- icalproperty_free (c->prop);
-
- g_free (c);
- }
-
- g_slist_free (priv->categories_list);
- priv->categories_list = NULL;
+ if (priv->categories) {
+ icalcomponent_remove_property (priv->icalcomp, priv->categories);
+ icalproperty_free (priv->categories);
}
-
+
return;
}
/* Create a single string of categories */
-
categories_str = stringify_categories (categ_list);
/* Set the categories */
-
- cat = g_new (struct categories, 1);
- cat->prop = icalproperty_new_categories (categories_str);
+ priv->categories = icalproperty_new_categories (categories_str);
g_free (categories_str);
- icalcomponent_add_property (priv->icalcomp, cat->prop);
+ icalcomponent_add_property (priv->icalcomp, priv->categories);
}
/**
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 5d649fb7ca..8887e1b86b 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -173,6 +173,8 @@ void cal_component_commit_sequence (CalComponent *comp);
void cal_component_get_uid (CalComponent *comp, const char **uid);
void cal_component_set_uid (CalComponent *comp, const char *uid);
+void cal_component_get_categories (CalComponent *comp, const char **categories);
+void cal_component_set_categories (CalComponent *comp, const char *categories);
void cal_component_get_categories_list (CalComponent *comp, GSList **categ_list);
void cal_component_set_categories_list (CalComponent *comp, GSList *categ_list);
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 55f265390c..7168f2714b 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -303,31 +303,11 @@ get_time_t (CalendarModel *model, time_t *t, gboolean skip_midnight)
static char *
get_categories (CalComponent *comp)
{
- GSList *categories;
- GString *str;
- char *s;
- GSList *l;
-
- cal_component_get_categories_list (comp, &categories);
-
- str = g_string_new (NULL);
-
- for (l = categories; l; l = l->next) {
- const char *category;
-
- category = l->data;
- g_string_append (str, category);
-
- if (l->next != NULL)
- g_string_append (str, ", ");
- }
-
- s = str->str;
+ const char *categories;
- g_string_free (str, FALSE);
- cal_component_free_categories_list (categories);
+ cal_component_get_categories (comp, &categories);
- return s;
+ return g_strdup (categories);
}
/* Returns a string based on the CLASSIFICATION property of a calendar component */
diff --git a/calendar/gui/dialogs/task-editor-dialog.glade b/calendar/gui/dialogs/task-editor-dialog.glade
index bdde9ed091..e205b4c10d 100644
--- a/calendar/gui/dialogs/task-editor-dialog.glade
+++ b/calendar/gui/dialogs/task-editor-dialog.glade
@@ -484,7 +484,6 @@ Confidential
<class>GtkButton</class>
<name>button3</name>
<can_focus>True</can_focus>
- <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
@@ -494,7 +493,6 @@ Confidential
<widget>
<class>GtkLabel</class>
<name>label16</name>
- <sensitive>False</sensitive>
<label>_Contacts...</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@@ -508,7 +506,6 @@ Confidential
<widget>
<class>GtkEntry</class>
<name>contacts</name>
- <sensitive>False</sensitive>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
@@ -523,9 +520,8 @@ Confidential
<widget>
<class>GtkButton</class>
- <name>button4</name>
+ <name>categories-button</name>
<can_focus>True</can_focus>
- <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
@@ -535,7 +531,6 @@ Confidential
<widget>
<class>GtkLabel</class>
<name>label17</name>
- <sensitive>False</sensitive>
<label>Ca_tegories...</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@@ -549,7 +544,6 @@ Confidential
<widget>
<class>GtkEntry</class>
<name>categories</name>
- <sensitive>False</sensitive>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
diff --git a/calendar/gui/dialogs/task-editor-dialog.glade.h b/calendar/gui/dialogs/task-editor-dialog.glade.h
index 5aa32dd38b..20f7db3014 100644
--- a/calendar/gui/dialogs/task-editor-dialog.glade.h
+++ b/calendar/gui/dialogs/task-editor-dialog.glade.h
@@ -1,20 +1,34 @@
/*
- * Translatable strings file generated by extract-ui.
- * Add this file to your project's POTFILES.in
+ * Translatable strings file generated by Glade.
+ * Add this file to your project's POTFILES.in.
* DO NOT compile it as part of your application.
*/
+gchar *s = N_("task-editor-dialog");
+gchar *s = N_("S_ummary");
+gchar *s = N_("Sta_rt Date:");
+gchar *s = N_("_Due Date:");
gchar *s = N_("% Comp_lete:");
+gchar *s = N_("_Status:");
+gchar *s = N_("Not Started\n"
+ "In Progress\n"
+ "Completed\n"
+ "Cancelled\n"
+ "");
+gchar *s = N_("_Priority:");
+gchar *s = N_("High\n"
+ "Normal\n"
+ "Low\n"
+ "");
gchar *s = N_("C_lassification:");
+gchar *s = N_("None\n"
+ "Public\n"
+ "Private\n"
+ "Confidential\n"
+ "");
+gchar *s = N_("_Contacts...");
gchar *s = N_("Ca_tegories...");
-gchar *s = N_("Date Completed:");
-gchar *s = N_("Details");
-gchar *s = N_("S_ummary");
-gchar *s = N_("Sta_rt Date:");
gchar *s = N_("Task");
+gchar *s = N_("Date Completed:");
gchar *s = N_("URL:");
-gchar *s = N_("_Contacts...");
-gchar *s = N_("_Due Date:");
-gchar *s = N_("_Priority:");
-gchar *s = N_("_Status:");
-gchar *s = N_("task-editor-dialog");
+gchar *s = N_("Details");
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c
index ceac6c933d..288244802e 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -32,6 +32,7 @@
#include <glade/glade.h>
#include <gal/util/e-util.h>
#include <gal/widgets/e-unicode.h>
+#include <gal/widgets/e-categories.h>
#include <e-util/e-dialog-widgets.h>
#include <widgets/misc/e-dateedit.h>
#include <cal-util/timeutil.h>
@@ -79,6 +80,7 @@ typedef struct {
GtkWidget *description;
GtkWidget *contacts;
+ GtkWidget *categories_btn;
GtkWidget *categories;
GtkWidget *completed_date;
@@ -166,6 +168,8 @@ static void field_changed (GtkWidget *widget,
static void task_editor_set_changed (TaskEditor *tedit,
gboolean changed);
static gboolean prompt_to_save_changes (TaskEditor *tedit);
+static void categories_clicked (GtkWidget *button,
+ TaskEditor *editor);
/* The function libglade calls to create the EDateEdit widgets in the GUI. */
GtkWidget * task_editor_create_date_edit (void);
@@ -396,6 +400,7 @@ get_widgets (TaskEditor *tedit)
priv->description = GW ("description");
priv->contacts = GW ("contacts");
+ priv->categories_btn = GW ("categories-button");
priv->categories = GW ("categories");
priv->completed_date = GW ("completed-date");
@@ -413,6 +418,7 @@ get_widgets (TaskEditor *tedit)
&& priv->classification
&& priv->description
&& priv->contacts
+ && priv->categories_btn
&& priv->categories
&& priv->completed_date
&& priv->url);
@@ -464,6 +470,9 @@ init_widgets (TaskEditor *tedit)
gtk_signal_connect (GTK_OBJECT (priv->url), "changed",
GTK_SIGNAL_FUNC (field_changed), tedit);
+ /* Button clicks */
+ gtk_signal_connect (GTK_OBJECT (priv->categories_btn), "clicked",
+ GTK_SIGNAL_FUNC (categories_clicked), tedit);
}
static void
@@ -752,7 +761,8 @@ fill_widgets (TaskEditor *tedit)
icalproperty_status status;
TaskEditorPriority priority;
const char *url;
-
+ const char *categories;
+
priv = tedit->priv;
task_editor_set_changed (tedit, FALSE);
@@ -848,6 +858,9 @@ fill_widgets (TaskEditor *tedit)
e_dialog_option_menu_set (priv->classification, classification,
classification_map);
+ /* Categories */
+ cal_component_get_categories (priv->comp, &categories);
+ e_dialog_editable_set (priv->categories, categories);
/* URL. */
cal_component_get_url (priv->comp, &url);
@@ -891,7 +904,7 @@ dialog_to_comp_object (TaskEditor *tedit)
TaskEditorPriority priority;
int priority_value, percent;
CalComponentClassification classification;
- char *url;
+ char *url, *cat;
char *str;
priv = tedit->priv;
@@ -986,6 +999,12 @@ dialog_to_comp_object (TaskEditor *tedit)
classification_map);
cal_component_set_classification (comp, classification);
+ /* Categories */
+ cat = e_dialog_editable_get (priv->categories);
+ cal_component_set_categories (comp, cat);
+
+ if (cat)
+ g_free (cat);
/* URL. */
url = e_dialog_editable_get (priv->url);
@@ -994,7 +1013,6 @@ dialog_to_comp_object (TaskEditor *tedit)
if (url)
g_free (url);
-
cal_component_commit_sequence (comp);
}
@@ -1297,3 +1315,28 @@ prompt_to_save_changes (TaskEditor *tedit)
}
}
+
+static void
+categories_clicked(GtkWidget *button, TaskEditor *tedit)
+{
+ char *categories;
+ GnomeDialog *dialog;
+ int result;
+ GtkWidget *entry;
+
+ entry = ((TaskEditorPrivate *)tedit->priv)->categories;
+ categories = e_utf8_gtk_entry_get_text (GTK_ENTRY (entry));
+
+ dialog = GNOME_DIALOG (e_categories_new (categories));
+ result = gnome_dialog_run (dialog);
+ g_free (categories);
+
+ if (result == 0) {
+ gtk_object_get (GTK_OBJECT (dialog),
+ "categories", &categories,
+ NULL);
+ e_utf8_gtk_entry_set_text (GTK_ENTRY (entry), categories);
+ g_free (categories);
+ }
+ gtk_object_destroy (GTK_OBJECT (dialog));
+}
diff --git a/calendar/gui/dialogs/task-page.glade b/calendar/gui/dialogs/task-page.glade
index bdde9ed091..e205b4c10d 100644
--- a/calendar/gui/dialogs/task-page.glade
+++ b/calendar/gui/dialogs/task-page.glade
@@ -484,7 +484,6 @@ Confidential
<class>GtkButton</class>
<name>button3</name>
<can_focus>True</can_focus>
- <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
@@ -494,7 +493,6 @@ Confidential
<widget>
<class>GtkLabel</class>
<name>label16</name>
- <sensitive>False</sensitive>
<label>_Contacts...</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@@ -508,7 +506,6 @@ Confidential
<widget>
<class>GtkEntry</class>
<name>contacts</name>
- <sensitive>False</sensitive>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
@@ -523,9 +520,8 @@ Confidential
<widget>
<class>GtkButton</class>
- <name>button4</name>
+ <name>categories-button</name>
<can_focus>True</can_focus>
- <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
@@ -535,7 +531,6 @@ Confidential
<widget>
<class>GtkLabel</class>
<name>label17</name>
- <sensitive>False</sensitive>
<label>Ca_tegories...</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@@ -549,7 +544,6 @@ Confidential
<widget>
<class>GtkEntry</class>
<name>categories</name>
- <sensitive>False</sensitive>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>