From ddedefc72c14506c84d3a7326d3c23474a9c4b96 Mon Sep 17 00:00:00 2001 From: tanya Date: Tue, 18 May 2010 17:40:10 +0300 Subject: [PATCH] remaked take notification with dbus --- applet/src/livewp-actor.c | 33 ++++++++++++++++++++------------- applet/src/livewp-actor.h | 1 + applet/src/livewp-common.h | 1 + applet/src/livewp-rules.c | 11 +++++------ applet/src/livewp-scene.c | 2 ++ 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/applet/src/livewp-actor.c b/applet/src/livewp-actor.c index f37ea91..916880f 100644 --- a/applet/src/livewp-actor.c +++ b/applet/src/livewp-actor.c @@ -141,16 +141,12 @@ int get_notify_count(gchar *notify_type) } return result; } - -void -change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin) +void read_notification(AWallpaperPlugin *desktop_plugin) { - GtkWidget *label; - gchar *message = NULL, *mes = NULL; - PangoFontDescription *pfd = NULL; + gchar *message = NULL; gint count = 0; - label = actor->image; + fprintf(stderr, "read notification \n"); count = get_notify_count("missed"); if (count > 0){ message = g_strdup_printf("%s: %d", _("Missed calls"), count); @@ -179,18 +175,29 @@ change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin) message = g_strdup_printf("%s: %d", _("Missed mail"), count); } } + desktop_plugin->priv->scene->notification = g_strdup(message); + g_free(message); +} - //fprintf(stderr, "message = %s", message); - if (message){ - mes = g_markup_printf_escaped("%s", "#FFFFFF", "#000000", message); +void +change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin) +{ + GtkWidget *label; + gchar *mes = NULL; + PangoFontDescription *pfd = NULL; + + + if (desktop_plugin->priv->scene->notification){ + label = actor->image; + mes = g_markup_printf_escaped("%s", "#FFFFFF", "#000000", + desktop_plugin->priv->scene->notification); gtk_label_set_markup(GTK_LABEL(label), mes); - g_free(message); - pfd = pango_font_description_from_string("Sans 14"); + pfd = pango_font_description_from_string("Sans 16"); gtk_widget_modify_font(GTK_WIDGET(label), NULL); gtk_widget_modify_font(GTK_WIDGET(label), pfd); pango_font_description_free(pfd); - actor->time_start_animation = time(NULL) + 20; } + actor->time_start_animation = time(NULL) + 20; } diff --git a/applet/src/livewp-actor.h b/applet/src/livewp-actor.h index cfe92a5..16b9ea4 100644 --- a/applet/src/livewp-actor.h +++ b/applet/src/livewp-actor.h @@ -71,6 +71,7 @@ Actor* init_object(AWallpaperPlugin *desktop_plugin, GPtrArray *child ); void destroy_actor(Actor *actor); +void read_notification(AWallpaperPlugin *desktop_plugin); void set_actor_position(Actor *actor, gint x, gint y, gint z, AWallpaperPlugin *desktop_plugin); void set_actor_scale(Actor *actor, double scalex, double scaley); void set_actor_visible(Actor *actor, gboolean visible); diff --git a/applet/src/livewp-common.h b/applet/src/livewp-common.h index 87e4b53..6462971 100644 --- a/applet/src/livewp-common.h +++ b/applet/src/livewp-common.h @@ -60,6 +60,7 @@ struct _Scene gint wind_orientation; // +/- 1 double wind_angle; // [-1 .. 1] guint seed; /* init value for random */ + gchar *notification; }; typedef struct _AWallpaperPlugin AWallpaperPlugin; typedef struct _AWallpaperPluginClass AWallpaperPluginClass; diff --git a/applet/src/livewp-rules.c b/applet/src/livewp-rules.c index d32e834..7658e6e 100644 --- a/applet/src/livewp-rules.c +++ b/applet/src/livewp-rules.c @@ -150,12 +150,11 @@ int get_moon_phase() gint fast_rnd(gint max) { -/* guint offset = 12923; */ -/* guint multiplier = 4079; */ - - //*seed = *seed * multiplier + offset; - //return (gint)(*seed % max); - guint seed = time(NULL); + guint offset = 12923; + guint multiplier = 4079; + static guint seed = 123; + + seed = seed * multiplier + offset; return (gint)(seed % max); } void diff --git a/applet/src/livewp-scene.c b/applet/src/livewp-scene.c index d012083..ebf8aa5 100644 --- a/applet/src/livewp-scene.c +++ b/applet/src/livewp-scene.c @@ -158,7 +158,9 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) scene->wind_angle = 0.3; /* init value for random */ scene->seed = time(NULL); + scene->notification = NULL; desktop_plugin->priv->scene = scene; + read_notification(desktop_plugin); actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, 5, 800, 480, -- 1.7.9.5