diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-13 12:55:04 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-13 12:55:04 +0800 |
commit | d5ba94f758a5206dc7cd5b0cd222bb2c3d348ebe (patch) | |
tree | f0ed1da36d11d0d6a12183a9f8f13bb3434e94d0 /calendar/gui/dialogs | |
parent | 9a3b0141daad42713cdeae13ffb0d2e8af786540 (diff) | |
download | gsoc2013-evolution-d5ba94f758a5206dc7cd5b0cd222bb2c3d348ebe.tar.gz gsoc2013-evolution-d5ba94f758a5206dc7cd5b0cd222bb2c3d348ebe.tar.zst gsoc2013-evolution-d5ba94f758a5206dc7cd5b0cd222bb2c3d348ebe.zip |
Add <visible>False</visible> to cal-prefs-dialog so it doesn't get shown
* gui/dialogs/cal-prefs-dialog.glade: Add <visible>False</visible>
to cal-prefs-dialog so it doesn't get shown when we load the Glade
file with libglade.
* gui/component-factory.c (owner_set_cb): Register the
ConfigControl factory.
* gui/tasks-control.c: Removed verb "TaskSettings".
(tasks_control_settings_cmd): Removed.
* gui/calendar-commands.c: Removed verb "CalendarSettings".
(settings_cmd): Removed.
* gui/dialogs/cal-prefs-dialog.c: Renamed `CalPrefsDialogPrivate'
to `DialogData'. Replace `dialog' member with a `page' member.
Remove `toplevel_notebook' member.
(init_widgets): Renamed from `cal_prefs_dialog_init_widgets'.
Just get a DialogData.
(get_widgets): Get a DialogData pointer.
(cal_prefs_dialog_destroy): Removed.
(config_control_destroy_callback): New, signal handler for
::destroy for ConfigControl.
(cal_prefs_dialog_new): Create a new DialogData, connect all the
signal handlers.
(create_time_edit): Renamed from
`cal_prefs_dialog_create_time_edit'.
(cal_prefs_dialog_show): Removed.
(cal_prefs_dialog_button_clicked): Removed.
(show_task_list_config): Get a DialogData.
(show_config): Renamed from `cal_prefs_dialog_show_config'.
Likewise.
(update_task_list_config): Likewise.
(update_config): Renamed from
`cal_prefs_dialog_update_config'. Likewise.
(color_set_callback): New callback, makes the dialog report
changes when the setting in any of the color widgets is changed.
(widget_changed_callback): New callback, makes the dialog report
changes when any of the widgets changes status.
(connect_changed): New utility function to connect this callback
to all the widgets.
(setup_widgets): Connect all the widgets.
(cal_prefs_dialog_new): Call `setup_widgets'.
* gui/config-control-factory.c: New.
* gui/config-control-factory.h: New.
* gui/GNOME_Evolution_Calendar.oaf.in: Add
OAFIID:GNOME_Evolution_Calendar_ConfigControl and
OAFIID:GNOME_Evolution_Calendar_ConfigControlFactory.
svn path=/trunk/; revision=16135
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.c | 586 | ||||
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.glade | 1 | ||||
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.h | 41 |
3 files changed, 267 insertions, 361 deletions
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index fc8d7b0c91..2e61fc0bd5 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -1,11 +1,11 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Author : + * Authors : * Damon Chaplin <damon@ximian.com> + * Ettore Perazzoli <ettore@ximian.com> * - * Copyright 2000, Ximian, Inc. - * Copyright 2000, Ximian, Inc. + * Copyright 2000, 2001, 2002 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -27,26 +27,28 @@ * to edit the calendar preference settings. */ +#ifdef HAVE_CONFIG_H #include <config.h> -#include <libgnomeui/gnome-color-picker.h> -#include <glade/glade.h> -#include <gal/util/e-util.h> -#include <e-util/e-dialog-widgets.h> -#include <widgets/misc/e-dateedit.h> +#endif + #include "../e-timezone-entry.h" #include "cal-prefs-dialog.h" #include "../calendar-config.h" #include "../calendar-commands.h" #include "../e-tasks.h" +#include <libgnomeui/gnome-color-picker.h> +#include <glade/glade.h> +#include <gal/util/e-util.h> +#include <e-util/e-dialog-widgets.h> +#include <widgets/misc/e-dateedit.h> + -struct _CalPrefsDialogPrivate { +struct _DialogData { /* Glade XML data */ GladeXML *xml; - GtkWidget *dialog; - - GtkWidget *toplevel_notebook; + GtkWidget *page; GtkWidget *timezone; GtkWidget *working_days[7]; @@ -74,6 +76,7 @@ struct _CalPrefsDialogPrivate { GtkWidget *default_reminder_interval; GtkWidget *default_reminder_units; }; +typedef struct _DialogData DialogData; static const int week_start_day_map[] = { 1, 2, 3, 4, 5, 6, 0, -1 @@ -93,217 +96,242 @@ static const int default_reminder_units_map[] = { }; -static void cal_prefs_dialog_class_init (CalPrefsDialogClass *class); -static void cal_prefs_dialog_init (CalPrefsDialog *prefs); -static gboolean get_widgets (CalPrefsDialog *prefs); -static void cal_prefs_dialog_destroy (GtkObject *object); -static void cal_prefs_dialog_init_widgets (CalPrefsDialog *prefs); -static void cal_prefs_dialog_button_clicked (GtkWidget *dialog, - gint button, - CalPrefsDialog *prefs); -static void cal_prefs_dialog_use_24_hour_toggled(GtkWidget *button, - CalPrefsDialog *prefs); -static void cal_prefs_dialog_hide_completed_tasks_toggled (GtkWidget *button, - CalPrefsDialog *prefs); -static void cal_prefs_dialog_show_config (CalPrefsDialog *prefs); -static void cal_prefs_dialog_update_config (CalPrefsDialog *prefs); +static gboolean get_widgets (DialogData *data); -GtkWidget* cal_prefs_dialog_create_time_edit (void); +static void widget_changed_callback (GtkWidget *, void *data); +static void connect_changed (GtkWidget *widget, const char *signal_name, EvolutionConfigControl *config_control); +static void setup_changes (DialogData *data, EvolutionConfigControl *config_control); -static GtkObjectClass *parent_class; +static void init_widgets (DialogData *data); +static void show_config (DialogData *data); +static void update_config (DialogData *dialog_data); -E_MAKE_TYPE (cal_prefs_dialog, "CalPrefsDialog", CalPrefsDialog, - cal_prefs_dialog_class_init, cal_prefs_dialog_init, - GTK_TYPE_OBJECT) +static void config_control_apply_callback (EvolutionConfigControl *config_control, void *data); +static void config_control_destroy_callback (GtkObject *object, void *data); +static void cal_prefs_dialog_use_24_hour_toggled(GtkWidget *button, void *data); +static void cal_prefs_dialog_hide_completed_tasks_toggled (GtkWidget *button, void *data); -static void -cal_prefs_dialog_class_init (CalPrefsDialogClass *class) +GtkWidget *cal_prefs_dialog_create_time_edit (void); + + +/** + * cal_prefs_dialog_new: + * + * Creates a new #CalPrefsDialog. + * + * Return value: a new #CalPrefsDialog. + **/ +EvolutionConfigControl * +cal_prefs_dialog_new (void) { - GtkObjectClass *object_class; + DialogData *dialog_data; + EvolutionConfigControl *config_control; - object_class = (GtkObjectClass *) class; + dialog_data = g_new0 (DialogData, 1); - parent_class = gtk_type_class (GTK_TYPE_OBJECT); + /* Load the content widgets */ - object_class->destroy = cal_prefs_dialog_destroy; -} + dialog_data->xml = glade_xml_new (EVOLUTION_GLADEDIR "/cal-prefs-dialog.glade", NULL); + if (!dialog_data->xml) { + g_message ("cal_prefs_dialog_construct(): Could not load the Glade XML file!"); + return NULL; + } + + if (!get_widgets (dialog_data)) { + g_message ("cal_prefs_dialog_construct(): Could not find all widgets in the XML file!"); + return NULL; + } + + init_widgets (dialog_data); + show_config (dialog_data); + + gtk_widget_ref (dialog_data->page); + gtk_container_remove (GTK_CONTAINER (dialog_data->page->parent), dialog_data->page); + config_control = evolution_config_control_new (dialog_data->page); + gtk_widget_unref (dialog_data->page); + gtk_signal_connect (GTK_OBJECT (config_control), "apply", + GTK_SIGNAL_FUNC (config_control_apply_callback), dialog_data); + gtk_signal_connect (GTK_OBJECT (config_control), "destroy", + GTK_SIGNAL_FUNC (config_control_destroy_callback), dialog_data); + + setup_changes (dialog_data, config_control); + + return config_control; +} static void -cal_prefs_dialog_init (CalPrefsDialog *prefs) +widget_changed_callback (GtkWidget *widget, + void *data) { - CalPrefsDialogPrivate *priv; + EvolutionConfigControl *config_control; - priv = g_new0 (CalPrefsDialogPrivate, 1); - prefs->priv = priv; + config_control = EVOLUTION_CONFIG_CONTROL (data); + evolution_config_control_changed (config_control); } - -/** - * cal_prefs_dialog_new: - * @page: Page to show when the dialog is popped up. - * - * Creates a new #CalPrefsDialog. - * - * Return value: a new #CalPrefsDialog. - **/ -CalPrefsDialog * -cal_prefs_dialog_new (CalPrefsDialogPage page) +/* ^*&%!!#! GnomeColorPicker. */ +static void +color_set_callback (GnomeColorPicker *cp, + guint r, + guint g, + guint b, + guint a, + void *data) { - CalPrefsDialog *prefs; + EvolutionConfigControl *config_control; - prefs = CAL_PREFS_DIALOG (gtk_type_new (cal_prefs_dialog_get_type ())); - return cal_prefs_dialog_construct (prefs, page); -} + config_control = EVOLUTION_CONFIG_CONTROL (data); + evolution_config_control_changed (config_control); +} -/** - * cal_prefs_dialog_construct: - * @prefs: A #CalPrefsDialog. - * @page: Page to show when the dialog is popped up. - * - * Constructs a task editor by loading its Glade XML file. - * - * Return value: The same object as @prefs, or NULL if the widgets could not be - * created. In the latter case, the task editor will automatically be - * destroyed. - **/ -CalPrefsDialog * -cal_prefs_dialog_construct (CalPrefsDialog *prefs, CalPrefsDialogPage page) +static void +connect_changed (GtkWidget *widget, + const char *signal_name, + EvolutionConfigControl *config_control) { - CalPrefsDialogPrivate *priv; + gtk_signal_connect (GTK_OBJECT (widget), signal_name, + GTK_SIGNAL_FUNC (widget_changed_callback), config_control); +} - g_return_val_if_fail (IS_CAL_PREFS_DIALOG (prefs), NULL); +static void +setup_changes (DialogData *dialog_data, + EvolutionConfigControl *config_control) +{ + int i; - priv = prefs->priv; + for (i = 0; i < 7; i ++) + connect_changed (dialog_data->working_days[i], "toggled", config_control); - /* Load the content widgets */ + connect_changed (dialog_data->timezone, "changed", config_control); - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/cal-prefs-dialog.glade", NULL); - if (!priv->xml) { - g_message ("cal_prefs_dialog_construct(): Could not load the Glade XML file!"); - goto error; - } + connect_changed (dialog_data->start_of_day, "changed", config_control); + connect_changed (dialog_data->end_of_day, "changed", config_control); - if (!get_widgets (prefs)) { - g_message ("cal_prefs_dialog_construct(): Could not find all widgets in the XML file!"); - goto error; - } + connect_changed (GTK_OPTION_MENU (dialog_data->week_start_day)->menu, "selection_done", config_control); - cal_prefs_dialog_init_widgets (prefs); + connect_changed (dialog_data->use_12_hour, "toggled", config_control); - cal_prefs_dialog_show_config (prefs); + connect_changed (GTK_OPTION_MENU (dialog_data->time_divisions)->menu, "selection_done", config_control); - cal_prefs_dialog_show (prefs, page); + connect_changed (dialog_data->show_end_times, "toggled", config_control); + connect_changed (dialog_data->compress_weekend, "toggled", config_control); + connect_changed (dialog_data->dnav_show_week_no, "toggled", config_control); - return prefs; + connect_changed (dialog_data->tasks_hide_completed_checkbutton, "toggled", config_control); + connect_changed (dialog_data->tasks_hide_completed_spinbutton, "changed", config_control); + connect_changed (GTK_OPTION_MENU (dialog_data->tasks_hide_completed_spinbutton)->menu, "selection_done", config_control); - error: + connect_changed (dialog_data->confirm_delete, "toggled", config_control); + connect_changed (dialog_data->default_reminder, "toggled", config_control); + connect_changed (dialog_data->default_reminder_interval, "changed", config_control); + connect_changed (GTK_OPTION_MENU (dialog_data->default_reminder_units)->menu, "selection_done", config_control); - gtk_object_unref (GTK_OBJECT (prefs)); - return NULL; + /* These use GnomeColorPicker so we have to use a different signal. */ + gtk_signal_connect (GTK_OBJECT (dialog_data->tasks_due_today_color), "color_set", + GTK_SIGNAL_FUNC (color_set_callback), config_control); + gtk_signal_connect (GTK_OBJECT (dialog_data->tasks_overdue_color), "color_set", + GTK_SIGNAL_FUNC (color_set_callback), config_control); } - /* Gets the widgets from the XML file and returns if they are all available. */ static gboolean -get_widgets (CalPrefsDialog *prefs) +get_widgets (DialogData *data) { - CalPrefsDialogPrivate *priv; - - priv = prefs->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) +#define GW(name) glade_xml_get_widget (data->xml, name) - priv->dialog = GW ("cal-prefs-dialog"); - - priv->toplevel_notebook = GW ("toplevel-notebook"); + data->page = GW ("toplevel-notebook"); /* The indices must be 0 (Sun) to 6 (Sat). */ - priv->working_days[0] = GW ("sun_button"); - priv->working_days[1] = GW ("mon_button"); - priv->working_days[2] = GW ("tue_button"); - priv->working_days[3] = GW ("wed_button"); - priv->working_days[4] = GW ("thu_button"); - priv->working_days[5] = GW ("fri_button"); - priv->working_days[6] = GW ("sat_button"); - - priv->timezone = GW ("timezone"); - priv->week_start_day = GW ("first_day_of_week"); - priv->start_of_day = GW ("start_of_day"); - priv->end_of_day = GW ("end_of_day"); - priv->use_12_hour = GW ("use_12_hour"); - priv->use_24_hour = GW ("use_24_hour"); - priv->time_divisions = GW ("time_divisions"); - priv->show_end_times = GW ("show_end_times"); - 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"); - - priv->tasks_hide_completed_checkbutton = GW ("tasks-hide-completed-checkbutton"); - priv->tasks_hide_completed_spinbutton = GW ("tasks-hide-completed-spinbutton"); - priv->tasks_hide_completed_optionmenu = GW ("tasks-hide-completed-optionmenu"); - - priv->confirm_delete = GW ("confirm-delete"); - priv->default_reminder = GW ("default-reminder"); - priv->default_reminder_interval = GW ("default-reminder-interval"); - priv->default_reminder_units = GW ("default-reminder-units"); + data->working_days[0] = GW ("sun_button"); + data->working_days[1] = GW ("mon_button"); + data->working_days[2] = GW ("tue_button"); + data->working_days[3] = GW ("wed_button"); + data->working_days[4] = GW ("thu_button"); + data->working_days[5] = GW ("fri_button"); + data->working_days[6] = GW ("sat_button"); + + data->timezone = GW ("timezone"); + data->week_start_day = GW ("first_day_of_week"); + data->start_of_day = GW ("start_of_day"); + data->end_of_day = GW ("end_of_day"); + data->use_12_hour = GW ("use_12_hour"); + data->use_24_hour = GW ("use_24_hour"); + data->time_divisions = GW ("time_divisions"); + data->show_end_times = GW ("show_end_times"); + data->compress_weekend = GW ("compress_weekend"); + data->dnav_show_week_no = GW ("dnav_show_week_no"); + + data->tasks_due_today_color = GW ("tasks_due_today_color"); + data->tasks_overdue_color = GW ("tasks_overdue_color"); + + data->tasks_hide_completed_checkbutton = GW ("tasks-hide-completed-checkbutton"); + data->tasks_hide_completed_spinbutton = GW ("tasks-hide-completed-spinbutton"); + data->tasks_hide_completed_optionmenu = GW ("tasks-hide-completed-optionmenu"); + + data->confirm_delete = GW ("confirm-delete"); + data->default_reminder = GW ("default-reminder"); + data->default_reminder_interval = GW ("default-reminder-interval"); + data->default_reminder_units = GW ("default-reminder-units"); #undef GW - return (priv->dialog - && priv->toplevel_notebook - && priv->timezone - && priv->working_days[0] - && priv->working_days[1] - && priv->working_days[2] - && priv->working_days[3] - && priv->working_days[4] - && priv->working_days[5] - && priv->working_days[6] - && priv->week_start_day - && priv->start_of_day - && priv->end_of_day - && priv->use_12_hour - && priv->use_24_hour - && priv->time_divisions - && priv->show_end_times - && priv->compress_weekend - && priv->dnav_show_week_no - && priv->tasks_due_today_color - && priv->tasks_overdue_color - && priv->tasks_hide_completed_checkbutton - && priv->tasks_hide_completed_spinbutton - && priv->tasks_hide_completed_optionmenu - && priv->confirm_delete - && priv->default_reminder - && priv->default_reminder_interval - && priv->default_reminder_units); + return (data->page + && data->timezone + && data->working_days[0] + && data->working_days[1] + && data->working_days[2] + && data->working_days[3] + && data->working_days[4] + && data->working_days[5] + && data->working_days[6] + && data->week_start_day + && data->start_of_day + && data->end_of_day + && data->use_12_hour + && data->use_24_hour + && data->time_divisions + && data->show_end_times + && data->compress_weekend + && data->dnav_show_week_no + && data->tasks_due_today_color + && data->tasks_overdue_color + && data->tasks_hide_completed_checkbutton + && data->tasks_hide_completed_spinbutton + && data->tasks_hide_completed_optionmenu + && data->confirm_delete + && data->default_reminder + && data->default_reminder_interval + && data->default_reminder_units); } static void -cal_prefs_dialog_destroy (GtkObject *object) +config_control_destroy_callback (GtkObject *object, + void *data) { - CalPrefsDialog *prefs; - CalPrefsDialogPrivate *priv; + DialogData *dialog_data; - g_return_if_fail (IS_CAL_PREFS_DIALOG (object)); + dialog_data = (DialogData *) data; - prefs = CAL_PREFS_DIALOG (object); - priv = prefs->priv; + /* (Nothing to free in the struct.) */ + g_free (dialog_data); +} - g_free (priv); - prefs->priv = NULL; +static void +config_control_apply_callback (EvolutionConfigControl *control, + void *data) +{ + DialogData *dialog_data; + + dialog_data = (DialogData *) data; - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + update_config (dialog_data); } @@ -322,122 +350,49 @@ cal_prefs_dialog_create_time_edit (void) } -void -cal_prefs_dialog_show (CalPrefsDialog *prefs, CalPrefsDialogPage page) -{ - CalPrefsDialogPrivate *priv; - int page_num; - - g_return_if_fail (IS_CAL_PREFS_DIALOG (prefs)); - - priv = prefs->priv; - - /* If the dialog is already show just raise it, otherwise refresh the - config settings and show it. */ - if (GTK_WIDGET_MAPPED (priv->dialog)) { - gdk_window_raise (priv->dialog->window); - } else { - cal_prefs_dialog_show_config (prefs); - gtk_widget_show (priv->dialog); - } - - switch (page) { - case CAL_PREFS_DIALOG_PAGE_CALENDAR: - page_num = 0; - break; - - case CAL_PREFS_DIALOG_PAGE_TASKS: - page_num = 2; - break; - - default: - g_assert_not_reached (); - return; - } - - gtk_notebook_set_page (GTK_NOTEBOOK (priv->toplevel_notebook), page_num); -} - - /* Connects any necessary signal handlers. */ static void -cal_prefs_dialog_init_widgets (CalPrefsDialog *prefs) +init_widgets (DialogData *dialog_data) { - CalPrefsDialogPrivate *priv; - - priv = prefs->priv; - - gtk_signal_connect (GTK_OBJECT (priv->dialog), "clicked", - GTK_SIGNAL_FUNC (cal_prefs_dialog_button_clicked), - prefs); - - gtk_signal_connect (GTK_OBJECT (priv->use_24_hour), "toggled", + gtk_signal_connect (GTK_OBJECT (dialog_data->use_24_hour), "toggled", GTK_SIGNAL_FUNC (cal_prefs_dialog_use_24_hour_toggled), - prefs); + dialog_data); - gtk_signal_connect (GTK_OBJECT (priv->tasks_hide_completed_checkbutton), + gtk_signal_connect (GTK_OBJECT (dialog_data->tasks_hide_completed_checkbutton), "toggled", GTK_SIGNAL_FUNC (cal_prefs_dialog_hide_completed_tasks_toggled), - prefs); + dialog_data); } static void -cal_prefs_dialog_button_clicked (GtkWidget *dialog, - gint button, - CalPrefsDialog *prefs) +cal_prefs_dialog_use_24_hour_toggled (GtkWidget *button, + void *data) { - CalPrefsDialogPrivate *priv; - - g_return_if_fail (IS_CAL_PREFS_DIALOG (prefs)); - - priv = prefs->priv; - - /* OK & Apply buttons update the config settings. */ - if (button == 0 || button == 1) - cal_prefs_dialog_update_config (prefs); - - /* OK & Close buttons close the dialog. */ - if (button == 0 || button == 2) - gtk_widget_hide (priv->dialog); - - /* FIXME: Handle button 3 (Help). */ - -} - - -static void -cal_prefs_dialog_use_24_hour_toggled (GtkWidget *button, - CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; + DialogData *dialog_data; gboolean use_24_hour; - priv = prefs->priv; + dialog_data = (DialogData *) data; - use_24_hour = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->use_24_hour)); + use_24_hour = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog_data->use_24_hour)); - e_date_edit_set_use_24_hour_format (E_DATE_EDIT (priv->start_of_day), - use_24_hour); - e_date_edit_set_use_24_hour_format (E_DATE_EDIT (priv->end_of_day), - use_24_hour); + e_date_edit_set_use_24_hour_format (E_DATE_EDIT (dialog_data->start_of_day), use_24_hour); + e_date_edit_set_use_24_hour_format (E_DATE_EDIT (dialog_data->end_of_day), use_24_hour); } static void -cal_prefs_dialog_hide_completed_tasks_toggled (GtkWidget *button, - CalPrefsDialog *prefs) +cal_prefs_dialog_hide_completed_tasks_toggled (GtkWidget *button, + void *data) { - CalPrefsDialogPrivate *priv; + DialogData *dialog_data; gboolean hide_completed_tasks; - priv = prefs->priv; + dialog_data = (DialogData *) data; - hide_completed_tasks = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->tasks_hide_completed_checkbutton)); + hide_completed_tasks = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog_data->tasks_hide_completed_checkbutton)); - gtk_widget_set_sensitive (priv->tasks_hide_completed_spinbutton, - hide_completed_tasks); - gtk_widget_set_sensitive (priv->tasks_hide_completed_optionmenu, - hide_completed_tasks); + gtk_widget_set_sensitive (dialog_data->tasks_hide_completed_spinbutton, hide_completed_tasks); + gtk_widget_set_sensitive (dialog_data->tasks_hide_completed_optionmenu, hide_completed_tasks); } /* Sets the color in a color picker from an X color spec */ @@ -462,117 +417,111 @@ set_color_picker (GtkWidget *picker, const char *spec) /* Shows the current task list settings in the dialog */ static void -show_task_list_config (CalPrefsDialog *prefs) +show_task_list_config (DialogData *dialog_data) { - CalPrefsDialogPrivate *priv; CalUnits units; gboolean hide_completed_tasks; - 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 ()); + set_color_picker (dialog_data->tasks_due_today_color, calendar_config_get_tasks_due_today_color ()); + set_color_picker (dialog_data->tasks_overdue_color, calendar_config_get_tasks_overdue_color ()); /* Hide Completed Tasks. */ hide_completed_tasks = calendar_config_get_hide_completed_tasks (); - e_dialog_toggle_set (priv->tasks_hide_completed_checkbutton, + e_dialog_toggle_set (dialog_data->tasks_hide_completed_checkbutton, hide_completed_tasks); /* Hide Completed Tasks Units. */ units = calendar_config_get_hide_completed_tasks_units (); - e_dialog_option_menu_set (priv->tasks_hide_completed_optionmenu, + e_dialog_option_menu_set (dialog_data->tasks_hide_completed_optionmenu, units, hide_completed_units_map); /* Hide Completed Tasks Value. */ - e_dialog_spin_set (priv->tasks_hide_completed_spinbutton, + e_dialog_spin_set (dialog_data->tasks_hide_completed_spinbutton, calendar_config_get_hide_completed_tasks_value ()); - gtk_widget_set_sensitive (priv->tasks_hide_completed_spinbutton, + gtk_widget_set_sensitive (dialog_data->tasks_hide_completed_spinbutton, hide_completed_tasks); - gtk_widget_set_sensitive (priv->tasks_hide_completed_optionmenu, + gtk_widget_set_sensitive (dialog_data->tasks_hide_completed_optionmenu, hide_completed_tasks); } /* Shows the current config settings in the dialog. */ static void -cal_prefs_dialog_show_config (CalPrefsDialog *prefs) +show_config (DialogData *dialog_data) { - CalPrefsDialogPrivate *priv; CalWeekdays working_days; gint mask, day, week_start_day, time_divisions; char *zone_name; icaltimezone *zone; gboolean sensitive; - priv = prefs->priv; - /* Timezone. */ zone_name = calendar_config_get_timezone (); zone = icaltimezone_get_builtin_timezone (zone_name); - e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->timezone), + e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (dialog_data->timezone), zone); /* Working Days. */ working_days = calendar_config_get_working_days (); mask = 1 << 0; for (day = 0; day < 7; day++) { - e_dialog_toggle_set (priv->working_days[day], (working_days & mask) ? TRUE : FALSE); + e_dialog_toggle_set (dialog_data->working_days[day], (working_days & mask) ? TRUE : FALSE); mask <<= 1; } /* Week Start Day. */ week_start_day = calendar_config_get_week_start_day (); - e_dialog_option_menu_set (priv->week_start_day, week_start_day, + e_dialog_option_menu_set (dialog_data->week_start_day, week_start_day, week_start_day_map); /* Start of Day. */ - e_date_edit_set_time_of_day (E_DATE_EDIT (priv->start_of_day), + e_date_edit_set_time_of_day (E_DATE_EDIT (dialog_data->start_of_day), calendar_config_get_day_start_hour (), calendar_config_get_day_start_minute ()); /* End of Day. */ - e_date_edit_set_time_of_day (E_DATE_EDIT (priv->end_of_day), + e_date_edit_set_time_of_day (E_DATE_EDIT (dialog_data->end_of_day), calendar_config_get_day_end_hour (), calendar_config_get_day_end_minute ()); /* 12/24 Hour Format. */ if (calendar_config_get_24_hour_format ()) - e_dialog_toggle_set (priv->use_24_hour, TRUE); + e_dialog_toggle_set (dialog_data->use_24_hour, TRUE); else - e_dialog_toggle_set (priv->use_12_hour, TRUE); + e_dialog_toggle_set (dialog_data->use_12_hour, TRUE); sensitive = calendar_config_locale_supports_12_hour_format (); - gtk_widget_set_sensitive (priv->use_12_hour, sensitive); - gtk_widget_set_sensitive (priv->use_24_hour, sensitive); + gtk_widget_set_sensitive (dialog_data->use_12_hour, sensitive); + gtk_widget_set_sensitive (dialog_data->use_24_hour, sensitive); /* Time Divisions. */ time_divisions = calendar_config_get_time_divisions (); - e_dialog_option_menu_set (priv->time_divisions, time_divisions, + e_dialog_option_menu_set (dialog_data->time_divisions, time_divisions, time_division_map); /* Show Appointment End Times. */ - e_dialog_toggle_set (priv->show_end_times, calendar_config_get_show_event_end ()); + e_dialog_toggle_set (dialog_data->show_end_times, calendar_config_get_show_event_end ()); /* Compress Weekend. */ - e_dialog_toggle_set (priv->compress_weekend, calendar_config_get_compress_weekend ()); + e_dialog_toggle_set (dialog_data->compress_weekend, calendar_config_get_compress_weekend ()); /* Date Navigator - Show Week Numbers. */ - e_dialog_toggle_set (priv->dnav_show_week_no, calendar_config_get_dnav_show_week_no ()); + e_dialog_toggle_set (dialog_data->dnav_show_week_no, calendar_config_get_dnav_show_week_no ()); /* Task list */ - show_task_list_config (prefs); + show_task_list_config (dialog_data); /* Other page */ - e_dialog_toggle_set (priv->confirm_delete, calendar_config_get_confirm_delete ()); + e_dialog_toggle_set (dialog_data->confirm_delete, calendar_config_get_confirm_delete ()); - e_dialog_toggle_set (priv->default_reminder, + e_dialog_toggle_set (dialog_data->default_reminder, calendar_config_get_use_default_reminder ()); - e_dialog_spin_set (priv->default_reminder_interval, + e_dialog_spin_set (dialog_data->default_reminder_interval, calendar_config_get_default_reminder_interval ()); - e_dialog_option_menu_set (priv->default_reminder_units, + e_dialog_option_menu_set (dialog_data->default_reminder_units, calendar_config_get_default_reminder_units (), default_reminder_units_map); } @@ -594,89 +543,82 @@ spec_from_picker (GtkWidget *picker) /* Updates the task list config values from the settings in the dialog */ static void -update_task_list_config (CalPrefsDialog *prefs) +update_task_list_config (DialogData *dialog_data) { - CalPrefsDialogPrivate *priv; + calendar_config_set_tasks_due_today_color (spec_from_picker (dialog_data->tasks_due_today_color)); + calendar_config_set_tasks_overdue_color (spec_from_picker (dialog_data->tasks_overdue_color)); - 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)); - - calendar_config_set_hide_completed_tasks (e_dialog_toggle_get (priv->tasks_hide_completed_checkbutton)); - calendar_config_set_hide_completed_tasks_units (e_dialog_option_menu_get (priv->tasks_hide_completed_optionmenu, hide_completed_units_map)); - calendar_config_set_hide_completed_tasks_value (e_dialog_spin_get_int (priv->tasks_hide_completed_spinbutton)); + calendar_config_set_hide_completed_tasks (e_dialog_toggle_get (dialog_data->tasks_hide_completed_checkbutton)); + calendar_config_set_hide_completed_tasks_units (e_dialog_option_menu_get (dialog_data->tasks_hide_completed_optionmenu, hide_completed_units_map)); + calendar_config_set_hide_completed_tasks_value (e_dialog_spin_get_int (dialog_data->tasks_hide_completed_spinbutton)); } /* Updates the config values based on the settings in the dialog. */ static void -cal_prefs_dialog_update_config (CalPrefsDialog *prefs) +update_config (DialogData *dialog_data) { - CalPrefsDialogPrivate *priv; CalWeekdays working_days; gint mask, day, week_start_day, time_divisions, hour, minute; icaltimezone *zone; - priv = prefs->priv; - /* Timezone. */ - zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->timezone)); + zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (dialog_data->timezone)); calendar_config_set_timezone (icaltimezone_get_location (zone)); /* Working Days. */ working_days = 0; mask = 1 << 0; for (day = 0; day < 7; day++) { - if (e_dialog_toggle_get (priv->working_days[day])) + if (e_dialog_toggle_get (dialog_data->working_days[day])) working_days |= mask; mask <<= 1; } calendar_config_set_working_days (working_days); /* Week Start Day. */ - week_start_day = e_dialog_option_menu_get (priv->week_start_day, week_start_day_map); + week_start_day = e_dialog_option_menu_get (dialog_data->week_start_day, week_start_day_map); calendar_config_set_week_start_day (week_start_day); /* Start of Day. */ - e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_of_day), &hour, &minute); + e_date_edit_get_time_of_day (E_DATE_EDIT (dialog_data->start_of_day), &hour, &minute); calendar_config_set_day_start_hour (hour); calendar_config_set_day_start_minute (minute); /* End of Day. */ - e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_of_day), &hour, &minute); + e_date_edit_get_time_of_day (E_DATE_EDIT (dialog_data->end_of_day), &hour, &minute); calendar_config_set_day_end_hour (hour); calendar_config_set_day_end_minute (minute); /* 12/24 Hour Format. */ - calendar_config_set_24_hour_format (e_dialog_toggle_get (priv->use_24_hour)); + calendar_config_set_24_hour_format (e_dialog_toggle_get (dialog_data->use_24_hour)); /* Time Divisions. */ - time_divisions = e_dialog_option_menu_get (priv->time_divisions, time_division_map); + time_divisions = e_dialog_option_menu_get (dialog_data->time_divisions, time_division_map); calendar_config_set_time_divisions (time_divisions); /* Show Appointment End Times. */ - calendar_config_set_show_event_end (e_dialog_toggle_get (priv->show_end_times)); + calendar_config_set_show_event_end (e_dialog_toggle_get (dialog_data->show_end_times)); /* Compress Weekend. */ - calendar_config_set_compress_weekend (e_dialog_toggle_get (priv->compress_weekend)); + calendar_config_set_compress_weekend (e_dialog_toggle_get (dialog_data->compress_weekend)); /* Date Navigator - Show Week Numbers. */ - calendar_config_set_dnav_show_week_no (e_dialog_toggle_get (priv->dnav_show_week_no)); + calendar_config_set_dnav_show_week_no (e_dialog_toggle_get (dialog_data->dnav_show_week_no)); /* Task list */ - update_task_list_config (prefs); + update_task_list_config (dialog_data); /* Other page */ - calendar_config_set_confirm_delete (e_dialog_toggle_get (priv->confirm_delete)); + calendar_config_set_confirm_delete (e_dialog_toggle_get (dialog_data->confirm_delete)); - calendar_config_set_use_default_reminder (e_dialog_toggle_get (priv->default_reminder)); + calendar_config_set_use_default_reminder (e_dialog_toggle_get (dialog_data->default_reminder)); calendar_config_set_default_reminder_interval ( - e_dialog_spin_get_int (priv->default_reminder_interval)); + e_dialog_spin_get_int (dialog_data->default_reminder_interval)); calendar_config_set_default_reminder_units ( - e_dialog_option_menu_get (priv->default_reminder_units, default_reminder_units_map)); + e_dialog_option_menu_get (dialog_data->default_reminder_units, default_reminder_units_map)); /* Done */ diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index 6a14f50ec3..20b2c5e363 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -15,6 +15,7 @@ <widget> <class>GnomeDialog</class> <name>cal-prefs-dialog</name> + <visible>False</visible> <title>Calendar and Tasks Settings</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h index 063341c18a..ce3f46736c 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ b/calendar/gui/dialogs/cal-prefs-dialog.h @@ -30,46 +30,9 @@ #ifndef _CAL_PREFS_DIALOG_H_ #define _CAL_PREFS_DIALOG_H_ -#include <gtk/gtkobject.h> -#include <libgnome/gnome-defs.h> +#include "evolution-config-control.h" -BEGIN_GNOME_DECLS - - -#define CAL_PREFS_DIALOG(obj) GTK_CHECK_CAST (obj, cal_prefs_dialog_get_type (), CalPrefsDialog) -#define CAL_PREFS_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, cal_prefs_dialog_get_type (), CalPrefsDialogClass) -#define IS_CAL_PREFS_DIALOG(obj) GTK_CHECK_TYPE (obj, cal_prefs_dialog_get_type ()) - - -typedef struct _CalPrefsDialog CalPrefsDialog; -typedef struct _CalPrefsDialogClass CalPrefsDialogClass; - -typedef struct _CalPrefsDialogPrivate CalPrefsDialogPrivate; - -typedef enum { - CAL_PREFS_DIALOG_PAGE_CALENDAR, - CAL_PREFS_DIALOG_PAGE_TASKS -} CalPrefsDialogPage; - -struct _CalPrefsDialog -{ - GtkObject object; - - /*< private >*/ - CalPrefsDialogPrivate *priv; -}; - -struct _CalPrefsDialogClass -{ - GtkObjectClass parent_class; -}; - - -GtkType cal_prefs_dialog_get_type (void); -CalPrefsDialog* cal_prefs_dialog_construct (CalPrefsDialog *prefs, CalPrefsDialogPage page); -CalPrefsDialog* cal_prefs_dialog_new (CalPrefsDialogPage page); - -void cal_prefs_dialog_show (CalPrefsDialog *prefs, CalPrefsDialogPage page); +EvolutionConfigControl *cal_prefs_dialog_new (void); END_GNOME_DECLS |