aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/menus
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-03-11 06:29:50 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-03-11 08:19:33 +0800
commit6af1b3178dcf5e3271f6be4d785c28cbe9043404 (patch)
treef3d05886ecb1a9f300adca7799ca59f8de4e717c /widgets/menus
parentc0533ef0530a1dfb8802731ad5fe6c4f8b3dccaf (diff)
downloadgsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.gz
gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.zst
gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.zip
Clean up GalView and related classes.
Diffstat (limited to 'widgets/menus')
-rw-r--r--widgets/menus/gal-define-views-dialog.c2
-rw-r--r--widgets/menus/gal-define-views-dialog.h54
-rw-r--r--widgets/menus/gal-view-collection.c2
-rw-r--r--widgets/menus/gal-view-etable.c22
-rw-r--r--widgets/menus/gal-view-etable.h81
-rw-r--r--widgets/menus/gal-view-factory-etable.c176
-rw-r--r--widgets/menus/gal-view-factory-etable.h57
-rw-r--r--widgets/menus/gal-view-factory.c88
-rw-r--r--widgets/menus/gal-view-factory.h70
-rw-r--r--widgets/menus/gal-view-instance-save-as-dialog.c2
-rw-r--r--widgets/menus/gal-view-instance-save-as-dialog.h56
-rw-r--r--widgets/menus/gal-view-instance.c2
-rw-r--r--widgets/menus/gal-view-new-dialog.c2
-rw-r--r--widgets/menus/gal-view.c228
-rw-r--r--widgets/menus/gal-view.h111
15 files changed, 580 insertions, 373 deletions
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 <gtk/gtk.h>
+#include <menus/gal-view-collection.h>
-#include <widgets/menus/gal-view-collection.h>
+/* 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 <gtk/gtk.h>
#include <menus/gal-view.h>
@@ -31,47 +31,62 @@
#include <table/e-table.h>
#include <table/e-tree.h>
+/* 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 <gtk/gtk.h>
#include <menus/gal-view-factory.h>
#include <table/e-table-specification.h>
-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 <config.h>
-
-#include "e-util/e-util.h"
-
#include "gal-view-factory.h"
+#include <config.h>
+#include <e-util/e-util.h>
+
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 <glib-object.h>
#include <menus/gal-view.h>
+/* 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 <gtk/gtk.h>
#include <widgets/menus/gal-view-collection.h>
#include <widgets/menus/gal-view-instance.h>
-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 <config.h>
-
-#include "e-util/e-util.h"
-
#include "gal-view.h"
-G_DEFINE_TYPE (GalView, gal_view, G_TYPE_OBJECT)
+#include <config.h>
+#include <e-util/e-util.h>
#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 <gtk/gtk.h>
#include <libxml/tree.h>
+/* 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 */