aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/comp-editor-page.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2008-07-19 00:23:26 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-07-19 00:23:26 +0800
commit0597b877c5bf4d21ac4048742ddf6b11e24877ba (patch)
tree74501a98fdec4d2c11d26a1f1d7d43a3058ad6f5 /calendar/gui/dialogs/comp-editor-page.c
parent68d73b10b22a2ba0e022b812321bc435e04c4867 (diff)
downloadgsoc2013-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/comp-editor-page.c')
-rw-r--r--calendar/gui/dialogs/comp-editor-page.c487
1 files changed, 207 insertions, 280 deletions
diff --git a/calendar/gui/dialogs/comp-editor-page.c b/calendar/gui/dialogs/comp-editor-page.c
index d05e0eed74..4a48611d01 100644
--- a/calendar/gui/dialogs/comp-editor-page.c
+++ b/calendar/gui/dialogs/comp-editor-page.c
@@ -23,84 +23,111 @@
#endif
#include <glib/gi18n.h>
-#include <libgnomeui/gnome-dialog.h>
-#include <libgnomeui/gnome-dialog-util.h>
+#include "comp-editor.h"
#include "comp-editor-page.h"
-
+#define COMP_EDITOR_PAGE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), TYPE_COMP_EDITOR_PAGE, CompEditorPagePrivate))
-static void comp_editor_page_class_init (CompEditorPageClass *class);
-static void comp_editor_page_init (CompEditorPage *page);
-static void comp_editor_page_dispose (GObject *object);
-
-static gpointer parent_class;
+struct _CompEditorPagePrivate {
+ CompEditor *editor; /* not referenced */
+ gboolean updating;
+};
-/* Signal IDs */
+enum {
+ PROP_0,
+ PROP_EDITOR,
+ PROP_UPDATING
+};
enum {
- CHANGED,
- NEEDS_SEND,
- SUMMARY_CHANGED,
DATES_CHANGED,
- CLIENT_CHANGED,
- FOCUS_IN,
- FOCUS_OUT,
LAST_SIGNAL
};
+static gpointer parent_class;
static guint comp_editor_page_signals[LAST_SIGNAL];
-#define CLASS(page) (COMP_EDITOR_PAGE_CLASS (G_OBJECT_GET_CLASS (page)))
+static void
+comp_editor_page_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CompEditorPagePrivate *priv;
+
+ priv = COMP_EDITOR_PAGE_GET_PRIVATE (object);
-
+ switch (property_id) {
+ case PROP_EDITOR:
+ priv->editor = g_value_get_object (value);
+ return;
-/**
- * comp_editor_page_get_type:
- *
- * Registers the #CompEditorPage class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CompEditorPage class.
- **/
-GType
-comp_editor_page_get_type (void)
+ case PROP_UPDATING:
+ comp_editor_page_set_updating (
+ COMP_EDITOR_PAGE (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+comp_editor_page_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- static GType type = 0;
+ switch (property_id) {
+ case PROP_EDITOR:
+ g_value_set_object (
+ value, comp_editor_page_get_editor (
+ COMP_EDITOR_PAGE (object)));
+ return;
+
+ case PROP_UPDATING:
+ g_value_set_boolean (
+ value, comp_editor_page_get_updating (
+ COMP_EDITOR_PAGE (object)));
+ }
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (CompEditorPageClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) comp_editor_page_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (CompEditorPage),
- 0, /* n_preallocs */
- (GInstanceInitFunc) comp_editor_page_init,
- NULL /* value_table */
- };
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
- type = g_type_register_static (
- G_TYPE_OBJECT, "CompEditorPage", &type_info, 0);
+static void
+comp_editor_page_dispose (GObject *object)
+{
+ CompEditorPage *page;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_COMP_EDITOR_PAGE (object));
+
+ page = COMP_EDITOR_PAGE (object);
+
+ if (page->accel_group) {
+ g_object_unref (page->accel_group);
+ page->accel_group = NULL;
}
- return type;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
-/* Class initialization function for the abstract editor page */
static void
comp_editor_page_class_init (CompEditorPageClass *class)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (CompEditorPagePrivate));
object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = comp_editor_page_set_property;
+ object_class->get_property = comp_editor_page_get_property;
object_class->dispose = comp_editor_page_dispose;
- class->changed = NULL;
- class->summary_changed = NULL;
class->dates_changed = NULL;
class->get_widget = NULL;
@@ -108,35 +135,28 @@ comp_editor_page_class_init (CompEditorPageClass *class)
class->fill_widgets = NULL;
class->fill_component = NULL;
class->fill_timezones = NULL;
- class->set_summary = NULL;
class->set_dates = NULL;
- comp_editor_page_signals[CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CompEditorPageClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- comp_editor_page_signals[NEEDS_SEND] =
- g_signal_new ("needs_send",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CompEditorPageClass, needs_send),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- comp_editor_page_signals[SUMMARY_CHANGED] =
- g_signal_new ("summary_changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CompEditorPageClass, summary_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ g_object_class_install_property (
+ object_class,
+ PROP_EDITOR,
+ g_param_spec_object (
+ "editor",
+ NULL,
+ NULL,
+ TYPE_COMP_EDITOR,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_UPDATING,
+ g_param_spec_boolean (
+ "updating",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
comp_editor_page_signals[DATES_CHANGED] =
g_signal_new ("dates_changed",
@@ -146,66 +166,57 @@ comp_editor_page_class_init (CompEditorPageClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- comp_editor_page_signals[CLIENT_CHANGED] =
- g_signal_new ("client_changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CompEditorPageClass, client_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
- comp_editor_page_signals[FOCUS_IN] =
- g_signal_new ("focus_in",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CompEditorPageClass, focus_in),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- comp_editor_page_signals[FOCUS_OUT] =
- g_signal_new ("focus_out",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CompEditorPageClass, focus_out),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
}
-
-
static void
comp_editor_page_init (CompEditorPage *page)
{
- page->client = NULL;
+ page->priv = COMP_EDITOR_PAGE_GET_PRIVATE (page);
+
page->accel_group = NULL;
}
-
-static void
-comp_editor_page_dispose (GObject *object)
+GType
+comp_editor_page_get_type (void)
{
- CompEditorPage *page;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (object));
-
- page = COMP_EDITOR_PAGE (object);
+ static GType type = 0;
- if (page->client) {
- g_object_unref (page->client);
- page->client = NULL;
- }
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (CompEditorPageClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) comp_editor_page_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (CompEditorPage),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) comp_editor_page_init,
+ NULL /* value_table */
+ };
- if (page->accel_group) {
- g_object_unref (page->accel_group);
- page->accel_group = NULL;
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "CompEditorPage", &type_info, 0);
}
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ return type;
}
+/**
+ * comp_editor_page_get_editor:
+ * @page: a #CompEditorPage
+ *
+ * Returns the #CompEditor to which @page belongs.
+ *
+ * Returns: the parent #CompEditor
+ **/
+CompEditor *
+comp_editor_page_get_editor (CompEditorPage *page)
+{
+ g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), NULL);
+
+ return page->priv->editor;
+}
/**
* comp_editor_page_get_widget:
@@ -219,11 +230,50 @@ comp_editor_page_dispose (GObject *object)
GtkWidget *
comp_editor_page_get_widget (CompEditorPage *page)
{
- g_return_val_if_fail (page != NULL, NULL);
+ CompEditorPageClass *class;
+
g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), NULL);
- g_return_val_if_fail (CLASS (page)->get_widget != NULL, NULL);
- return (* CLASS (page)->get_widget) (page);
+ class = COMP_EDITOR_PAGE_GET_CLASS (page);
+ g_return_val_if_fail (class->get_widget != NULL, NULL);
+
+ return class->get_widget (page);
+}
+
+gboolean
+comp_editor_page_get_updating (CompEditorPage *page)
+{
+ g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), FALSE);
+
+ return page->priv->updating;
+}
+
+void
+comp_editor_page_set_updating (CompEditorPage *page,
+ gboolean updating)
+{
+ g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
+
+ page->priv->updating = updating;
+
+ g_object_notify (G_OBJECT (page), "updating");
+}
+
+void
+comp_editor_page_changed (CompEditorPage *page)
+{
+ CompEditor *editor;
+
+ g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
+
+ /* Block change notifications if the page is updating. This right
+ * here is why we have an 'updating' flag. It's up to subclasses
+ * to set and clear it at appropriate times. */
+ if (page->priv->updating)
+ return;
+
+ editor = comp_editor_page_get_editor (page);
+ comp_editor_set_changed (editor, TRUE);
}
/**
@@ -237,11 +287,14 @@ comp_editor_page_get_widget (CompEditorPage *page)
void
comp_editor_page_focus_main_widget (CompEditorPage *page)
{
- g_return_if_fail (page != NULL);
+ CompEditorPageClass *class;
+
g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
- g_return_if_fail (CLASS (page)->focus_main_widget != NULL);
- (* CLASS (page)->focus_main_widget) (page);
+ class = COMP_EDITOR_PAGE_GET_CLASS (page);
+ g_return_if_fail (class->focus_main_widget != NULL);
+
+ class->focus_main_widget (page);
}
/**
@@ -252,13 +305,23 @@ comp_editor_page_focus_main_widget (CompEditorPage *page)
* Fills the widgets of an editor page with the data from a calendar component.
**/
gboolean
-comp_editor_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
+comp_editor_page_fill_widgets (CompEditorPage *page,
+ ECalComponent *comp)
{
+ CompEditorPageClass *class;
+ gboolean success;
+
g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), FALSE);
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE);
- g_return_val_if_fail (CLASS (page)->fill_widgets != NULL, FALSE);
- return (* CLASS (page)->fill_widgets) (page, comp);
+ class = COMP_EDITOR_PAGE_GET_CLASS (page);
+ g_return_val_if_fail (class->fill_widgets != NULL, FALSE);
+
+ comp_editor_page_set_updating (page, TRUE);
+ success = class->fill_widgets (page, comp);
+ comp_editor_page_set_updating (page, FALSE);
+
+ return success;
}
/**
@@ -275,12 +338,15 @@ comp_editor_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
gboolean
comp_editor_page_fill_component (CompEditorPage *page, ECalComponent *comp)
{
- g_return_val_if_fail (page != NULL, FALSE);
+ CompEditorPageClass *class;
+
g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), FALSE);
g_return_val_if_fail (comp != NULL, FALSE);
- if (CLASS (page)->fill_component != NULL)
- return (* CLASS (page)->fill_component) (page, comp);
+ class = COMP_EDITOR_PAGE_GET_CLASS (page);
+
+ if (class->fill_component != NULL)
+ return class->fill_component (page, comp);
return TRUE;
}
@@ -298,90 +364,20 @@ comp_editor_page_fill_component (CompEditorPage *page, ECalComponent *comp)
gboolean
comp_editor_page_fill_timezones (CompEditorPage *page, GHashTable *timezones)
{
+ CompEditorPageClass *class;
+
g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), FALSE);
g_return_val_if_fail (timezones != NULL, FALSE);
- if (CLASS (page)->fill_timezones != NULL)
- return (* CLASS (page)->fill_timezones) (page, timezones);
-
- return TRUE;
-}
-
-/**
- * comp_editor_page_set_e_cal:
- * @page: An editor page
- * @client: A #ECal object
- *
- * Sets the #ECal for the dialog page to use.
- **/
-void
-comp_editor_page_set_e_cal (CompEditorPage *page, ECal *client)
-{
- g_return_if_fail (page != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
-
- if (client == page->client)
- return;
-
- if (page->client)
- g_object_unref (page->client);
-
- page->client = client;
- if (page->client)
- g_object_ref (client);
-}
-
-/**
- * comp_editor_page_set_summary:
- * @page: An editor page
- * @summary: The text of the new summary value
- *
- * Sets the summary value for this group of widgets
- **/
-void
-comp_editor_page_set_summary (CompEditorPage *page, const char *summary)
-{
- g_return_if_fail (page != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
-
- if (CLASS (page)->set_summary != NULL)
- (* CLASS (page)->set_summary) (page, summary);
-}
-
-/**
- * comp_editor_page_unset_focused_widget
- * @page: An editor page
- * @widget: The widget that has the current focus
-**/
-void
-comp_editor_page_unset_focused_widget (CompEditorPage *page, GtkWidget *widget)
-{
- g_return_if_fail (page!= NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
+ class = COMP_EDITOR_PAGE_GET_CLASS (page);
- g_signal_emit (page,
- comp_editor_page_signals[FOCUS_OUT], 0,
- widget);
+ if (class->fill_timezones != NULL)
+ return class->fill_timezones (page, timezones);
+ return TRUE;
}
/**
- * comp_editor_page_set_focussed_widget:
- * @page: An editor page
- * @widget: The widget that has the current focus
-**/
-void
-comp_editor_page_set_focused_widget (CompEditorPage *page, GtkWidget *widget)
-{
- g_return_if_fail (page!= NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
-
- g_signal_emit (page,
- comp_editor_page_signals[FOCUS_IN], 0,
- widget);
-
-}
-/**
* comp_editor_page_set_dates:
* @page: An editor page
* @dates: A collection of various dates in time_t format
@@ -391,62 +387,14 @@ comp_editor_page_set_focused_widget (CompEditorPage *page, GtkWidget *widget)
void
comp_editor_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates)
{
- g_return_if_fail (page != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
-
- if (CLASS (page)->set_dates != NULL)
- (* CLASS (page)->set_dates) (page, dates);
-}
-
-/**
- * comp_editor_page_notify_changed:
- * @page: An editor page.
- *
- * Makes an editor page emit the "changed" signal. This is meant to be
- * used only by page implementations.
- **/
-void
-comp_editor_page_notify_changed (CompEditorPage *page)
-{
- g_return_if_fail (page != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
-
- g_signal_emit (page, comp_editor_page_signals[CHANGED], 0);
-}
-
-/**
- * comp_editor_page_notify_needs_send:
- * @page:
- *
- *
- **/
-void
-comp_editor_page_notify_needs_send (CompEditorPage *page)
-{
- g_return_if_fail (page != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
+ CompEditorPageClass *class;
- g_signal_emit (page, comp_editor_page_signals[NEEDS_SEND], 0);
-}
-
-/**
- * comp_editor_page_notify_summary_changed:
- * @page: An editor page.
- *
- * Makes an editor page emit the "summary_changed" signal. This is meant to be
- * used only by page implementations.
- **/
-void
-comp_editor_page_notify_summary_changed (CompEditorPage *page,
- const char *summary)
-{
- g_return_if_fail (page != NULL);
g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
+ class = COMP_EDITOR_PAGE_GET_CLASS (page);
- g_signal_emit (page,
- comp_editor_page_signals[SUMMARY_CHANGED], 0,
- summary);
+ if (class->set_dates != NULL)
+ class->set_dates (page, dates);
}
/**
@@ -460,7 +408,6 @@ void
comp_editor_page_notify_dates_changed (CompEditorPage *page,
CompEditorPageDates *dates)
{
- g_return_if_fail (page != NULL);
g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
g_signal_emit (page,
@@ -469,26 +416,6 @@ comp_editor_page_notify_dates_changed (CompEditorPage *page,
}
/**
- * comp_editor_page_notify_client_changed:
- * @page: An editor page.
- *
- * Makes an editor page emit the "client_changed" signal. This is meant to be
- * used only by page implementations.
- **/
-void
-comp_editor_page_notify_client_changed (CompEditorPage *page,
- ECal *client)
-{
- g_return_if_fail (page != NULL);
- g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
-
- comp_editor_page_set_e_cal (page, client);
- g_signal_emit (page,
- comp_editor_page_signals[CLIENT_CHANGED], 0,
- client);
-}
-
-/**
* comp_editor_page_display_validation_error:
* @page: An editor page.
* @msg: Error message to display.