diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-03-11 06:29:50 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-03-11 08:19:33 +0800 |
commit | 6af1b3178dcf5e3271f6be4d785c28cbe9043404 (patch) | |
tree | f3d05886ecb1a9f300adca7799ca59f8de4e717c /widgets/menus/gal-view.c | |
parent | c0533ef0530a1dfb8802731ad5fe6c4f8b3dccaf (diff) | |
download | gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.gz gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.bz2 gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.lz gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.xz gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.tar.zst gsoc2013-evolution-6af1b3178dcf5e3271f6be4d785c28cbe9043404.zip |
Clean up GalView and related classes.
Diffstat (limited to 'widgets/menus/gal-view.c')
-rw-r--r-- | widgets/menus/gal-view.c | 228 |
1 files changed, 152 insertions, 76 deletions
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); } |