new enotify test which showcases 1) our ability to break e_dbus 2) enotify's continue...
[framework/uifw/edbus.git] / src / bin / notify.c
index a6cde3b..b5b52b9 100644 (file)
@@ -4,10 +4,14 @@
 
 #include <stdio.h>
 
+#include <Evas.h>
 #include <Ecore.h>
+#include <Ecore_Evas.h>
 #include <E_DBus.h>
 #include <E_Notify.h>
 
+#define LOGO PACKAGE_DATA_DIR "/logo.png"
+
 void
 cb_sent(void *data __UNUSED__, void *ret, DBusError *err)
 {
@@ -32,11 +36,42 @@ cb_timer(void *data __UNUSED__)
   static const char *icons[] = {
     "xterm",
     "firefox",
-    "gvim"
+    "gvim",
+    "e"
   };
 
-  snprintf(buf, sizeof(buf), "<i>%s</i> says <b>Hello</b> #%d", icons[num%3], num / 3); 
-  n = e_notification_full_new(icons[num%3], 0, icons[num%3], "Summary", buf, -1);
+  snprintf(buf, sizeof(buf), "<i>%s</i> says <b>Hello</b> #%d", icons[num % 4], num % 4); 
+  n = e_notification_full_new(icons[num % 4], 0, (icons[num % 4][0] != 'e') ? icons[num % 4] : NULL, "Summary", buf, -1);
+
+  if (!e_notification_app_icon_get(n))
+    {
+       Ecore_Evas *ee;
+       Evas_Object *img;
+       E_Notification_Image *i;
+       ee = ecore_evas_buffer_new(1, 1);
+       if (ee)
+         {
+            img = evas_object_image_add(ecore_evas_get(ee));
+            evas_object_image_file_set(img, LOGO, NULL);
+            if (evas_object_image_load_error_get(img) != EVAS_LOAD_ERROR_NONE)
+              evas_object_image_file_set(img, "logo.png", NULL);
+            if (evas_object_image_load_error_get(img) != EVAS_LOAD_ERROR_NONE)
+              {
+                 fprintf(stderr, "ERROR LOADING IMAGE: %s\n", LOGO);
+                 evas_object_del(img);
+                 img = NULL;
+              }
+            else
+              ecore_evas_manual_render(ee);
+
+            i = e_notification_image_new();
+            if (e_notification_image_init(i, img))
+              e_notification_hint_image_data_set(n, i);
+           evas_object_del(img);
+           ecore_evas_free(ee);
+         }
+    }
+
   e_notification_send(n, cb_sent, NULL);
   e_notification_unref(n);
   num++;
@@ -75,6 +110,7 @@ main()
 {
   int ret = 0;
   ecore_init();
+  ecore_evas_init();
   if (e_notification_init())
   {
     ecore_timer_add(1, cb_timer, NULL);
@@ -82,6 +118,7 @@ main()
     e_notification_shutdown();
   }
 
+  ecore_evas_shutdown();
   ecore_shutdown();
   return ret;
 }