From ec532d28e42f4c0fb912bf7442b092e65d273178 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 5 Jan 2001 18:23:51 +0000 Subject: get categories button (init_widgets): listen for button click 2001-01-05 JP Rosevear * 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 svn path=/trunk/; revision=7268 --- calendar/gui/calendar-model.c | 26 ++----------- calendar/gui/dialogs/task-editor-dialog.glade | 8 +--- calendar/gui/dialogs/task-editor-dialog.glade.h | 36 ++++++++++++------ calendar/gui/dialogs/task-editor.c | 49 +++++++++++++++++++++++-- calendar/gui/dialogs/task-page.glade | 8 +--- 5 files changed, 76 insertions(+), 51 deletions(-) (limited to 'calendar/gui') 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 GtkButton button3 True - GTK_RELIEF_NORMAL 0 False @@ -494,7 +493,6 @@ Confidential GtkLabel label16 - False GTK_JUSTIFY_CENTER False @@ -508,7 +506,6 @@ Confidential GtkEntry contacts - False True True True @@ -523,9 +520,8 @@ Confidential GtkButton - button4 + categories-button True - GTK_RELIEF_NORMAL 0 False @@ -535,7 +531,6 @@ Confidential GtkLabel label17 - False GTK_JUSTIFY_CENTER False @@ -549,7 +544,6 @@ Confidential GtkEntry categories - False True True True 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 #include #include +#include #include #include #include @@ -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 GtkButton button3 True - GTK_RELIEF_NORMAL 0 False @@ -494,7 +493,6 @@ Confidential GtkLabel label16 - False GTK_JUSTIFY_CENTER False @@ -508,7 +506,6 @@ Confidential GtkEntry contacts - False True True True @@ -523,9 +520,8 @@ Confidential GtkButton - button4 + categories-button True - GTK_RELIEF_NORMAL 0 False @@ -535,7 +531,6 @@ Confidential GtkLabel label17 - False GTK_JUSTIFY_CENTER False @@ -549,7 +544,6 @@ Confidential GtkEntry categories - False True True True -- cgit v1.2.3