From 6af1b3178dcf5e3271f6be4d785c28cbe9043404 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 10 Mar 2010 17:29:50 -0500 Subject: Clean up GalView and related classes. --- .../gui/widgets/gal-view-factory-minicard.c | 52 ++--- .../gui/widgets/gal-view-factory-minicard.h | 52 +++-- addressbook/gui/widgets/gal-view-minicard.c | 2 +- calendar/gui/calendar-view-factory.c | 2 +- calendar/gui/calendar-view.c | 2 +- widgets/menus/gal-define-views-dialog.c | 2 +- widgets/menus/gal-define-views-dialog.h | 54 ++--- widgets/menus/gal-view-collection.c | 2 +- widgets/menus/gal-view-etable.c | 22 +- widgets/menus/gal-view-etable.h | 81 +++++--- widgets/menus/gal-view-factory-etable.c | 176 +++++++++++----- widgets/menus/gal-view-factory-etable.h | 57 ++++-- widgets/menus/gal-view-factory.c | 88 ++++---- widgets/menus/gal-view-factory.h | 70 ++++--- widgets/menus/gal-view-instance-save-as-dialog.c | 2 +- widgets/menus/gal-view-instance-save-as-dialog.h | 56 ++--- widgets/menus/gal-view-instance.c | 2 +- widgets/menus/gal-view-new-dialog.c | 2 +- widgets/menus/gal-view.c | 228 ++++++++++++++------- widgets/menus/gal-view.h | 111 +++++----- widgets/table/e-table-specification.c | 2 +- widgets/table/e-table-specification.h | 12 +- widgets/table/e-table-state.c | 14 +- 23 files changed, 658 insertions(+), 433 deletions(-) diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.c b/addressbook/gui/widgets/gal-view-factory-minicard.c index ee61207855..d5804b18d9 100644 --- a/addressbook/gui/widgets/gal-view-factory-minicard.c +++ b/addressbook/gui/widgets/gal-view-factory-minicard.c @@ -29,39 +29,42 @@ #include "gal-view-factory-minicard.h" #include "gal-view-minicard.h" -G_DEFINE_TYPE (GalViewFactoryMinicard, gal_view_factory_minicard, GAL_VIEW_FACTORY_TYPE) +G_DEFINE_TYPE ( + GalViewFactoryMinicard, + gal_view_factory_minicard, GAL_TYPE_VIEW_FACTORY) static const gchar * -gal_view_factory_minicard_get_title (GalViewFactory *factory) +gal_view_factory_minicard_get_title (GalViewFactory *factory) { return _("Card View"); } -static GalView * -gal_view_factory_minicard_new_view (GalViewFactory *factory, - const gchar *name) -{ - return gal_view_minicard_new(name); -} - static const gchar * gal_view_factory_minicard_get_type_code (GalViewFactory *factory) { return "minicard"; } +static GalView * +gal_view_factory_minicard_new_view (GalViewFactory *factory, + const gchar *name) +{ + return gal_view_minicard_new (name); +} + static void -gal_view_factory_minicard_class_init (GalViewFactoryMinicardClass *minicard_class) +gal_view_factory_minicard_class_init (GalViewFactoryMinicardClass *minicard_class) { - GalViewFactoryClass *view_factory_class = GAL_VIEW_FACTORY_CLASS(minicard_class); + GalViewFactoryClass *view_factory_class; - view_factory_class->get_title = gal_view_factory_minicard_get_title; - view_factory_class->new_view = gal_view_factory_minicard_new_view; - view_factory_class->get_type_code = gal_view_factory_minicard_get_type_code; + view_factory_class = GAL_VIEW_FACTORY_CLASS (minicard_class); + view_factory_class->get_title = gal_view_factory_minicard_get_title; + view_factory_class->get_type_code = gal_view_factory_minicard_get_type_code; + view_factory_class->new_view = gal_view_factory_minicard_new_view; } static void -gal_view_factory_minicard_init (GalViewFactoryMinicard *factory) +gal_view_factory_minicard_init (GalViewFactoryMinicard *factory) { } @@ -74,23 +77,8 @@ gal_view_factory_minicard_init (GalViewFactoryMinicard *factory) * Returns: The new GalViewFactoryMinicard. */ GalViewFactory * -gal_view_factory_minicard_new (void) -{ - return gal_view_factory_minicard_construct (g_object_new (GAL_TYPE_VIEW_FACTORY_MINICARD, NULL)); -} - -/** - * gal_view_minicard_construct - * @factory: The factory to construct - * - * constructs the GalViewFactoryMinicard. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewFactoryMinicard. - */ -GalViewFactory * -gal_view_factory_minicard_construct (GalViewFactoryMinicard *factory) +gal_view_factory_minicard_new (void) { - return GAL_VIEW_FACTORY(factory); + return g_object_new (GAL_TYPE_VIEW_FACTORY_MINICARD, NULL); } diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.h b/addressbook/gui/widgets/gal-view-factory-minicard.h index 0aa6dc5ba9..aa27bf9a27 100644 --- a/addressbook/gui/widgets/gal-view-factory-minicard.h +++ b/addressbook/gui/widgets/gal-view-factory-minicard.h @@ -23,29 +23,47 @@ * */ -#ifndef _GAL_VIEW_FACTORY_MINICARD_H_ -#define _GAL_VIEW_FACTORY_MINICARD_H_ +#ifndef GAL_VIEW_FACTORY_MINICARD_H +#define GAL_VIEW_FACTORY_MINICARD_H #include #include -#define GAL_TYPE_VIEW_FACTORY_MINICARD (gal_view_factory_minicard_get_type ()) -#define GAL_VIEW_FACTORY_MINICARD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicard)) -#define GAL_VIEW_FACTORY_MINICARD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicardClass)) -#define GAL_IS_VIEW_FACTORY_MINICARD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_TYPE_VIEW_FACTORY_MINICARD)) -#define GAL_IS_VIEW_FACTORY_MINICARD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_TYPE_VIEW_FACTORY_MINICARD)) +/* Standard GObject macros */ +#define GAL_TYPE_VIEW_FACTORY_MINICARD \ + (gal_view_factory_minicard_get_type ()) +#define GAL_VIEW_FACTORY_MINICARD(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicard)) +#define GAL_VIEW_FACTORY_MINICARD_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicardClass)) +#define GAL_IS_VIEW_FACTORY_MINICARD(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_VIEW_FACTORY_MINICARD)) +#define GAL_IS_VIEW_FACTORY_MINICARD_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_VIEW_FACTORY_MINICARD)) +#define GAL_VIEW_FACTORY_MINICARD_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicardClass)) -typedef struct { - GalViewFactory base; -} GalViewFactoryMinicard; +G_BEGIN_DECLS -typedef struct { +typedef struct _GalViewFactoryMinicard GalViewFactoryMinicard; +typedef struct _GalViewFactoryMinicardClass GalViewFactoryMinicardClass; + +struct _GalViewFactoryMinicard { + GalViewFactory parent; +}; + +struct _GalViewFactoryMinicardClass { GalViewFactoryClass parent_class; -} GalViewFactoryMinicardClass; +}; + +GType gal_view_factory_minicard_get_type (void); +GalViewFactory *gal_view_factory_minicard_new (void); -/* Standard functions */ -GType gal_view_factory_minicard_get_type (void); -GalViewFactory *gal_view_factory_minicard_new (void); -GalViewFactory *gal_view_factory_minicard_construct (GalViewFactoryMinicard *factory); +G_END_DECLS -#endif /* _GAL_VIEW_FACTORY_MINICARD_H_ */ +#endif /* GAL_VIEW_FACTORY_MINICARD_H */ diff --git a/addressbook/gui/widgets/gal-view-minicard.c b/addressbook/gui/widgets/gal-view-minicard.c index a40cd8420f..e5fe93d380 100644 --- a/addressbook/gui/widgets/gal-view-minicard.c +++ b/addressbook/gui/widgets/gal-view-minicard.c @@ -201,7 +201,7 @@ gal_view_minicard_get_type (void) }; type = g_type_register_static ( - GAL_VIEW_TYPE, "GalViewMinicard", &type_info, 0); + GAL_TYPE_VIEW, "GalViewMinicard", &type_info, 0); } return type; diff --git a/calendar/gui/calendar-view-factory.c b/calendar/gui/calendar-view-factory.c index fb48a5559a..16f2790cfe 100644 --- a/calendar/gui/calendar-view-factory.c +++ b/calendar/gui/calendar-view-factory.c @@ -51,7 +51,7 @@ static GalView * calendar_view_factory_new_view (GalViewFactory *factory, const gchar *name); -G_DEFINE_TYPE (CalendarViewFactory, calendar_view_factory, GAL_VIEW_FACTORY_TYPE) +G_DEFINE_TYPE (CalendarViewFactory, calendar_view_factory, GAL_TYPE_VIEW_FACTORY) /* Class initialization function for the calendar view factory */ static void diff --git a/calendar/gui/calendar-view.c b/calendar/gui/calendar-view.c index b316771ca1..0687fe9817 100644 --- a/calendar/gui/calendar-view.c +++ b/calendar/gui/calendar-view.c @@ -50,7 +50,7 @@ static void calendar_view_set_title (GalView *view, const gchar *title); static const gchar *calendar_view_get_type_code (GalView *view); static GalView *calendar_view_clone (GalView *view); -G_DEFINE_TYPE (CalendarView, calendar_view, GAL_VIEW_TYPE) +G_DEFINE_TYPE (CalendarView, calendar_view, GAL_TYPE_VIEW) /* Class initialization function for the calendar view */ static void diff --git a/widgets/menus/gal-define-views-dialog.c b/widgets/menus/gal-define-views-dialog.c index c63456d620..34c20be18a 100644 --- a/widgets/menus/gal-define-views-dialog.c +++ b/widgets/menus/gal-define-views-dialog.c @@ -350,7 +350,7 @@ gal_define_views_dialog_set_collection(GalDefineViewsDialog *dialog, GtkWidget* gal_define_views_dialog_new (GalViewCollection *collection) { - GtkWidget *widget = g_object_new (GAL_DEFINE_VIEWS_DIALOG_TYPE, NULL); + GtkWidget *widget = g_object_new (GAL_TYPE_DEFINE_VIEWS_DIALOG, NULL); gal_define_views_dialog_set_collection (GAL_DEFINE_VIEWS_DIALOG (widget), collection); return widget; } diff --git a/widgets/menus/gal-define-views-dialog.h b/widgets/menus/gal-define-views-dialog.h index c4b79a7834..da214af36a 100644 --- a/widgets/menus/gal-define-views-dialog.h +++ b/widgets/menus/gal-define-views-dialog.h @@ -20,34 +20,37 @@ * */ -#ifndef __GAL_DEFINE_VIEWS_DIALOG_H__ -#define __GAL_DEFINE_VIEWS_DIALOG_H__ +#ifndef GAL_DEFINE_VIEWS_DIALOG_H +#define GAL_DEFINE_VIEWS_DIALOG_H #include +#include -#include +/* Standard GObject macros */ +#define GAL_TYPE_DEFINE_VIEWS_DIALOG \ + (gal_define_views_dialog_get_type ()) +#define GAL_DEFINE_VIEWS_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_DEFINE_VIEWS_DIALOG, GalDefineViewsDialog)) +#define GAL_DEFINE_VIEWS_DIALOG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_DEFINE_VIEWS_DIALOG, GalDefineViewsDialogClass)) +#define GAL_IS_DEFINE_VIEWS_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_DEFINE_VIEWS_DIALOG)) +#define GAL_IS_DEFINE_VIEWS_DIALOG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_DEFINE_VIEWS_DIALOG)) +#define GAL_DEFINE_VIEWS_DIALOG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_DEFINE_VIEWS_DIALOG, GalDefineViewsDialogClass)) G_BEGIN_DECLS -/* GalDefineViewsDialog - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define GAL_DEFINE_VIEWS_DIALOG_TYPE (gal_define_views_dialog_get_type ()) -#define GAL_DEFINE_VIEWS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_DEFINE_VIEWS_DIALOG_TYPE, GalDefineViewsDialog)) -#define GAL_DEFINE_VIEWS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_DEFINE_VIEWS_DIALOG_TYPE, GalDefineViewsDialogClass)) -#define GAL_IS_DEFINE_VIEWS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_DEFINE_VIEWS_DIALOG_TYPE)) -#define GAL_IS_DEFINE_VIEWS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GAL_DEFINE_VIEWS_DIALOG_TYPE)) - -typedef struct _GalDefineViewsDialog GalDefineViewsDialog; -typedef struct _GalDefineViewsDialogClass GalDefineViewsDialogClass; +typedef struct _GalDefineViewsDialog GalDefineViewsDialog; +typedef struct _GalDefineViewsDialogClass GalDefineViewsDialogClass; -struct _GalDefineViewsDialog -{ +struct _GalDefineViewsDialog { GtkDialog parent; /* item specific fields */ @@ -58,14 +61,13 @@ struct _GalDefineViewsDialog GalViewCollection *collection; }; -struct _GalDefineViewsDialogClass -{ +struct _GalDefineViewsDialogClass { GtkDialogClass parent_class; }; -GtkWidget *gal_define_views_dialog_new (GalViewCollection *collection); -GType gal_define_views_dialog_get_type (void); +GType gal_define_views_dialog_get_type(void); +GtkWidget * gal_define_views_dialog_new (GalViewCollection *collection); G_END_DECLS -#endif /* __GAL_DEFINE_VIEWS_DIALOG_H__ */ +#endif /* GAL_DEFINE_VIEWS_DIALOG_H */ diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c index 5719e17f6b..e2b97c4771 100644 --- a/widgets/menus/gal-view-collection.c +++ b/widgets/menus/gal-view-collection.c @@ -205,7 +205,7 @@ gal_view_collection_class_init (GalViewCollectionClass *klass) G_STRUCT_OFFSET (GalViewCollectionClass, display_view), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, GAL_VIEW_TYPE); + G_TYPE_NONE, 1, GAL_TYPE_VIEW); gal_view_collection_signals [CHANGED] = g_signal_new ("changed", diff --git a/widgets/menus/gal-view-etable.c b/widgets/menus/gal-view-etable.c index b264524c71..977d58b627 100644 --- a/widgets/menus/gal-view-etable.c +++ b/widgets/menus/gal-view-etable.c @@ -26,7 +26,7 @@ #include "gal-view-etable.h" -G_DEFINE_TYPE (GalViewEtable, gal_view_etable, GAL_VIEW_TYPE) +G_DEFINE_TYPE (GalViewEtable, gal_view_etable, GAL_TYPE_VIEW) static void detach_table (GalViewEtable *view) @@ -127,7 +127,7 @@ gal_view_etable_clone (GalView *view) gve = GAL_VIEW_ETABLE(view); - new = g_object_new (GAL_VIEW_ETABLE_TYPE, NULL); + new = g_object_new (GAL_TYPE_VIEW_ETABLE, NULL); new->spec = gve->spec; new->title = g_strdup (gve->title); new->state = e_table_state_duplicate(gve->state); @@ -200,7 +200,9 @@ gal_view_etable_new (ETableSpecification *spec, { GalViewEtable *view; - view = g_object_new (GAL_VIEW_ETABLE_TYPE, NULL); + g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL); + + view = g_object_new (GAL_TYPE_VIEW_ETABLE, NULL); return gal_view_etable_construct (view, spec, title); } @@ -221,6 +223,9 @@ gal_view_etable_construct (GalViewEtable *view, ETableSpecification *spec, const gchar *title) { + g_return_val_if_fail (GAL_IS_VIEW_ETABLE (view), NULL); + g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL); + if (spec) g_object_ref(spec); view->spec = spec; @@ -237,6 +242,9 @@ gal_view_etable_construct (GalViewEtable *view, void gal_view_etable_set_state (GalViewEtable *view, ETableState *state) { + g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); + g_return_if_fail (E_IS_TABLE_STATE (state)); + if (view->state) g_object_unref(view->state); view->state = e_table_state_duplicate(state); @@ -271,6 +279,9 @@ tree_state_changed (ETree *tree, GalViewEtable *view) void gal_view_etable_attach_table (GalViewEtable *view, ETable *table) { + g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); + g_return_if_fail (E_IS_TABLE (table)); + gal_view_etable_detach (view); view->table = table; @@ -285,6 +296,9 @@ gal_view_etable_attach_table (GalViewEtable *view, ETable *table) void gal_view_etable_attach_tree (GalViewEtable *view, ETree *tree) { + g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); + g_return_if_fail (E_IS_TREE (tree)); + gal_view_etable_detach (view); view->tree = tree; @@ -299,6 +313,8 @@ gal_view_etable_attach_tree (GalViewEtable *view, ETree *tree) void gal_view_etable_detach (GalViewEtable *view) { + g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); + if (view->table != NULL) detach_table (view); if (view->tree != NULL) diff --git a/widgets/menus/gal-view-etable.h b/widgets/menus/gal-view-etable.h index 4ae1d3e9b0..cfccf1e15b 100644 --- a/widgets/menus/gal-view-etable.h +++ b/widgets/menus/gal-view-etable.h @@ -21,8 +21,8 @@ * */ -#ifndef _GAL_VIEW_ETABLE_H_ -#define _GAL_VIEW_ETABLE_H_ +#ifndef GAL_VIEW_ETABLE_H +#define GAL_VIEW_ETABLE_H #include #include @@ -31,47 +31,62 @@ #include #include
+/* Standard GObject macros */ +#define GAL_TYPE_VIEW_ETABLE \ + (gal_view_etable_get_type ()) +#define GAL_VIEW_ETABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_VIEW_ETABLE, GalViewEtable)) +#define GAL_VIEW_ETABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_VIEW_ETABLE, GalViewEtableClass)) +#define GAL_IS_VIEW_ETABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_VIEW_ETABLE)) +#define GAL_IS_VIEW_ETABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_VIEW_ETABLE)) +#define GAL_VIEW_ETABLE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_VIEW_ETABLE, GalViewEtableClass)) + G_BEGIN_DECLS -#define GAL_VIEW_ETABLE_TYPE (gal_view_etable_get_type ()) -#define GAL_VIEW_ETABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_VIEW_ETABLE_TYPE, GalViewEtable)) -#define GAL_VIEW_ETABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_VIEW_ETABLE_TYPE, GalViewEtableClass)) -#define GAL_IS_VIEW_ETABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_VIEW_ETABLE_TYPE)) -#define GAL_IS_VIEW_ETABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_VIEW_ETABLE_TYPE)) +typedef struct _GalViewEtable GalViewEtable; +typedef struct _GalViewEtableClass GalViewEtableClass; -typedef struct { - GalView base; +struct _GalViewEtable { + GalView parent; ETableSpecification *spec; - ETableState *state; - gchar *title; + ETableState *state; + gchar *title; - ETable *table; - guint table_state_changed_id; + ETable *table; + guint table_state_changed_id; - ETree *tree; - guint tree_state_changed_id; -} GalViewEtable; + ETree *tree; + guint tree_state_changed_id; +}; -typedef struct { +struct _GalViewEtableClass { GalViewClass parent_class; -} GalViewEtableClass; +}; -/* Standard functions */ -GType gal_view_etable_get_type (void); -GalView *gal_view_etable_new (ETableSpecification *spec, - const gchar *title); -GalView *gal_view_etable_construct (GalViewEtable *view, - ETableSpecification *spec, - const gchar *title); -void gal_view_etable_set_state (GalViewEtable *view, - ETableState *state); -void gal_view_etable_attach_table (GalViewEtable *view, - ETable *table); -void gal_view_etable_attach_tree (GalViewEtable *view, - ETree *tree); -void gal_view_etable_detach (GalViewEtable *view); +GType gal_view_etable_get_type (void); +GalView * gal_view_etable_new (ETableSpecification *spec, + const gchar *title); +GalView * gal_view_etable_construct (GalViewEtable *view, + ETableSpecification *spec, + const gchar *title); +void gal_view_etable_set_state (GalViewEtable *view, + ETableState *state); +void gal_view_etable_attach_table (GalViewEtable *view, + ETable *table); +void gal_view_etable_attach_tree (GalViewEtable *view, + ETree *tree); +void gal_view_etable_detach (GalViewEtable *view); G_END_DECLS -#endif /* _GAL_VIEW_ETABLE_H_ */ +#endif /* GAL_VIEW_ETABLE_H */ diff --git a/widgets/menus/gal-view-factory-etable.c b/widgets/menus/gal-view-factory-etable.c index 3eb9d99d57..1969d333bb 100644 --- a/widgets/menus/gal-view-factory-etable.c +++ b/widgets/menus/gal-view-factory-etable.c @@ -29,62 +29,146 @@ #include "gal-view-etable.h" #include "gal-view-factory-etable.h" -G_DEFINE_TYPE (GalViewFactoryEtable, gal_view_factory_etable, GAL_VIEW_FACTORY_TYPE) +#define GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtablePrivate)) -static const gchar * -gal_view_factory_etable_get_title (GalViewFactory *factory) +struct _GalViewFactoryEtablePrivate { + ETableSpecification *specification; +}; + +enum { + PROP_0, + PROP_SPECIFICATION +}; + +G_DEFINE_TYPE ( + GalViewFactoryEtable, + gal_view_factory_etable, GAL_TYPE_VIEW_FACTORY) + +static void +view_factory_etable_set_specification (GalViewFactoryEtable *factory, + ETableSpecification *specification) { - return _("Table"); + g_return_if_fail (factory->priv->specification == NULL); + g_return_if_fail (E_IS_TABLE_SPECIFICATION (specification)); + + factory->priv->specification = g_object_ref (specification); } -static GalView * -gal_view_factory_etable_new_view (GalViewFactory *factory, - const gchar *name) +static void +view_factory_etable_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - return gal_view_etable_new(GAL_VIEW_FACTORY_ETABLE(factory)->spec, name); + switch (property_id) { + case PROP_SPECIFICATION: + view_factory_etable_set_specification ( + GAL_VIEW_FACTORY_ETABLE (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } -static const gchar * -gal_view_factory_etable_get_type_code (GalViewFactory *factory) +static void +view_factory_etable_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - return "etable"; + switch (property_id) { + case PROP_SPECIFICATION: + g_value_set_object ( + value, + gal_view_factory_etable_get_specification ( + GAL_VIEW_FACTORY_ETABLE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -gal_view_factory_etable_dispose (GObject *object) +view_factory_etable_dispose (GObject *object) { - GalViewFactoryEtable *factory = GAL_VIEW_FACTORY_ETABLE(object); + GalViewFactoryEtablePrivate *priv; + + priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (object); - if (factory->spec) - g_object_unref(factory->spec); - factory->spec = NULL; + if (priv->specification != NULL) { + g_object_unref (priv->specification); + priv->specification = NULL; + } - if (G_OBJECT_CLASS (gal_view_factory_etable_parent_class)->dispose) - (* G_OBJECT_CLASS (gal_view_factory_etable_parent_class)->dispose) (object); + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (gal_view_factory_etable_parent_class)->dispose (object); } -static void -gal_view_factory_etable_class_init (GalViewFactoryEtableClass *klass) +static const gchar * +view_factory_etable_get_title (GalViewFactory *factory) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GalViewFactoryClass *view_factory_class = GAL_VIEW_FACTORY_CLASS (klass); + return _("Table"); +} - view_factory_class->get_title = gal_view_factory_etable_get_title; - view_factory_class->new_view = gal_view_factory_etable_new_view; - view_factory_class->get_type_code = gal_view_factory_etable_get_type_code; +static const gchar * +view_factory_etable_get_type_code (GalViewFactory *factory) +{ + return "etable"; +} + +static GalView * +view_factory_etable_new_view (GalViewFactory *factory, + const gchar *name) +{ + GalViewFactoryEtablePrivate *priv; - object_class->dispose = gal_view_factory_etable_dispose; + priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (factory); + + return gal_view_etable_new (priv->specification, name); +} + +static void +gal_view_factory_etable_class_init (GalViewFactoryEtableClass *class) +{ + GObjectClass *object_class; + GalViewFactoryClass *view_factory_class; + + g_type_class_add_private (class, sizeof (GalViewFactoryEtablePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = view_factory_etable_set_property; + object_class->get_property = view_factory_etable_get_property; + object_class->dispose = view_factory_etable_dispose; + + view_factory_class = GAL_VIEW_FACTORY_CLASS (class); + view_factory_class->get_title = view_factory_etable_get_title; + view_factory_class->get_type_code = view_factory_etable_get_type_code; + view_factory_class->new_view = view_factory_etable_new_view; + + g_object_class_install_property ( + object_class, + PROP_SPECIFICATION, + g_param_spec_object ( + "specification", + NULL, + NULL, + E_TYPE_TABLE_SPECIFICATION, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); } static void -gal_view_factory_etable_init (GalViewFactoryEtable *factory) +gal_view_factory_etable_init (GalViewFactoryEtable *factory) { - factory->spec = NULL; + factory->priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (factory); } /** - * gal_view_etable_new - * @spec: The spec to create GalViewEtables based upon. + * gal_view_etable_new: + * @specification: The spec to create GalViewEtables based upon. * * A new GalViewFactory for creating ETable views. Create one of * these and pass it to GalViewCollection for use. @@ -92,29 +176,19 @@ gal_view_factory_etable_init (GalViewFactoryEtable *factory) * Returns: The new GalViewFactoryEtable. */ GalViewFactory * -gal_view_factory_etable_new (ETableSpecification *spec) +gal_view_factory_etable_new (ETableSpecification *specification) { - return gal_view_factory_etable_construct ( - g_object_new (GAL_VIEW_FACTORY_ETABLE_TYPE, NULL), spec); + g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (specification), NULL); + + return g_object_new ( + GAL_TYPE_VIEW_FACTORY_ETABLE, + "specification", specification, NULL); } -/** - * gal_view_etable_construct - * @factory: The factory to construct - * @spec: The spec to create GalViewEtables based upon. - * - * constructs the GalViewFactoryEtable. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewFactoryEtable. - */ -GalViewFactory * -gal_view_factory_etable_construct (GalViewFactoryEtable *factory, - ETableSpecification *spec) +ETableSpecification * +gal_view_factory_etable_get_specification (GalViewFactoryEtable *factory) { - if (spec) - g_object_ref(spec); - factory->spec = spec; - return GAL_VIEW_FACTORY(factory); -} + g_return_val_if_fail (GAL_IS_VIEW_FACTORY_ETABLE (factory), NULL); + return factory->priv->specification; +} diff --git a/widgets/menus/gal-view-factory-etable.h b/widgets/menus/gal-view-factory-etable.h index d4d39c7fe3..79aaa161e9 100644 --- a/widgets/menus/gal-view-factory-etable.h +++ b/widgets/menus/gal-view-factory-etable.h @@ -21,38 +21,53 @@ * */ -#ifndef _GAL_VIEW_FACTORY_ETABLE_H_ -#define _GAL_VIEW_FACTORY_ETABLE_H_ +#ifndef GAL_VIEW_FACTORY_ETABLE_H +#define GAL_VIEW_FACTORY_ETABLE_H #include #include #include
-G_BEGIN_DECLS +/* Standard GObject macros */ +#define GAL_TYPE_VIEW_FACTORY_ETABLE \ + (gal_view_factory_etable_get_type ()) +#define GAL_VIEW_FACTORY_ETABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtable)) +#define GAL_VIEW_FACTORY_ETABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtableClass)) +#define GAL_IS_VIEW_FACTORY_ETABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE)) +#define GAL_IS_VIEW_FACTORY_ETABLE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_VIEW_FACTORY_ETABLE)) +#define GAL_VIEW_FACTORY_ETABLE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtableClass)) -#define GAL_VIEW_FACTORY_ETABLE_TYPE (gal_view_factory_etable_get_type ()) -#define GAL_VIEW_FACTORY_ETABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_VIEW_FACTORY_ETABLE_TYPE, GalViewFactoryEtable)) -#define GAL_VIEW_FACTORY_ETABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_VIEW_FACTORY_ETABLE_TYPE, GalViewFactoryEtableClass)) -#define GAL_IS_VIEW_FACTORY_ETABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_VIEW_FACTORY_ETABLE_TYPE)) -#define GAL_IS_VIEW_FACTORY_ETABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_VIEW_FACTORY_ETABLE_TYPE)) -#define GAL_VIEW_FACTORY_ETABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GAL_VIEW_FACTORY_ETABLE_TYPE, GalViewFactoryEtableClass)) +G_BEGIN_DECLS -typedef struct { - GalViewFactory base; +typedef struct _GalViewFactoryEtable GalViewFactoryEtable; +typedef struct _GalViewFactoryEtableClass GalViewFactoryEtableClass; +typedef struct _GalViewFactoryEtablePrivate GalViewFactoryEtablePrivate; - ETableSpecification *spec; -} GalViewFactoryEtable; +struct _GalViewFactoryEtable { + GalViewFactory parent; + GalViewFactoryEtablePrivate *priv; +}; -typedef struct { +struct _GalViewFactoryEtableClass { GalViewFactoryClass parent_class; -} GalViewFactoryEtableClass; +}; -/* Standard functions */ -GType gal_view_factory_etable_get_type (void); -GalViewFactory *gal_view_factory_etable_new (ETableSpecification *spec); -GalViewFactory *gal_view_factory_etable_construct (GalViewFactoryEtable *factory, - ETableSpecification *spec); +GType gal_view_factory_etable_get_type(void); +ETableSpecification * + gal_view_factory_etable_get_specification + (GalViewFactoryEtable *factory); +GalViewFactory *gal_view_factory_etable_new (ETableSpecification *specification); G_END_DECLS -#endif /* _GAL_VIEW_FACTORY_ETABLE_H_ */ +#endif /* GAL_VIEW_FACTORY_ETABLE_H */ diff --git a/widgets/menus/gal-view-factory.c b/widgets/menus/gal-view-factory.c index d58a1545d0..7dec4416ef 100644 --- a/widgets/menus/gal-view-factory.c +++ b/widgets/menus/gal-view-factory.c @@ -20,83 +20,81 @@ * */ -#include - -#include "e-util/e-util.h" - #include "gal-view-factory.h" +#include +#include + G_DEFINE_TYPE (GalViewFactory, gal_view_factory, G_TYPE_OBJECT) -#define d(x) +/* XXX Should GalViewFactory be a GInterface? */ -d(static gint depth = 0;) +static void +gal_view_factory_class_init (GalViewFactoryClass *class) +{ +} + +static void +gal_view_factory_init (GalViewFactory *factory) +{ +} /** * gal_view_factory_get_title: - * @factory: The factory to query. + * @factory: a #GalViewFactory * * Returns: The title of the factory. */ const gchar * gal_view_factory_get_title (GalViewFactory *factory) { - g_return_val_if_fail (factory != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - - if (GAL_VIEW_FACTORY_GET_CLASS (factory)->get_title) - return GAL_VIEW_FACTORY_GET_CLASS (factory)->get_title (factory); - else - return NULL; -} + GalViewFactoryClass *class; -/** - * gal_view_factory_new_view: - * @factory: The factory to use - * @name: the name for the view. - * - * Returns: The new view - */ -GalView * -gal_view_factory_new_view (GalViewFactory *factory, - const gchar *name) -{ - g_return_val_if_fail (factory != NULL, NULL); g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - if (GAL_VIEW_FACTORY_GET_CLASS (factory)->new_view) - return GAL_VIEW_FACTORY_GET_CLASS (factory)->new_view (factory, name); - else - return NULL; + class = GAL_VIEW_FACTORY_GET_CLASS (factory); + g_return_val_if_fail (class->get_title != NULL, NULL); + + return class->get_title (factory); } /** * gal_view_factory_get_type_code: - * @factory: The factory to use + * @factory: a #GalViewFactory * * Returns: The type code */ const gchar * gal_view_factory_get_type_code (GalViewFactory *factory) { - g_return_val_if_fail (factory != NULL, NULL); + GalViewFactoryClass *class; + g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - if (GAL_VIEW_FACTORY_GET_CLASS (factory)->get_type_code) - return GAL_VIEW_FACTORY_GET_CLASS (factory)->get_type_code (factory); - else - return NULL; -} + class = GAL_VIEW_FACTORY_GET_CLASS (factory); + g_return_val_if_fail (class->get_type_code != NULL, NULL); -static void -gal_view_factory_class_init (GalViewFactoryClass *klass) -{ - klass->get_title = NULL; - klass->new_view = NULL; + return class->get_type_code (factory); } -static void -gal_view_factory_init (GalViewFactory *factory) +/** + * gal_view_factory_new_view: + * @factory: a #GalViewFactory + * @name: the name for the view + * + * Returns: The new view + */ +GalView * +gal_view_factory_new_view (GalViewFactory *factory, + const gchar *name) { + GalViewFactoryClass *class; + + g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); + + class = GAL_VIEW_FACTORY_GET_CLASS (factory); + g_return_val_if_fail (class->new_view != NULL, NULL); + + return class->new_view (factory, name); } diff --git a/widgets/menus/gal-view-factory.h b/widgets/menus/gal-view-factory.h index 376ea2ed88..7b523cb407 100644 --- a/widgets/menus/gal-view-factory.h +++ b/widgets/menus/gal-view-factory.h @@ -21,54 +21,62 @@ * */ -#ifndef _GAL_VIEW_FACTORY_H_ -#define _GAL_VIEW_FACTORY_H_ +#ifndef GAL_VIEW_FACTORY_H +#define GAL_VIEW_FACTORY_H #include #include +/* Standard GObject macros */ +#define GAL_TYPE_VIEW_FACTORY \ + (gal_view_factory_get_type ()) +#define GAL_VIEW_FACTORY(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_VIEW_FACTORY, GalViewFactory)) +#define GAL_VIEW_FACTORY_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_VIEW_FACTORY, GalViewFactoryClass)) +#define GAL_IS_VIEW_FACTORY(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_VIEW_FACTORY)) +#define GAL_IS_VIEW_FACTORY_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_VIEW_FACTORY)) +#define GAL_VIEW_FACTORY_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_VIEW_FACTORY, GalViewFactoryClass)) + G_BEGIN_DECLS -#define GAL_VIEW_FACTORY_TYPE (gal_view_factory_get_type ()) -#define GAL_VIEW_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_VIEW_FACTORY_TYPE, GalViewFactory)) -#define GAL_VIEW_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_VIEW_FACTORY_TYPE, GalViewFactoryClass)) -#define GAL_IS_VIEW_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_VIEW_FACTORY_TYPE)) -#define GAL_IS_VIEW_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_VIEW_FACTORY_TYPE)) -#define GAL_VIEW_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GAL_VIEW_FACTORY_TYPE, GalViewFactoryClass)) +typedef struct _GalViewFactory GalViewFactory; +typedef struct _GalViewFactoryClass GalViewFactoryClass; -typedef struct { - GObject base; -} GalViewFactory; +struct _GalViewFactory { + GObject parent; +}; -typedef struct { +struct _GalViewFactoryClass { GObjectClass parent_class; - /* - * Virtual methods - */ - const gchar *(*get_title) (GalViewFactory *factory); - const gchar *(*get_type_code) (GalViewFactory *factory); - GalView *(*new_view) (GalViewFactory *factory, - const gchar *name); -} GalViewFactoryClass; - -/* Standard functions */ -GType gal_view_factory_get_type (void); + /* Methods */ + const gchar * (*get_title) (GalViewFactory *factory); + const gchar * (*get_type_code) (GalViewFactory *factory); + GalView * (*new_view) (GalViewFactory *factory, + const gchar *name); +}; -/* Query functions */ -/* Returns already translated title. */ -const gchar *gal_view_factory_get_title (GalViewFactory *factory); +GType gal_view_factory_get_type (void); +const gchar * gal_view_factory_get_title (GalViewFactory *factory); /* Returns the code for use in identifying this type of object in the * view list. This identifier should identify this as being the * unique factory for xml files which were written out with this * identifier. Thus each factory should have a unique type code. */ -const gchar *gal_view_factory_get_type_code (GalViewFactory *factory); +const gchar * gal_view_factory_get_type_code (GalViewFactory *factory); -/* Create a new view */ -GalView *gal_view_factory_new_view (GalViewFactory *factory, - const gchar *name); +GalView * gal_view_factory_new_view (GalViewFactory *factory, + const gchar *name); G_END_DECLS -#endif /* _GAL_VIEW_FACTORY_H_ */ +#endif /* GAL_VIEW_FACTORY_H */ diff --git a/widgets/menus/gal-view-instance-save-as-dialog.c b/widgets/menus/gal-view-instance-save-as-dialog.c index 37d903c630..56b6dc176b 100644 --- a/widgets/menus/gal-view-instance-save-as-dialog.c +++ b/widgets/menus/gal-view-instance-save-as-dialog.c @@ -288,7 +288,7 @@ gal_view_instance_save_as_dialog_init (GalViewInstanceSaveAsDialog *dialog) GtkWidget * gal_view_instance_save_as_dialog_new (GalViewInstance *instance) { - GtkWidget *widget = g_object_new (GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE, NULL); + GtkWidget *widget = g_object_new (GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, NULL); gal_view_instance_save_as_dialog_set_instance (GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (widget), instance); return widget; } diff --git a/widgets/menus/gal-view-instance-save-as-dialog.h b/widgets/menus/gal-view-instance-save-as-dialog.h index 0f43666760..a316c9acfb 100644 --- a/widgets/menus/gal-view-instance-save-as-dialog.h +++ b/widgets/menus/gal-view-instance-save-as-dialog.h @@ -20,39 +20,43 @@ * */ -#ifndef __GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H__ -#define __GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H__ +#ifndef GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H +#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H #include #include #include -G_BEGIN_DECLS +/* Standard GObject macros */ +#define GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG \ + (gal_view_instance_save_as_dialog_get_type ()) +#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, GalViewInstanceSaveAsDialog)) +#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, GalViewInstanceSaveAsDialogClass)) +#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG)) +#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG)) +#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, GalViewInstanceSaveAsDialogClass)) -/* GalViewInstanceSaveAsDialog - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE (gal_view_instance_save_as_dialog_get_type ()) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE, GalViewInstanceSaveAsDialog)) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE, GalViewInstanceSaveAsDialogClass)) -#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE)) -#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE)) +G_BEGIN_DECLS -typedef struct _GalViewInstanceSaveAsDialog GalViewInstanceSaveAsDialog; -typedef struct _GalViewInstanceSaveAsDialogClass GalViewInstanceSaveAsDialogClass; +typedef struct _GalViewInstanceSaveAsDialog GalViewInstanceSaveAsDialog; +typedef struct _GalViewInstanceSaveAsDialogClass GalViewInstanceSaveAsDialogClass; typedef enum { GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE, GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE } GalViewInstanceSaveAsDialogToggle; -struct _GalViewInstanceSaveAsDialog -{ +struct _GalViewInstanceSaveAsDialog { GtkDialog parent; /* item specific fields */ @@ -69,16 +73,14 @@ struct _GalViewInstanceSaveAsDialog GalViewInstanceSaveAsDialogToggle toggle; }; -struct _GalViewInstanceSaveAsDialogClass -{ +struct _GalViewInstanceSaveAsDialogClass { GtkDialogClass parent_class; }; -GtkWidget *gal_view_instance_save_as_dialog_new (GalViewInstance *instance); -GType gal_view_instance_save_as_dialog_get_type (void); - -void gal_view_instance_save_as_dialog_save (GalViewInstanceSaveAsDialog *dialog); +GType gal_view_instance_save_as_dialog_get_type (void); +GtkWidget * gal_view_instance_save_as_dialog_new (GalViewInstance *instance); +void gal_view_instance_save_as_dialog_save (GalViewInstanceSaveAsDialog *dialog); G_END_DECLS -#endif /* __GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H__ */ +#endif /* GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H */ diff --git a/widgets/menus/gal-view-instance.c b/widgets/menus/gal-view-instance.c index 05b8709573..fef74aab16 100644 --- a/widgets/menus/gal-view-instance.c +++ b/widgets/menus/gal-view-instance.c @@ -186,7 +186,7 @@ gal_view_instance_class_init (GalViewInstanceClass *klass) G_STRUCT_OFFSET (GalViewInstanceClass, display_view), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, GAL_VIEW_TYPE); + G_TYPE_NONE, 1, GAL_TYPE_VIEW); gal_view_instance_signals [CHANGED] = g_signal_new ("changed", diff --git a/widgets/menus/gal-view-new-dialog.c b/widgets/menus/gal-view-new-dialog.c index ba0ade0eef..ed5a539616 100644 --- a/widgets/menus/gal-view-new-dialog.c +++ b/widgets/menus/gal-view-new-dialog.c @@ -66,7 +66,7 @@ gal_view_new_dialog_class_init (GalViewNewDialogClass *klass) g_param_spec_object ("factory", _("Factory"), /*_( */"XXX blurb" /*)*/, - GAL_VIEW_FACTORY_TYPE, + GAL_TYPE_VIEW_FACTORY, G_PARAM_READWRITE)); } diff --git a/widgets/menus/gal-view.c b/widgets/menus/gal-view.c index b410d8ec42..3b70c7a3f5 100644 --- a/widgets/menus/gal-view.c +++ b/widgets/menus/gal-view.c @@ -21,24 +21,111 @@ * */ -#include - -#include "e-util/e-util.h" - #include "gal-view.h" -G_DEFINE_TYPE (GalView, gal_view, G_TYPE_OBJECT) +#include +#include #define d(x) -d(static gint depth = 0;) +enum { + PROP_0, + PROP_TITLE, + PROP_TYPE_CODE +}; enum { CHANGED, LAST_SIGNAL }; -static guint gal_view_signals [LAST_SIGNAL] = { 0, }; +static guint signals[LAST_SIGNAL]; + +G_DEFINE_ABSTRACT_TYPE (GalView, gal_view, G_TYPE_OBJECT) + +static void +view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_TITLE: + gal_view_set_title ( + GAL_VIEW (object), + g_value_get_string (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_TITLE: + g_value_set_string ( + value, gal_view_get_title ( + GAL_VIEW (object))); + return; + + case PROP_TYPE_CODE: + g_value_set_string ( + value, gal_view_get_type_code ( + GAL_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +gal_view_class_init (GalViewClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = view_set_property; + object_class->get_property = view_get_property; + + g_object_class_install_property ( + object_class, + PROP_TITLE, + g_param_spec_string ( + "title", + NULL, + NULL, + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_TYPE_CODE, + g_param_spec_string ( + "type-code", + NULL, + NULL, + NULL, + G_PARAM_READABLE)); + + signals[CHANGED] = g_signal_new ( + "changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GalViewClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + +static void +gal_view_init (GalView *view) +{ +} /** * gal_view_edit @@ -46,15 +133,18 @@ static guint gal_view_signals [LAST_SIGNAL] = { 0, }; * @parent: the parent window. */ void -gal_view_edit (GalView *view, - GtkWindow *parent) +gal_view_edit (GalView *view, + GtkWindow *parent) { - g_return_if_fail (view != NULL); + GalViewClass *class; + g_return_if_fail (GAL_IS_VIEW (view)); g_return_if_fail (GTK_IS_WINDOW (parent)); - if (GAL_VIEW_GET_CLASS (view)->edit) - GAL_VIEW_GET_CLASS (view)->edit (view, parent); + class = GAL_VIEW_GET_CLASS (view); + g_return_if_fail (class->edit != NULL); + + class->edit (view, parent); } /** @@ -63,14 +153,18 @@ gal_view_edit (GalView *view, * @filename: The file to load from */ void -gal_view_load (GalView *view, - const gchar *filename) +gal_view_load (GalView *view, + const gchar *filename) { - g_return_if_fail (view != NULL); + GalViewClass *class; + g_return_if_fail (GAL_IS_VIEW (view)); + g_return_if_fail (filename != NULL); + + class = GAL_VIEW_GET_CLASS (view); + g_return_if_fail (class->load != NULL); - if (GAL_VIEW_GET_CLASS (view)->load) - GAL_VIEW_GET_CLASS (view)->load (view, filename); + class->load (view, filename); } /** @@ -79,14 +173,18 @@ gal_view_load (GalView *view, * @filename: The file to save to */ void -gal_view_save (GalView *view, - const gchar *filename) +gal_view_save (GalView *view, + const gchar *filename) { - g_return_if_fail (view != NULL); + GalViewClass *class; + g_return_if_fail (GAL_IS_VIEW (view)); + g_return_if_fail (filename != NULL); + + class = GAL_VIEW_GET_CLASS (view); + g_return_if_fail (class->save != NULL); - if (GAL_VIEW_GET_CLASS (view)->save) - GAL_VIEW_GET_CLASS (view)->save (view, filename); + class->save (view, filename); } /** @@ -96,15 +194,16 @@ gal_view_save (GalView *view, * Returns: The title of the view. */ const gchar * -gal_view_get_title (GalView *view) +gal_view_get_title (GalView *view) { - g_return_val_if_fail (view != NULL, NULL); + GalViewClass *class; + g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - if (GAL_VIEW_GET_CLASS (view)->get_title) - return GAL_VIEW_GET_CLASS (view)->get_title (view); - else - return NULL; + class = GAL_VIEW_GET_CLASS (view); + g_return_val_if_fail (class->get_title != NULL, NULL); + + return class->get_title (view); } /** @@ -113,14 +212,19 @@ gal_view_get_title (GalView *view) * @title: The new title value. */ void -gal_view_set_title (GalView *view, - const gchar *title) +gal_view_set_title (GalView *view, + const gchar *title) { - g_return_if_fail (view != NULL); + GalViewClass *class; + g_return_if_fail (GAL_IS_VIEW (view)); - if (GAL_VIEW_GET_CLASS (view)->set_title) - GAL_VIEW_GET_CLASS (view)->set_title (view, title); + class = GAL_VIEW_GET_CLASS (view); + g_return_if_fail (class->set_title != NULL); + + class->set_title (view, title); + + g_object_notify (G_OBJECT (view), "title"); } /** @@ -132,13 +236,14 @@ gal_view_set_title (GalView *view, const gchar * gal_view_get_type_code (GalView *view) { - g_return_val_if_fail (view != NULL, NULL); + GalViewClass *class; + g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - if (GAL_VIEW_GET_CLASS (view)->get_type_code) - return GAL_VIEW_GET_CLASS (view)->get_type_code (view); - else - return NULL; + class = GAL_VIEW_GET_CLASS (view); + g_return_val_if_fail (class->get_type_code != NULL, NULL); + + return class->get_type_code (view); } /** @@ -148,15 +253,16 @@ gal_view_get_type_code (GalView *view) * Returns: The clone. */ GalView * -gal_view_clone (GalView *view) +gal_view_clone (GalView *view) { - g_return_val_if_fail (view != NULL, NULL); + GalViewClass *class; + g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - if (GAL_VIEW_GET_CLASS (view)->clone) - return GAL_VIEW_GET_CLASS (view)->clone (view); - else - return NULL; + class = GAL_VIEW_GET_CLASS (view); + g_return_val_if_fail (class->clone != NULL, NULL); + + return class->clone (view); } /** @@ -164,40 +270,10 @@ gal_view_clone (GalView *view) * @view: The view that changed. */ void -gal_view_changed (GalView *view) +gal_view_changed (GalView *view) { - g_return_if_fail (view != NULL); g_return_if_fail (GAL_IS_VIEW (view)); - g_signal_emit(view, - gal_view_signals [CHANGED], 0); -} - -static void -gal_view_class_init (GalViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - klass->edit = NULL; - klass->load = NULL; - klass->save = NULL; - klass->get_title = NULL; - klass->clone = NULL; - - klass->changed = NULL; - - gal_view_signals [CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GalViewClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -gal_view_init (GalView *view) -{ + g_signal_emit (view, signals [CHANGED], 0); } diff --git a/widgets/menus/gal-view.h b/widgets/menus/gal-view.h index 099a92704c..84c26ba77f 100644 --- a/widgets/menus/gal-view.h +++ b/widgets/menus/gal-view.h @@ -21,73 +21,74 @@ * */ -#ifndef _GAL_VIEW_H_ -#define _GAL_VIEW_H_ +#ifndef GAL_VIEW_H +#define GAL_VIEW_H #include #include +/* Standard GObject macros */ +#define GAL_TYPE_VIEW \ + (gal_view_get_type ()) +#define GAL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), GAL_TYPE_VIEW, GalView)) +#define GAL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), GAL_TYPE_VIEW, GalViewClass)) +#define GAL_IS_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), GAL_TYPE_VIEW)) +#define GAL_IS_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), GAL_TYPE_VIEW)) +#define GAL_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), GAL_TYPE_VIEW, GalViewClass)) + G_BEGIN_DECLS -#define GAL_VIEW_TYPE (gal_view_get_type ()) -#define GAL_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_VIEW_TYPE, GalView)) -#define GAL_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_VIEW_TYPE, GalViewClass)) -#define GAL_IS_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_VIEW_TYPE)) -#define GAL_IS_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_VIEW_TYPE)) -#define GAL_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GAL_VIEW_TYPE, GalViewClass)) +typedef struct _GalView GalView; +typedef struct _GalViewClass GalViewClass; -typedef struct { - GObject base; -} GalView; +struct _GalView { + GObject parent; +}; -typedef struct { +struct _GalViewClass { GObjectClass parent_class; - /* - * Virtual methods - */ - void (*edit) (GalView *view, GtkWindow *parent_window); - void (*load) (GalView *view, - const gchar *filename); - void (*save) (GalView *view, - const gchar *filename); - const gchar *(*get_title) (GalView *view); - void (*set_title) (GalView *view, - const gchar *title); - const gchar *(*get_type_code) (GalView *view); - GalView *(*clone) (GalView *view); + /* Methods */ + void (*edit) (GalView *view, + GtkWindow *parent_window); + void (*load) (GalView *view, + const gchar *filename); + void (*save) (GalView *view, + const gchar *filename); + const gchar * (*get_title) (GalView *view); + void (*set_title) (GalView *view, + const gchar *title); + const gchar * (*get_type_code) (GalView *view); + GalView * (*clone) (GalView *view); /* Signals */ - void (*changed) (GalView *view); -} GalViewClass; - -/* Standard functions */ -GType gal_view_get_type (void); - -/* Open an editor dialog for this view, modal/transient for the GtkWindow arg. */ -void gal_view_edit (GalView *view, - GtkWindow *parent); - -/* xml load and save functions */ -void gal_view_load (GalView *view, - const gchar *filename); -void gal_view_save (GalView *view, - const gchar *filename); - -/* Title functions */ -const gchar *gal_view_get_title (GalView *view); -void gal_view_set_title (GalView *view, - const gchar *title); - -/* View type. */ -const gchar *gal_view_get_type_code (GalView *view); - -/* Cloning the view */ -GalView *gal_view_clone (GalView *view); - -/* Changed signal */ -void gal_view_changed (GalView *view); + void (*changed) (GalView *view); +}; + +GType gal_view_get_type (void); +void gal_view_edit (GalView *view, + GtkWindow *parent); +void gal_view_load (GalView *view, + const gchar *filename); +void gal_view_save (GalView *view, + const gchar *filename); +const gchar * gal_view_get_title (GalView *view); +void gal_view_set_title (GalView *view, + const gchar *title); +const gchar * gal_view_get_type_code (GalView *view); +GalView * gal_view_clone (GalView *view); +void gal_view_changed (GalView *view); G_END_DECLS -#endif /* _GAL_VIEW_H_ */ +#endif /* GAL_VIEW_H */ diff --git a/widgets/table/e-table-specification.c b/widgets/table/e-table-specification.c index d837b7344e..5d2bcad32c 100644 --- a/widgets/table/e-table-specification.c +++ b/widgets/table/e-table-specification.c @@ -111,7 +111,7 @@ etsp_init (ETableSpecification *etsp) ETableSpecification * e_table_specification_new (void) { - ETableSpecification *etsp = g_object_new (E_TABLE_SPECIFICATION_TYPE, NULL); + ETableSpecification *etsp = g_object_new (E_TYPE_TABLE_SPECIFICATION, NULL); return (ETableSpecification *) etsp; } diff --git a/widgets/table/e-table-specification.h b/widgets/table/e-table-specification.h index c2ca7a018d..e6f6707ae5 100644 --- a/widgets/table/e-table-specification.h +++ b/widgets/table/e-table-specification.h @@ -33,12 +33,12 @@ G_BEGIN_DECLS -#define E_TABLE_SPECIFICATION_TYPE (e_table_specification_get_type ()) -#define E_TABLE_SPECIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TABLE_SPECIFICATION_TYPE, ETableSpecification)) -#define E_TABLE_SPECIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TABLE_SPECIFICATION_TYPE, ETableSpecificationClass)) -#define E_IS_TABLE_SPECIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TABLE_SPECIFICATION_TYPE)) -#define E_IS_TABLE_SPECIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TABLE_SPECIFICATION_TYPE)) -#define E_TABLE_SPECIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), E_TABLE_SPECIFICATION_TYPE, ETableSpecificationClass)) +#define E_TYPE_TABLE_SPECIFICATION (e_table_specification_get_type ()) +#define E_TABLE_SPECIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_TABLE_SPECIFICATION, ETableSpecification)) +#define E_TABLE_SPECIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_TABLE_SPECIFICATION, ETableSpecificationClass)) +#define E_IS_TABLE_SPECIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_TABLE_SPECIFICATION)) +#define E_IS_TABLE_SPECIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_TABLE_SPECIFICATION)) +#define E_TABLE_SPECIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), E_TYPE_TABLE_SPECIFICATION, ETableSpecificationClass)) typedef struct { GObject base; diff --git a/widgets/table/e-table-state.c b/widgets/table/e-table-state.c index 46d0c355e8..1360271680 100644 --- a/widgets/table/e-table-state.c +++ b/widgets/table/e-table-state.c @@ -119,6 +119,9 @@ e_table_state_load_from_file (ETableState *state, { xmlDoc *doc; + g_return_val_if_fail (E_IS_TABLE_STATE (state), FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + doc = e_xml_parse_file (filename); if (doc) { xmlNode *node = xmlDocGetRootElement(doc); @@ -135,6 +138,9 @@ e_table_state_load_from_string (ETableState *state, { xmlDoc *doc; + g_return_if_fail (E_IS_TABLE_STATE (state)); + g_return_if_fail (xml != NULL); + doc = xmlParseMemory ((gchar *) xml, strlen(xml)); if (doc) { xmlNode *node = xmlDocGetRootElement(doc); @@ -157,6 +163,9 @@ e_table_state_load_from_node (ETableState *state, gdouble state_version; gint i; + g_return_if_fail (E_IS_TABLE_STATE (state)); + g_return_if_fail (node != NULL); + state_version = e_xml_get_double_prop_by_name_with_default ( node, (const guchar *)"state-version", STATE_VERSION); @@ -227,6 +236,8 @@ e_table_state_save_to_string (ETableState *state) gint length; xmlDoc *doc; + g_return_val_if_fail (E_IS_TABLE_STATE (state), NULL); + doc = xmlNewDoc((const guchar *)"1.0"); xmlDocSetRootElement(doc, e_table_state_save_to_node(state, NULL)); xmlDocDumpMemory(doc, &string, &length); @@ -244,6 +255,8 @@ e_table_state_save_to_node (ETableState *state, gint i; xmlNode *node; + g_return_val_if_fail (E_IS_TABLE_STATE (state), NULL); + if (parent) node = xmlNewChild ( parent, NULL, (const guchar *) "ETableState", NULL); @@ -287,7 +300,6 @@ e_table_state_duplicate (ETableState *state) ETableState *new_state; gchar *copy; - g_return_val_if_fail (state != NULL, NULL); g_return_val_if_fail (E_IS_TABLE_STATE (state), NULL); new_state = e_table_state_new (); -- cgit