From a0afdf4f53224a55425a8826c0563faa510fa6c5 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Sun, 1 Jul 2001 04:59:24 +0000 Subject: Fixes bug #1406. 2001-06-30 Federico Mena Quintero Fixes bug #1406. * gui/calendar-config.c (config_read): Handle the options for the task list colors. (calendar_config_write): Ditto. (calendar_config_get_tasks_due_today_color): New function. (calendar_config_set_tasks_due_today_color): New function. (calendar_config_get_tasks_overdue_color): New function. (calendar_config_set_tasks_overdue_color): New function. (calendar_config_configure_e_calendar_table): Use e_table_model_changed() for the colors. * gui/dialogs/cal-prefs-dialog.glade: Updated the options for the task list and alarms. * gui/dialogs/cal-prefs-dialog.c (cal_prefs_dialog_show_config): Update the task list settings. (cal_prefs_dialog_update_config): Ditto. * gui/calendar-model.c (get_color): Deal with tasks for today as well as overdue tasks. Make it cleaner, even though we have to duplicate a chunk of is_overdue(). * gui/calendar-commands.c (preferences_cmd): Renamed from properties_cmd(). svn path=/trunk/; revision=10648 --- calendar/gui/dialogs/cal-prefs-dialog.c | 72 +++++ calendar/gui/dialogs/cal-prefs-dialog.glade | 465 +++------------------------- 2 files changed, 119 insertions(+), 418 deletions(-) (limited to 'calendar/gui/dialogs') diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 3451f6e4a5..de3cbf2483 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -29,6 +29,7 @@ */ #include +#include #include #include #include @@ -57,6 +58,10 @@ struct _CalPrefsDialogPrivate { GtkWidget *show_end_times; GtkWidget *compress_weekend; GtkWidget *dnav_show_week_no; + + /* Widgets for the task list options */ + GtkWidget *tasks_due_today_color; + GtkWidget *tasks_overdue_color; }; static const int week_start_day_map[] = { @@ -209,6 +214,9 @@ get_widgets (CalPrefsDialog *prefs) priv->compress_weekend = GW ("compress_weekend"); priv->dnav_show_week_no = GW ("dnav_show_week_no"); + priv->tasks_due_today_color = GW ("tasks_due_today_color"); + priv->tasks_overdue_color = GW ("tasks_overdue_color"); + #undef GW return (priv->dialog @@ -343,6 +351,37 @@ cal_prefs_dialog_use_24_hour_toggled (GtkWidget *button, use_24_hour); } +/* Sets the color in a color picker from an X color spec */ +static void +set_color_picker (GtkWidget *picker, const char *spec) +{ + GdkColor color; + + g_assert (spec != NULL); + + if (!gdk_color_parse (spec, &color)) { + color.red = color.green = color.blue = 0; + return; + } + + gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (picker), + color.red, + color.green, + color.blue, + 65535); +} + +/* Shows the current task list settings in the dialog */ +static void +show_task_list_config (CalPrefsDialog *prefs) +{ + CalPrefsDialogPrivate *priv; + + priv = prefs->priv; + + set_color_picker (priv->tasks_due_today_color, calendar_config_get_tasks_due_today_color ()); + set_color_picker (priv->tasks_overdue_color, calendar_config_get_tasks_overdue_color ()); +} /* Shows the current config settings in the dialog. */ static void @@ -403,8 +442,38 @@ cal_prefs_dialog_show_config (CalPrefsDialog *prefs) /* Date Navigator - Show Week Numbers. */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->dnav_show_week_no), calendar_config_get_dnav_show_week_no ()); + + /* Task list */ + + show_task_list_config (prefs); +} + +/* Returns a pointer to a static string with an X color spec for the current + * value of a color picker. + */ +static const char * +spec_from_picker (GtkWidget *picker) +{ + static char spec[8]; + guint8 r, g, b; + + gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (picker), &r, &g, &b, NULL); + g_snprintf (spec, sizeof (spec), "#%02x%02x%02x", r, g, b); + + return spec; } +/* Updates the task list config values from the settings in the dialog */ +static void +update_task_list_config (CalPrefsDialog *prefs) +{ + CalPrefsDialogPrivate *priv; + + priv = prefs->priv; + + calendar_config_set_tasks_due_today_color (spec_from_picker (priv->tasks_due_today_color)); + calendar_config_set_tasks_overdue_color (spec_from_picker (priv->tasks_overdue_color)); +} /* Updates the config values based on the settings in the dialog. */ static void @@ -465,6 +534,9 @@ cal_prefs_dialog_update_config (CalPrefsDialog *prefs) /* Date Navigator - Show Week Numbers. */ calendar_config_set_dnav_show_week_no (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->dnav_show_week_no))); + /* Task list */ + update_task_list_config (prefs); + calendar_config_write (); update_all_config_settings (); e_tasks_update_all_config_settings (); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index bf45b072ce..038d091a72 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -256,7 +256,7 @@ GtkFrame frame9 - + 0 GTK_SHADOW_ETCHED_IN @@ -506,10 +506,6 @@ Sunday - - - Placeholder - @@ -535,7 +531,7 @@ Sunday GtkFrame frame10 - + 0 GTK_SHADOW_ETCHED_IN @@ -667,7 +663,7 @@ Sunday GtkFrame frame11 - + 0 GTK_SHADOW_ETCHED_IN @@ -708,176 +704,41 @@ Sunday False 4 - - GtkHBox - hbox4 - False - 0 - - 0 - True - True - - - - GtkFrame - frame3 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox4 - 4 - False - 0 - - - GtkCheckButton - checkbutton1 - True - - True - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton2 - True - - True - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton3 - True - - True - True - - 0 - False - False - - - - - - - GtkFrame - frame4 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox5 - 4 - False - 0 - - - GtkCheckButton - checkbutton4 - True - - False - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton5 - True - - False - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton6 - True - - False - True - - 0 - False - False - - - - - - GtkFrame - frame5 - + frame13 + 0 GTK_SHADOW_ETCHED_IN 0 - True - True + False + False GtkTable - table3 + table6 4 - 3 + 2 2 False 4 4 - GnomeColorPicker - colorpicker1 - True - True - False - Pick a color + GtkLabel + label23 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 - 1 - 2 + 0 + 1 0 1 0 @@ -886,21 +747,24 @@ Sunday False False False - False + True False - GnomeColorPicker - colorpicker2 - True - True - False - Pick a color + GtkLabel + label24 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 - 1 - 2 + 0 + 1 1 2 0 @@ -909,44 +773,21 @@ Sunday False False False - False + True False GnomeColorPicker - colorpicker3 + tasks_due_today_color True True False - Pick a color + Color for tasks due today 1 2 - 2 - 3 - 0 - 0 - False - False - False - False - False - False - - - - - GtkAlignment - alignment1 - 1 - 0.5 - 1 - 1 - - 0 - 1 0 1 0 @@ -956,32 +797,20 @@ Sunday False False True - True + False - - - GtkLabel - label8 - - GTK_JUSTIFY_RIGHT - False - 1 - 0.5 - 0 - 0 - - GtkAlignment - alignment2 - 1 - 0.5 - 1 - 1 + GnomeColorPicker + tasks_overdue_color + True + True + False + Color for overdue tasks - 0 - 1 + 1 + 2 1 2 0 @@ -991,55 +820,8 @@ Sunday False False True - True - - - - GtkLabel - label9 - - GTK_JUSTIFY_RIGHT - True - 1 - 0.5 - 0 - 0 - - - - - GtkAlignment - alignment3 - 1 - 0.5 - 1 - 1 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True + False - - - GtkLabel - label10 - - GTK_JUSTIFY_RIGHT - False - 1 - 0.5 - 0 - 0 - @@ -1049,7 +831,7 @@ Sunday GtkLabel Notebook:tab label11 - + GTK_JUSTIFY_CENTER False 0.5 @@ -1144,7 +926,7 @@ Sunday GtkFrame frame7 - + 0 GTK_SHADOW_ETCHED_IN @@ -1163,159 +945,6 @@ Sunday True - - - GtkFrame - frame8 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkVBox - vbox7 - 4 - False - 4 - - - GtkHBox - hbox6 - False - 0 - - 0 - False - True - - - - GtkCheckButton - checkbutton9 - True - - False - True - - 0 - False - False - - - - - GtkSpinButton - spinbutton2 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 5 - 0 - 100 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkLabel - label13 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - - GtkHBox - hbox7 - False - 0 - - 0 - True - True - - - - GtkCheckButton - checkbutton10 - True - - False - True - - 0 - False - False - - - - - GtkSpinButton - spinbutton3 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 600 - 0 - 1000 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkLabel - label14 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - -- cgit