[evolution-data-server] CamelService: Add a "display-name" property.



commit 4702d2dadcfbe859a957c4e4996c0568b245ad21
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Aug 17 20:49:02 2011 -0400

    CamelService: Add a "display-name" property.
    
    Mostly as a convenience to clients.  Camel itself doesn't use this for
    anything at present, although I suppose it could come in handy for some
    error messages or user prompts.

 camel/camel-service.c                        |   79 ++++++++++++++++++++++++++
 camel/camel-service.h                        |    3 +
 docs/reference/camel/camel-sections.txt      |    2 +
 docs/reference/camel/tmpl/camel-service.sgml |   23 ++++++++
 4 files changed, 107 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 9609e97..03b03b8 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -58,6 +58,7 @@ struct _CamelServicePrivate {
 	CamelProvider *provider;
 	CamelURL *url;
 
+	gchar *display_name;
 	gchar *user_data_dir;
 	gchar *uid;
 
@@ -74,6 +75,7 @@ struct _AsyncContext {
 
 enum {
 	PROP_0,
+	PROP_DISPLAY_NAME,
 	PROP_PROVIDER,
 	PROP_SESSION,
 	PROP_SETTINGS,
@@ -229,6 +231,12 @@ service_set_property (GObject *object,
                       GParamSpec *pspec)
 {
 	switch (property_id) {
+		case PROP_DISPLAY_NAME:
+			camel_service_set_display_name (
+				CAMEL_SERVICE (object),
+				g_value_get_string (value));
+			return;
+
 		case PROP_PROVIDER:
 			service_set_provider (
 				CAMEL_SERVICE (object),
@@ -270,6 +278,12 @@ service_get_property (GObject *object,
                       GParamSpec *pspec)
 {
 	switch (property_id) {
+		case PROP_DISPLAY_NAME:
+			g_value_set_string (
+				value, camel_service_get_display_name (
+				CAMEL_SERVICE (object)));
+			return;
+
 		case PROP_PROVIDER:
 			g_value_set_pointer (
 				value, camel_service_get_provider (
@@ -340,6 +354,7 @@ service_finalize (GObject *object)
 	if (priv->url != NULL)
 		camel_url_free (priv->url);
 
+	g_free (priv->display_name);
 	g_free (priv->user_data_dir);
 	g_free (priv->uid);
 
@@ -580,6 +595,18 @@ camel_service_class_init (CamelServiceClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_DISPLAY_NAME,
+		g_param_spec_string (
+			"display-name",
+			"Display Name",
+			"The display name for the service",
+			NULL,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_PROVIDER,
 		g_param_spec_pointer (
 			"provider",
@@ -693,6 +720,58 @@ camel_service_cancel_connect (CamelService *service)
 }
 
 /**
+ * camel_service_get_display_name:
+ * @service: a #CamelService
+ *
+ * Returns the display name for @service, or %NULL if @service has not
+ * been given a display name.  The display name is intended for use in
+ * a user interface and should generally be given a user-defined name.
+ *
+ * Compare this with camel_service_get_name(), which returns a built-in
+ * description of the type of service (IMAP, SMTP, etc.).
+ *
+ * Returns: the display name for @service, or %NULL
+ *
+ * Since: 3.2
+ **/
+const gchar *
+camel_service_get_display_name (CamelService *service)
+{
+	g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+
+	return service->priv->display_name;
+}
+
+/**
+ * camel_service_set_display_name:
+ * @service: a #CamelService
+ * @display_name: a valid UTF-8 string, or %NULL
+ *
+ * Assigns a UTF-8 display name to @service.  The display name is intended
+ * for use in a user interface and should generally be given a user-defined
+ * name.
+ *
+ * Compare this with camel_service_get_name(), which returns a built-in
+ * description of the type of service (IMAP, SMTP, etc.).
+ *
+ * Since: 3.2
+ **/
+void
+camel_service_set_display_name (CamelService *service,
+                                const gchar *display_name)
+{
+	g_return_if_fail (CAMEL_IS_SERVICE (service));
+
+	if (display_name != NULL)
+		g_return_if_fail (g_utf8_validate (display_name, -1, NULL));
+
+	g_free (service->priv->display_name);
+	service->priv->display_name = g_strdup (display_name);
+
+	g_object_notify (G_OBJECT (service), "display-name");
+}
+
+/**
  * camel_service_get_user_data_dir:
  * @service: a #CamelService
  *
diff --git a/camel/camel-service.h b/camel/camel-service.h
index 4599a81..a9843e3 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -145,6 +145,9 @@ typedef struct {
 
 GType		camel_service_get_type		(void);
 GQuark		camel_service_error_quark	(void) G_GNUC_CONST;
+const gchar *	camel_service_get_display_name	(CamelService *service);
+void		camel_service_set_display_name	(CamelService *service,
+						 const gchar *display_name);
 const gchar *	camel_service_get_user_data_dir	(CamelService *service);
 gchar *		camel_service_get_name		(CamelService *service,
 						 gboolean brief);
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 7522fc7..7f86668 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -1952,6 +1952,8 @@ CAMEL_SERVICE_ERROR
 CamelServiceError
 CamelServiceConnectionStatus
 CamelServiceAuthType
+camel_service_get_display_name
+camel_service_set_display_name
 camel_service_get_user_data_dir
 camel_service_get_name
 camel_service_get_provider
diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml
index 2161313..db5c5c7 100644
--- a/docs/reference/camel/tmpl/camel-service.sgml
+++ b/docs/reference/camel/tmpl/camel-service.sgml
@@ -26,6 +26,11 @@ CamelService
 </para>
 
 
+<!-- ##### ARG CamelService:display-name ##### -->
+<para>
+
+</para>
+
 <!-- ##### ARG CamelService:provider ##### -->
 <para>
 
@@ -89,6 +94,24 @@ CamelService
 @authproto: 
 @need_password: 
 
+<!-- ##### FUNCTION camel_service_get_display_name ##### -->
+<para>
+
+</para>
+
+ service: 
+ Returns: 
+
+
+<!-- ##### FUNCTION camel_service_set_display_name ##### -->
+<para>
+
+</para>
+
+ service: 
+ display_name: 
+
+
 <!-- ##### FUNCTION camel_service_get_user_data_dir ##### -->
 <para>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]