[empathy: 2/3] Move category name constants to #defines



commit ed85fe70b223a778b5d7bdca6b4fe8d5ac327959
Author: Will Thompson <will thompson collabora co uk>
Date:   Wed Mar 28 10:39:51 2012 +0100

    Move category name constants to #defines
    
    This is kind of overkill to avoid me typoing the two names used in
    empathy-chat-window.c, but, hey.

 libempathy-gtk/empathy-notify-manager.h |   15 +++++++++++++
 src/empathy-chat-window.c               |    4 +-
 src/empathy-event-manager.h             |    1 +
 src/empathy-notifications-approver.c    |   35 ++++++++++++++----------------
 4 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/libempathy-gtk/empathy-notify-manager.h b/libempathy-gtk/empathy-notify-manager.h
index dd7565c..0b937e1 100644
--- a/libempathy-gtk/empathy-notify-manager.h
+++ b/libempathy-gtk/empathy-notify-manager.h
@@ -43,6 +43,21 @@ G_BEGIN_DECLS
 #define EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_PRIVATE_SYNCHRONOUS "x-canonical-private-synchronous"
 #define EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_TRUNCATION          "x-canonical-truncation"
 
+/* Categories associated with EMPATHY_NOTIFY_MANAGER_CAP_CATEGORY.
+ * Uses x-empathy as prefix for unofficial categories. See
+ * http://www.galago-project.org/specs/notification/0.9/x211.html */
+#define EMPATHY_NOTIFICATION_CATEGORY_CHAT             "im.received"
+#define EMPATHY_NOTIFICATION_CATEGORY_PRESENCE_ONLINE  "presence.online"
+#define EMPATHY_NOTIFICATION_CATEGORY_PRESENCE_OFFLINE "presence.offline"
+/* Yes, these two are the same. */
+#define EMPATHY_NOTIFICATION_CATEGORY_VOIP             "x-empathy.call.incoming"
+#define EMPATHY_NOTIFICATION_CATEGORY_CALL             "x-empathy.call.incoming"
+#define EMPATHY_NOTIFICATION_CATEGORY_TRANSFER         "x-empathy.transfer.incoming"
+#define EMPATHY_NOTIFICATION_CATEGORY_INVITATION       "x-empathy.im.room-invitation"
+#define EMPATHY_NOTIFICATION_CATEGORY_AUTH             "x-empathy.network.auth-request"
+#define EMPATHY_NOTIFICATION_CATEGORY_SUBSCRIPTION     "x-empathy.im.subscription-request"
+#define EMPATHY_NOTIFICATION_CATEGORY_MENTIONED        "x-empathy.im.mentioned"
+
 #define EMPATHY_TYPE_NOTIFY_MANAGER         (empathy_notify_manager_get_type ())
 #define EMPATHY_NOTIFY_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_NOTIFY_MANAGER, EmpathyNotifyManager))
 #define EMPATHY_NOTIFY_MANAGER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_NOTIFY_MANAGER, EmpathyNotifyManagerClass))
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 0008fed..ac3584f 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -1570,8 +1570,8 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
 
 		{
 			const gchar *category = empathy_chat_is_room (chat)
-				? "x-empathy.im.mentioned"
-				: "im.received";
+				? EMPATHY_NOTIFICATION_CATEGORY_MENTIONED
+				: EMPATHY_NOTIFICATION_CATEGORY_CHAT;
 			notify_notification_set_hint (notification,
 				EMPATHY_NOTIFY_MANAGER_CAP_CATEGORY,
 				g_variant_new_string (category));
diff --git a/src/empathy-event-manager.h b/src/empathy-event-manager.h
index 91c6e1f..e50ab88 100644
--- a/src/empathy-event-manager.h
+++ b/src/empathy-event-manager.h
@@ -58,6 +58,7 @@ typedef enum {
     EMPATHY_EVENT_TYPE_PRESENCE_OFFLINE,
     EMPATHY_EVENT_TYPE_INVITATION,
     EMPATHY_EVENT_TYPE_AUTH,
+    EMPATHY_EVENT_TYPE_MENTIONED,
 } EmpathyEventType;
 
 typedef struct {
diff --git a/src/empathy-notifications-approver.c b/src/empathy-notifications-approver.c
index 7a4f037..92b3f74 100644
--- a/src/empathy-notifications-approver.c
+++ b/src/empathy-notifications-approver.c
@@ -185,6 +185,7 @@ add_notification_actions (EmpathyNotificationsApprover *self,
 
   switch (self->priv->event->type) {
     case EMPATHY_EVENT_TYPE_CHAT:
+    case EMPATHY_EVENT_TYPE_MENTIONED:
       notify_notification_add_action (notification,
         "respond", _("Respond"), (NotifyActionCallback) notification_approve_cb,
           self, NULL);
@@ -265,6 +266,7 @@ notification_is_urgent (EmpathyNotificationsApprover *self,
     case EMPATHY_EVENT_TYPE_TRANSFER:
     case EMPATHY_EVENT_TYPE_INVITATION:
     case EMPATHY_EVENT_TYPE_AUTH:
+    case EMPATHY_EVENT_TYPE_MENTIONED:
       return TRUE;
 
     case EMPATHY_EVENT_TYPE_SUBSCRIPTION:
@@ -276,30 +278,25 @@ notification_is_urgent (EmpathyNotificationsApprover *self,
   return FALSE;
 }
 
-/* Use x-empathy as prefix for unofficial categories
- * http://www.galago-project.org/specs/notification/0.9/x211.html */
 static const gchar *
 get_category_for_event_type (EmpathyEventType type)
 {
+#define CASE(x) \
+    case EMPATHY_EVENT_TYPE_##x: \
+      return EMPATHY_NOTIFICATION_CATEGORY_##x;
   switch (type) {
-    case EMPATHY_EVENT_TYPE_CHAT:
-      return "im.received";
-    case EMPATHY_EVENT_TYPE_PRESENCE_ONLINE:
-      return "presence.online";
-    case EMPATHY_EVENT_TYPE_PRESENCE_OFFLINE:
-      return "presence.offline";
-    case EMPATHY_EVENT_TYPE_VOIP:
-    case EMPATHY_EVENT_TYPE_CALL:
-      return "x-empathy.call.incoming";
-    case EMPATHY_EVENT_TYPE_TRANSFER:
-      return "x-empathy.transfer.incoming";
-    case EMPATHY_EVENT_TYPE_INVITATION:
-      return "x-empathy.im.room-invitation";
-    case EMPATHY_EVENT_TYPE_AUTH:
-      return "x-empathy.network.auth-request";
-    case EMPATHY_EVENT_TYPE_SUBSCRIPTION:
-      return "x-empathy.im.subscription-request";
+    CASE(CHAT)
+    CASE(PRESENCE_ONLINE)
+    CASE(PRESENCE_OFFLINE)
+    CASE(VOIP)
+    CASE(CALL)
+    CASE(TRANSFER)
+    CASE(INVITATION)
+    CASE(AUTH)
+    CASE(SUBSCRIPTION)
+    CASE(MENTIONED)
   }
+#undef CASE
 
   return NULL;
 }



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