diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2008-07-19 00:23:26 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-07-19 00:23:26 +0800 |
commit | 0597b877c5bf4d21ac4048742ddf6b11e24877ba (patch) | |
tree | 74501a98fdec4d2c11d26a1f1d7d43a3058ad6f5 /calendar/gui/dialogs/task-details-page.c | |
parent | 68d73b10b22a2ba0e022b812321bc435e04c4867 (diff) | |
download | gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.gz gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.zst gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.zip |
** Fixes bug #542125
2008-07-18 Matthew Barnes <mbarnes@redhat.com>
** Fixes bug #542125
** This set of changes migrates CompEditor, CompEditorPage and the
various subclasses from using BonoboUI to GtkUIManager for menus
and toolbars. It also substantially cleans up the code and
streamlines the CompEditorPage API, making more effective use
of GObject properties.
Core changes:
* gui/dialogs/comp-editor-page.c:
* gui/dialogs/comp-editor-page.h:
* gui/dialogs/comp-editor.c:
* gui/dialogs/comp-editor.h:
* gui/dialogs/event-editor.c:
* gui/dialogs/event-editor.h:
* gui/dialogs/event-page.c:
* gui/dialogs/event-page.h:
* gui/dialogs/memo-editor.c:
* gui/dialogs/memo-editor.h:
* gui/dialogs/memo-page.c:
* gui/dialogs/memo-page.h:
* gui/dialogs/recurrence-page.c:
* gui/dialogs/recurrence-page.h:
* gui/dialogs/schedule-page.c:
* gui/dialogs/schedule-page.h:
* gui/dialogs/task-details-page.c:
* gui/dialogs/task-details-page.h:
* gui/dialogs/task-editor.c:
* gui/dialogs/task-editor.h:
* gui/dialogs/task-page.c:
* gui/dialogs/task-page.h:
Supporting changes:
* gui/calendar-component.c:
* gui/comp-editor-factory.c:
* gui/e-cal-popup.c:
* gui/e-calendar-table.c:
* gui/e-calendar-view.c:
* gui/e-comp-editor-registry.c:
* gui/e-memo-table.c:
* gui/e-tasks.c:
* gui/gnome-cal.c:
* gui/memos-component.c:
* gui/tasks-component.c:
* gui/dialogs/alarm-dialog.c:
* gui/dialogs/comp-editor-util.c:
* art/Makefile.am:
Move query-free-busy.png to data/icons.
svn path=/trunk/; revision=35753
Diffstat (limited to 'calendar/gui/dialogs/task-details-page.c')
-rw-r--r-- | calendar/gui/dialogs/task-details-page.c | 197 |
1 files changed, 75 insertions, 122 deletions
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index 6e882ee26c..4b2a6491b6 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -37,9 +37,10 @@ #include "comp-editor-util.h" #include "task-details-page.h" - +#define TASK_DETAILS_PAGE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), TYPE_TASK_DETAILS_PAGE, TaskDetailsPagePrivate)) -/* Private part of the TaskDetailsPage structure */ struct _TaskDetailsPagePrivate { /* Glade XML data */ GladeXML *xml; @@ -57,8 +58,6 @@ struct _TaskDetailsPagePrivate { GtkWidget *url_label; GtkWidget *url_entry; GtkWidget *url; - - gboolean updating; }; /* Note that these two arrays must match. */ @@ -85,10 +84,6 @@ static const int priority_map[] = { -1 }; - - -static void task_details_page_finalize (GObject *object); - static GtkWidget *task_details_page_get_widget (CompEditorPage *page); static void task_details_page_focus_main_widget (CompEditorPage *page); static gboolean task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); @@ -97,82 +92,52 @@ static gboolean task_details_page_fill_timezones (CompEditorPage *page, GHashTab G_DEFINE_TYPE (TaskDetailsPage, task_details_page, TYPE_COMP_EDITOR_PAGE) -/* Class initialization function for the task page */ static void -task_details_page_class_init (TaskDetailsPageClass *class) +task_details_page_dispose (GObject *object) { - CompEditorPageClass *editor_page_class; - GObjectClass *object_class; + TaskDetailsPagePrivate *priv; - editor_page_class = (CompEditorPageClass *) class; - object_class = (GObjectClass *) class; + priv = TASK_DETAILS_PAGE_GET_PRIVATE (object); - editor_page_class->get_widget = task_details_page_get_widget; - editor_page_class->focus_main_widget = task_details_page_focus_main_widget; - editor_page_class->fill_widgets = task_details_page_fill_widgets; - editor_page_class->fill_component = task_details_page_fill_component; - editor_page_class->fill_timezones = task_details_page_fill_timezones; + if (priv->main != NULL) { + g_object_unref (priv->main); + priv->main = NULL; + } + + if (priv->xml != NULL) { + g_object_unref (priv->xml); + priv->xml = NULL; + } - object_class->finalize = task_details_page_finalize; + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (task_details_page_parent_class)->dispose (object); } -/* Object initialization function for the task page */ static void -task_details_page_init (TaskDetailsPage *tdpage) +task_details_page_class_init (TaskDetailsPageClass *class) { - TaskDetailsPagePrivate *priv; - - priv = g_new0 (TaskDetailsPagePrivate, 1); - tdpage->priv = priv; - - priv->xml = NULL; - - priv->main = NULL; - - priv->status = NULL; - priv->priority = NULL; - priv->percent_complete = NULL; + GObjectClass *object_class; + CompEditorPageClass *editor_page_class; - priv->date_completed_label = NULL; - priv->completed_date = NULL; + g_type_class_add_private (class, sizeof (TaskDetailsPagePrivate)); - priv->url_label = NULL; - priv->url_entry = NULL; - priv->url = NULL; + object_class = G_OBJECT_CLASS (class); + object_class->dispose = task_details_page_dispose; - priv->updating = FALSE; + editor_page_class = COMP_EDITOR_PAGE_CLASS (class); + editor_page_class->get_widget = task_details_page_get_widget; + editor_page_class->focus_main_widget = task_details_page_focus_main_widget; + editor_page_class->fill_widgets = task_details_page_fill_widgets; + editor_page_class->fill_component = task_details_page_fill_component; + editor_page_class->fill_timezones = task_details_page_fill_timezones; } -/* Destroy handler for the task page */ static void -task_details_page_finalize (GObject *object) +task_details_page_init (TaskDetailsPage *tdpage) { - TaskDetailsPage *tdpage; - TaskDetailsPagePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_TASK_DETAILS_PAGE (object)); - - tdpage = TASK_DETAILS_PAGE (object); - priv = tdpage->priv; - - if (priv->main) - g_object_unref (priv->main); - - if (priv->xml) { - g_object_unref (priv->xml); - priv->xml = NULL; - } - - g_free (priv); - tdpage->priv = NULL; - - if (G_OBJECT_CLASS (task_details_page_parent_class)->finalize) - (* G_OBJECT_CLASS (task_details_page_parent_class)->finalize) (object); + tdpage->priv = TASK_DETAILS_PAGE_GET_PRIVATE (tdpage); } - - /* get_widget handler for the task page */ static GtkWidget * task_details_page_get_widget (CompEditorPage *page) @@ -261,12 +226,15 @@ clear_widgets (TaskDetailsPage *tdpage) static void sensitize_widgets (TaskDetailsPage *tdpage) { + TaskDetailsPagePrivate *priv = tdpage->priv; + CompEditor *editor; + ECal *client; gboolean read_only; - TaskDetailsPagePrivate *priv; - priv = tdpage->priv; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); + client = comp_editor_get_client (editor); - if (!e_cal_is_read_only (COMP_EDITOR_PAGE (tdpage)->client, &read_only, NULL)) + if (!e_cal_is_read_only (client, &read_only, NULL)) read_only = TRUE; gtk_widget_set_sensitive (priv->status, !read_only); @@ -292,8 +260,6 @@ task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) tdpage = TASK_DETAILS_PAGE (page); priv = tdpage->priv; - priv->updating = TRUE; - /* Clean the screen */ clear_widgets (tdpage); @@ -361,8 +327,6 @@ task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) e_cal_component_get_url (comp, &url); e_dialog_editable_set (priv->url, url); - priv->updating = FALSE; - sensitize_widgets (tdpage); return TRUE; @@ -561,10 +525,10 @@ date_changed_cb (EDateEdit *dedit, gpointer data) tdpage = TASK_DETAILS_PAGE (data); priv = tdpage->priv; - if (priv->updating) + if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tdpage))) return; - priv->updating = TRUE; + comp_editor_page_set_updating (COMP_EDITOR_PAGE (tdpage), TRUE); date_set = e_date_edit_get_date (E_DATE_EDIT (priv->completed_date), &completed_tt.year, @@ -593,7 +557,7 @@ date_changed_cb (EDateEdit *dedit, gpointer data) e_dialog_spin_set (priv->percent_complete, 100); } - priv->updating = FALSE; + comp_editor_page_set_updating (COMP_EDITOR_PAGE (tdpage), FALSE); /* Notify upstream */ dates.complete = &completed_tt; @@ -605,14 +569,17 @@ status_changed (GtkMenu *menu, TaskDetailsPage *tdpage) { TaskDetailsPagePrivate *priv; icalproperty_status status; + CompEditor *editor; time_t ctime = -1; priv = tdpage->priv; - if (priv->updating) + if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tdpage))) return; - priv->updating = TRUE; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); + + comp_editor_page_set_updating (COMP_EDITOR_PAGE (tdpage), TRUE); status = e_dialog_option_menu_get (priv->status, status_map); if (status == ICAL_STATUS_NONE) { @@ -633,9 +600,9 @@ status_changed (GtkMenu *menu, TaskDetailsPage *tdpage) complete_date_changed (tdpage, ctime, TRUE); } - priv->updating = FALSE; + comp_editor_page_set_updating (COMP_EDITOR_PAGE (tdpage), FALSE); - comp_editor_page_notify_changed (COMP_EDITOR_PAGE (tdpage)); + comp_editor_set_changed (editor, TRUE); } static void @@ -644,15 +611,18 @@ percent_complete_changed (GtkAdjustment *adj, TaskDetailsPage *tdpage) TaskDetailsPagePrivate *priv; gint percent; icalproperty_status status; + CompEditor *editor; gboolean complete; time_t ctime = -1; priv = tdpage->priv; - if (priv->updating) + if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tdpage))) return; - priv->updating = TRUE; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); + + comp_editor_page_set_updating (COMP_EDITOR_PAGE (tdpage), TRUE); percent = e_dialog_spin_get_int (priv->percent_complete); if (percent == 100) { @@ -672,23 +642,9 @@ percent_complete_changed (GtkAdjustment *adj, TaskDetailsPage *tdpage) e_date_edit_set_time (E_DATE_EDIT (priv->completed_date), ctime); complete_date_changed (tdpage, ctime, complete); - priv->updating = FALSE; - - comp_editor_page_notify_changed (COMP_EDITOR_PAGE (tdpage)); -} - -/* This is called when any field is changed; it notifies upstream. */ -static void -field_changed_cb (GtkWidget *widget, gpointer data) -{ - TaskDetailsPage *tdpage; - TaskDetailsPagePrivate *priv; + comp_editor_page_set_updating (COMP_EDITOR_PAGE (tdpage), FALSE); - tdpage = TASK_DETAILS_PAGE (data); - priv = tdpage->priv; - - if (!priv->updating) - comp_editor_page_notify_changed (COMP_EDITOR_PAGE (tdpage)); + comp_editor_set_changed (editor, TRUE); } /* Hooks the widget signals */ @@ -721,27 +677,22 @@ init_widgets (TaskDetailsPage *tdpage) G_CALLBACK (percent_complete_changed), tdpage); /* Priority */ - g_signal_connect((GTK_OPTION_MENU (priv->priority)->menu), - "deactivate", - G_CALLBACK (field_changed_cb), tdpage); + g_signal_connect_swapped ( + GTK_OPTION_MENU (priv->priority)->menu, "deactivate", + G_CALLBACK (comp_editor_page_changed), tdpage); /* Completed Date */ - g_signal_connect((priv->completed_date), "changed", - G_CALLBACK (date_changed_cb), tdpage); - g_signal_connect (priv->completed_date, "changed", - G_CALLBACK (field_changed_cb), tdpage); + g_signal_connect ( + priv->completed_date, "changed", + G_CALLBACK (date_changed_cb), tdpage); + g_signal_connect_swapped ( + priv->completed_date, "changed", + G_CALLBACK (comp_editor_page_changed), tdpage); /* URL */ - g_signal_connect((priv->url), "changed", - G_CALLBACK (field_changed_cb), tdpage); -} - -static void -client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) -{ - TaskDetailsPage *tdpage = TASK_DETAILS_PAGE (page); - - sensitize_widgets (tdpage); + g_signal_connect_swapped ( + priv->url, "changed", + G_CALLBACK (comp_editor_page_changed), tdpage); } /** @@ -756,10 +707,11 @@ client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) TaskDetailsPage * task_details_page_construct (TaskDetailsPage *tdpage) { - TaskDetailsPagePrivate *priv; + TaskDetailsPagePrivate *priv = tdpage->priv; + CompEditor *editor; char *gladefile; - priv = tdpage->priv; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); gladefile = g_build_filename (EVOLUTION_GLADEDIR, "task-details-page.glade", @@ -781,8 +733,9 @@ task_details_page_construct (TaskDetailsPage *tdpage) init_widgets (tdpage); - g_signal_connect_after (G_OBJECT (tdpage), "client_changed", - G_CALLBACK (client_changed_cb), NULL); + g_signal_connect_swapped ( + editor, "notify::client", + G_CALLBACK (sensitize_widgets), tdpage); return tdpage; } @@ -796,14 +749,14 @@ task_details_page_construct (TaskDetailsPage *tdpage) * not be created. **/ TaskDetailsPage * -task_details_page_new (void) +task_details_page_new (CompEditor *editor) { TaskDetailsPage *tdpage; - tdpage = g_object_new (TYPE_TASK_DETAILS_PAGE, NULL); + tdpage = g_object_new (TYPE_TASK_DETAILS_PAGE, "editor", editor, NULL); if (!task_details_page_construct (tdpage)) { g_object_unref (tdpage); - return NULL; + g_return_val_if_reached (NULL); } return tdpage; |