[gnome-documents] Use properties for name and model name
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] Use properties for name and model name
- Date: Tue, 29 Jan 2013 18:09:40 +0000 (UTC)
commit 69943692c117bab4c3ac2404405d6d04f77448f8
Author: William Jon McCann <jmccann redhat com>
Date: Sat Jan 26 04:45:12 2013 -0500
Use properties for name and model name
https://bugzilla.gnome.org/show_bug.cgi?id=691254
src/lib/gd-places-links.c | 74 +++++++++++++++++++++++++++++++++++++--------
src/lib/gd-places-page.c | 33 +++++++++-----------
src/lib/gd-places-page.h | 6 +--
3 files changed, 78 insertions(+), 35 deletions(-)
---
diff --git a/src/lib/gd-places-links.c b/src/lib/gd-places-links.c
index c1aca3c..5b8e5c2 100644
--- a/src/lib/gd-places-links.c
+++ b/src/lib/gd-places-links.c
@@ -43,6 +43,14 @@ struct _GdPlacesLinksPrivate {
GtkTreeModel *model;
EvDocument *document;
EvDocumentModel *document_model;
+ const char *name;
+};
+
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_DOCUMENT_MODEL,
};
enum {
@@ -391,18 +399,6 @@ gd_places_links_supports_document (GdPlacesPage *places_page,
ev_document_links_has_document_links (EV_DOCUMENT_LINKS (document)));
}
-static const char *
-gd_places_links_get_label (GdPlacesPage *places_page)
-{
- return _("Contents");
-}
-
-static const char *
-gd_places_links_get_icon_name (GdPlacesPage *places_page)
-{
- return "view-list-symbolic";
-}
-
static void
gd_places_links_set_document_model (GdPlacesPage *places_page,
EvDocumentModel *model)
@@ -441,6 +437,12 @@ gd_places_links_set_document_model (GdPlacesPage *places_page,
}
}
+static const char *
+gd_places_links_get_name (GdPlacesPage *places_page)
+{
+ return GD_PLACES_LINKS (places_page)->priv->name;
+}
+
static void
gd_places_links_dispose (GObject *object)
{
@@ -468,12 +470,53 @@ gd_places_links_dispose (GObject *object)
G_OBJECT_CLASS (gd_places_links_parent_class)->dispose (object);
}
+static void
+gd_places_links_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+
+ GdPlacesLinks *self = GD_PLACES_LINKS (object);
+
+ switch (prop_id) {
+ case PROP_DOCUMENT_MODEL:
+ gd_places_links_set_document_model (GD_PLACES_PAGE (self), g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gd_places_links_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdPlacesLinks *self = GD_PLACES_LINKS (object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ g_value_set_string (value, self->priv->name);
+ break;
+ case PROP_DOCUMENT_MODEL:
+ g_value_set_object (value, self->priv->document_model);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
static void
gd_places_links_init (GdPlacesLinks *self)
{
self->priv = GD_PLACES_LINKS_GET_PRIVATE (self);
+ self->priv->name = _("Contents");
+
gd_places_links_construct (self);
}
@@ -482,7 +525,7 @@ gd_places_links_page_iface_init (GdPlacesPageInterface *iface)
{
iface->supports_document = gd_places_links_supports_document;
iface->set_document_model = gd_places_links_set_document_model;
- iface->get_label = gd_places_links_get_label;
+ iface->get_name = gd_places_links_get_name;
}
static void
@@ -491,6 +534,8 @@ gd_places_links_class_init (GdPlacesLinksClass *klass)
GObjectClass *oclass = G_OBJECT_CLASS (klass);
oclass->dispose = gd_places_links_dispose;
+ oclass->set_property = gd_places_links_set_property;
+ oclass->get_property = gd_places_links_get_property;
signals[LINK_ACTIVATED] = g_signal_new ("link-activated",
G_TYPE_FROM_CLASS (oclass),
@@ -500,6 +545,9 @@ gd_places_links_class_init (GdPlacesLinksClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ g_object_class_override_property (oclass, PROP_NAME, "name");
+ g_object_class_override_property (oclass, PROP_DOCUMENT_MODEL, "document-model");
+
g_type_class_add_private (oclass, sizeof (GdPlacesLinksPrivate));
}
diff --git a/src/lib/gd-places-page.c b/src/lib/gd-places-page.c
index f1de582..f2ecccc 100644
--- a/src/lib/gd-places-page.c
+++ b/src/lib/gd-places-page.c
@@ -62,7 +62,7 @@ gd_places_page_set_document_model (GdPlacesPage *places_page,
}
const char *
-gd_places_page_get_label (GdPlacesPage *places_page)
+gd_places_page_get_name (GdPlacesPage *places_page)
{
GdPlacesPageInterface *iface;
@@ -70,27 +70,24 @@ gd_places_page_get_label (GdPlacesPage *places_page)
iface = GD_PLACES_PAGE_GET_IFACE (places_page);
- g_assert (iface->get_label);
+ g_assert (iface->get_name);
- return iface->get_label (places_page);
+ return iface->get_name (places_page);
}
-const char *
-gd_places_page_get_icon_name (GdPlacesPage *places_page)
-{
- GdPlacesPageInterface *iface;
-
- g_return_val_if_fail (GD_IS_PLACES_PAGE (places_page), NULL);
-
- iface = GD_PLACES_PAGE_GET_IFACE (places_page);
-
- g_assert (iface->get_icon_name);
-
- return iface->get_icon_name (places_page);
-}
-
-
static void
gd_places_page_default_init (GdPlacesPageInterface *iface)
{
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("name",
+ "Name",
+ "Name of the page",
+ NULL,
+ G_PARAM_READABLE));
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("document-model",
+ "Document Model",
+ "Document Model",
+ EV_TYPE_DOCUMENT_MODEL,
+ G_PARAM_READWRITE));
}
diff --git a/src/lib/gd-places-page.h b/src/lib/gd-places-page.h
index 1c123f0..73e4d79 100644
--- a/src/lib/gd-places-page.h
+++ b/src/lib/gd-places-page.h
@@ -49,8 +49,7 @@ struct _GdPlacesPageInterface
EvDocument *document);
void (* set_document_model) (GdPlacesPage *places_page,
EvDocumentModel *model);
- const char * (* get_label) (GdPlacesPage *places_page);
- const char * (* get_icon_name ) (GdPlacesPage *places_page);
+ const char * (* get_name) (GdPlacesPage *places_page);
};
GType gd_places_page_get_type (void) G_GNUC_CONST;
@@ -58,8 +57,7 @@ gboolean gd_places_page_supports_document (GdPlacesPage *places_page,
EvDocument *document);
void gd_places_page_set_document_model (GdPlacesPage *places_page,
EvDocumentModel *model);
-const char * gd_places_page_get_label (GdPlacesPage *page);
-const char * gd_places_page_get_icon_name (GdPlacesPage *page);
+const char * gd_places_page_get_name (GdPlacesPage *page);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]