#include <string.h>
#include <libhildondesktop/libhildondesktop.h>
+#include <mce/dbus-names.h>
+#include <mce/mode-names.h>
#include "eyes.h"
#include "themes.h"
HD_DEFINE_PLUGIN_MODULE (EyesPlugin, eyes_plugin, HD_TYPE_HOME_PLUGIN_ITEM)
+static void eyes_check_display(DBusGProxy *object, const char *status, EyesPluginContent *eyes);
+
/*****************************
*** Eyes Plugin Functions ***
*****************************/
if (eyes->pupil_filename != NULL)
g_free(eyes->pupil_filename);
+ if (eyes->proxy != NULL)
+ dbus_g_proxy_disconnect_signal (eyes->proxy, MCE_DISPLAY_SIG, G_CALLBACK(eyes_check_display), eyes);
+
g_free(eyes);
}
setup_eyes(eyes);
eyes_applet_fill(eyes);
+ eyes->visible = TRUE;
+
return eyes;
}
static void
eyes_check_desktop (GObject *gobject, GParamSpec *pspec, EyesPluginContent *eyes)
+
{
g_warning ("eyes_check_desktop");
gchar *name = pspec->name;
g_object_get (gobject, name, &status, NULL);
if (status) {
eyes_applet_fill(eyes);
+ eyes->visible = TRUE;
} else if (eyes->timeout_id != 0) {
g_source_remove (eyes->timeout_id);
eyes->timeout_id = 0;
+ eyes->visible = FALSE;
}
}
static void
+eyes_check_display(DBusGProxy *object, const char *status, EyesPluginContent *eyes)
+{
+ if (strncmp(status, MCE_DISPLAY_ON_STRING,
+ strlen(MCE_DISPLAY_ON_STRING) + 1) == 0
+ && eyes-> visible)
+ {
+ hildon_banner_show_information(NULL, NULL, eyes->theme_name);
+ eyes_applet_fill(eyes);
+ }
+ else if (strncmp(status, MCE_DISPLAY_OFF_STRING,
+ strlen(MCE_DISPLAY_OFF_STRING) + 1) == 0)
+ {
+ if (eyes->timeout_id != 0)
+ {
+ g_source_remove (eyes->timeout_id);
+ eyes->timeout_id = 0;
+ }
+ }
+
+}
+
+static void
eyes_plugin_dispose (GObject *object)
{
g_warning ("eyes_plugin_dispose");
g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
G_CALLBACK (eyes_check_desktop), eyes);
+ eyes->dbus_conn = NULL;
+ eyes->proxy = NULL;
+
+ eyes->dbus_conn = hd_home_plugin_item_get_dbus_g_connection ( &desktop_plugin->hitem, DBUS_BUS_SYSTEM, NULL );
+ if (eyes->dbus_conn != NULL)
+ {
+ eyes->proxy = dbus_g_proxy_new_for_name(eyes->dbus_conn, MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF);
+ dbus_g_proxy_add_signal (eyes->proxy, MCE_DISPLAY_SIG, G_TYPE_STRING, G_TYPE_INVALID );
+ dbus_g_proxy_connect_signal(eyes->proxy, MCE_DISPLAY_SIG, G_CALLBACK(eyes_check_display),eyes,NULL);
+ }
+
gtk_container_add (GTK_CONTAINER (desktop_plugin), eyes->align);
}