summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device.c22
-rw-r--r--src/device.h1
-rw-r--r--src/gui.c30
3 files changed, 53 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 3d42419..a76b6e7 100644
--- a/src/device.c
+++ b/src/device.c
@@ -169,6 +169,28 @@ gboolean device_sbs_set_iconstate(sbservices_client_t sbc, plist_t iconstate, GE
return result;
}
+gboolean device_sbs_save_wallpaper(sbservices_client_t sbc, const char *filename, GError **error)
+{
+ gboolean res = FALSE;
+ char *png = NULL;
+ uint64_t pngsize = 0;
+
+ if ((sbservices_get_home_screen_wallpaper_pngdata(sbc, &png, &pngsize) == SBSERVICES_E_SUCCESS) && (pngsize > 0)) {
+ /* save png icon to disk */
+ FILE *f = fopen(filename, "w");
+ fwrite(png, 1, pngsize, f);
+ fclose(f);
+ res = TRUE;
+ } else {
+ if (error)
+ *error = g_error_new(device_domain, EIO, _("Could not get wallpaper png data"));
+ }
+ if (png) {
+ free(png);
+ }
+ return res;
+}
+
device_info_t device_info_new()
{
return g_new0(struct device_info_int, 1);
diff --git a/src/device.h b/src/device.h
index cfe4d54..b89f0ea 100644
--- a/src/device.h
+++ b/src/device.h
@@ -42,6 +42,7 @@ void device_sbs_free(sbservices_client_t sbc);
gboolean device_sbs_get_iconstate(sbservices_client_t sbc, plist_t *iconstate, GError **error);
gboolean device_sbs_save_icon(sbservices_client_t sbc, char *display_identifier, char *filename, GError **error);
gboolean device_sbs_set_iconstate(sbservices_client_t sbc, plist_t iconstate, GError **error);
+gboolean device_sbs_save_wallpaper(sbservices_client_t sbc, const char *filename, GError **error);
device_info_t device_info_new();
void device_info_free(device_info_t device_info);
diff --git a/src/gui.c b/src/gui.c
index e1fdbcf..a76034d 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -72,6 +72,7 @@ const ClutterActorBox left_trigger = { -30.0, 16.0, -8.0, STAGE_HEIGHT - DOCK_HE
const ClutterActorBox right_trigger = { STAGE_WIDTH + 8.0, 16.0, STAGE_WIDTH + 30.0, STAGE_HEIGHT - DOCK_HEIGHT - 16.0 };
ClutterActor *stage = NULL;
+ClutterActor *wallpaper = NULL;
ClutterActor *the_dock = NULL;
ClutterActor *the_sb = NULL;
ClutterActor *type_label = NULL;
@@ -138,6 +139,10 @@ static void pages_free()
sbpage_free(dockitems, NULL);
dockitems = NULL;
}
+ if (wallpaper) {
+ clutter_actor_destroy(wallpaper);
+ wallpaper = NULL;
+ }
}
static void clutter_actor_get_abs_center(ClutterActor *actor, gfloat *center_x, gfloat *center_y)
@@ -1108,6 +1113,26 @@ static gboolean wait_icon_load_finished(gpointer user_data)
return res;
}
+static void gui_set_wallpaper(const char *wp)
+{
+ GError *err = NULL;
+ wallpaper = NULL;
+ ClutterActor *actor = clutter_texture_new();
+ clutter_texture_set_load_async(CLUTTER_TEXTURE(actor), TRUE);
+ clutter_texture_set_from_file(CLUTTER_TEXTURE(actor), wp, &err);
+ if (err) {
+ g_error_free(err);
+ err = NULL;
+ return;
+ }
+ clutter_actor_set_size(actor, 320.0, 480.0);
+ clutter_actor_set_position(actor, 0, 0);
+ clutter_actor_show(actor);
+ clutter_group_add(CLUTTER_GROUP(stage), actor);
+ clutter_actor_lower_bottom(actor);
+ wallpaper = actor;
+}
+
static gboolean gui_pages_init_cb(gpointer user_data)
{
const char *uuid = (const char*)user_data;
@@ -1131,6 +1156,11 @@ static gboolean gui_pages_init_cb(gpointer user_data)
}
if (sbc) {
+ /* Load wallpaper if available */
+ if (device_sbs_save_wallpaper(sbc, "/tmp/wallpaper.png", &error)) {
+ gui_set_wallpaper("/tmp/wallpaper.png");
+ }
+
/* Load icon data */
if (device_sbs_get_iconstate(sbc, &iconstate, &error)) {
gui_set_iconstate(iconstate);