summaryrefslogtreecommitdiffstats
path: root/src/splash-plugins
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2008-06-12 17:29:16 -0400
committerRay Strode <rstrode@redhat.com>2008-06-12 17:32:02 -0400
commit54a651f30cb40c4adbba610aff86d20a4bc38e52 (patch)
tree4d25dac061aa763f13fc77e4249725d65349180c /src/splash-plugins
parent76d837e38783f635e1cb7b258034b82e7ef7bee1 (diff)
downloadplymouth-54a651f30cb40c4adbba610aff86d20a4bc38e52.tar.gz
plymouth-54a651f30cb40c4adbba610aff86d20a4bc38e52.tar.xz
plymouth-54a651f30cb40c4adbba610aff86d20a4bc38e52.zip
Move throbber to libplybootsplash
Diffstat (limited to 'src/splash-plugins')
-rw-r--r--src/splash-plugins/spinfinity/Makefile.am4
-rw-r--r--src/splash-plugins/spinfinity/plugin.c18
-rw-r--r--src/splash-plugins/spinfinity/throbber.c333
-rw-r--r--src/splash-plugins/spinfinity/throbber.h53
4 files changed, 10 insertions, 398 deletions
diff --git a/src/splash-plugins/spinfinity/Makefile.am b/src/splash-plugins/spinfinity/Makefile.am
index 8a22804..485b19f 100644
--- a/src/splash-plugins/spinfinity/Makefile.am
+++ b/src/splash-plugins/spinfinity/Makefile.am
@@ -17,9 +17,7 @@ spinfinity_la_LDFLAGS = -module -avoid-version -export-dynamic
spinfinity_la_LIBADD = $(PLYMOUTH_LIBS) \
../../libply/libply.la \
../../libplybootsplash/libplybootsplash.la
-spinfinity_la_SOURCES = $(srcdir)/plugin.c \
- $(srcdir)/throbber.h \
- $(srcdir)/throbber.c
+spinfinity_la_SOURCES = $(srcdir)/plugin.c
throbber_frames = \
throbber-00.png \
diff --git a/src/splash-plugins/spinfinity/plugin.c b/src/splash-plugins/spinfinity/plugin.c
index 07f9ffd..8b95c0e 100644
--- a/src/splash-plugins/spinfinity/plugin.c
+++ b/src/splash-plugins/spinfinity/plugin.c
@@ -50,7 +50,7 @@
#include "ply-utils.h"
#include "ply-window.h"
-#include "throbber.h"
+#include "ply-throbber.h"
#include <linux/kd.h>
@@ -77,7 +77,7 @@ struct _ply_boot_splash_plugin
ply_window_t *window;
entry_t *entry;
- throbber_t *throbber;
+ ply_throbber_t *throbber;
ply_answer_t *pending_password_answer;
};
@@ -99,7 +99,7 @@ create_plugin (void)
plugin->entry_image = ply_image_new (PLYMOUTH_IMAGE_DIR "spinfinity/entry.png");
plugin->box_image = ply_image_new (PLYMOUTH_IMAGE_DIR "spinfinity/box.png");
- plugin->throbber = throbber_new (PLYMOUTH_IMAGE_DIR "spinfinity",
+ plugin->throbber = ply_throbber_new (PLYMOUTH_IMAGE_DIR "spinfinity",
"throbber-");
return plugin;
@@ -140,7 +140,7 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
ply_image_free (plugin->entry_image);
ply_image_free (plugin->box_image);
ply_image_free (plugin->lock_image);
- throbber_free (plugin->throbber);
+ ply_throbber_free (plugin->throbber);
free (plugin);
}
@@ -189,9 +189,9 @@ start_animation (ply_boot_splash_plugin_t *plugin)
ply_frame_buffer_get_size (plugin->frame_buffer, &area);
- width = throbber_get_width (plugin->throbber);
- height = throbber_get_height (plugin->throbber);
- throbber_start (plugin->throbber,
+ width = ply_throbber_get_width (plugin->throbber);
+ height = ply_throbber_get_height (plugin->throbber);
+ ply_throbber_start (plugin->throbber,
plugin->loop,
plugin->window,
area.width / 2.0 - width / 2.0,
@@ -206,7 +206,7 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
assert (plugin != NULL);
assert (plugin->loop != NULL);
- throbber_stop (plugin->throbber);
+ ply_throbber_stop (plugin->throbber);
for (i = 0; i < 10; i++)
{
@@ -325,7 +325,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
return false;
ply_trace ("loading throbber");
- if (!throbber_load (plugin->throbber))
+ if (!ply_throbber_load (plugin->throbber))
return false;
plugin->window = window;
diff --git a/src/splash-plugins/spinfinity/throbber.c b/src/splash-plugins/spinfinity/throbber.c
deleted file mode 100644
index 998f229..0000000
--- a/src/splash-plugins/spinfinity/throbber.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* throbber.c - boot throbber
- *
- * Copyright (C) 2007, 2008 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written by: Ray Strode <rstrode@redhat.com>
- */
-#include "config.h"
-
-#include <assert.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <math.h>
-#include <signal.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <values.h>
-#include <unistd.h>
-#include <wchar.h>
-
-#include "throbber.h"
-#include "ply-event-loop.h"
-#include "ply-array.h"
-#include "ply-logger.h"
-#include "ply-frame-buffer.h"
-#include "ply-image.h"
-#include "ply-utils.h"
-#include "ply-window.h"
-
-#include <linux/kd.h>
-
-#ifndef FRAMES_PER_SECOND
-#define FRAMES_PER_SECOND 30
-#endif
-
-struct _throbber
-{
- ply_array_t *frames;
- ply_event_loop_t *loop;
- char *image_dir;
- char *frames_prefix;
-
- ply_window_t *window;
- ply_frame_buffer_t *frame_buffer;
- ply_frame_buffer_area_t frame_area;
-
- long x, y;
- long width, height;
- double start_time, now;
-};
-
-throbber_t *
-throbber_new (const char *image_dir,
- const char *frames_prefix)
-{
- throbber_t *throbber;
-
- assert (image_dir != NULL);
- assert (frames_prefix != NULL);
-
- throbber = calloc (1, sizeof (throbber_t));
-
- throbber->frames = ply_array_new ();
- throbber->frames_prefix = strdup (frames_prefix);
- throbber->image_dir = strdup (image_dir);
- throbber->width = 0;
- throbber->height = 0;
- throbber->frame_area.width = 0;
- throbber->frame_area.height = 0;
- throbber->frame_area.x = 0;
- throbber->frame_area.y = 0;
-
- return throbber;
-}
-
-static void
-throbber_remove_frames (throbber_t *throbber)
-{
- int i;
- ply_image_t **frames;
-
- frames = (ply_image_t **) ply_array_steal_elements (throbber->frames);
- for (i = 0; frames[i] != NULL; i++)
- ply_image_free (frames[i]);
- free (frames);
-}
-
-void
-throbber_free (throbber_t *throbber)
-{
- if (throbber == NULL)
- return;
-
- throbber_remove_frames (throbber);
- ply_array_free (throbber->frames);
-
- free (throbber->frames_prefix);
- free (throbber->image_dir);
- free (throbber);
-}
-
-static void
-animate_at_time (throbber_t *throbber,
- double time)
-{
- int number_of_frames;
- int frame_number;
- ply_image_t * const * frames;
- uint32_t *frame_data;
-
- ply_window_set_mode (throbber->window, PLY_WINDOW_MODE_GRAPHICS);
-
- number_of_frames = ply_array_get_size (throbber->frames);
-
- if (number_of_frames == 0)
- return;
-
- frame_number = (.5 * sin (time) + .5) * number_of_frames;
-
- ply_frame_buffer_pause_updates (throbber->frame_buffer);
- if (throbber->frame_area.width > 0)
- ply_frame_buffer_fill_with_hex_color (throbber->frame_buffer, &throbber->frame_area,
- PLYMOUTH_BACKGROUND_COLOR);
-
- frames = (ply_image_t * const *) ply_array_get_elements (throbber->frames);
-
- throbber->frame_area.x = throbber->x;
- throbber->frame_area.y = throbber->y;
- throbber->frame_area.width = ply_image_get_width (frames[frame_number]);
- throbber->frame_area.height = ply_image_get_height (frames[frame_number]);
- frame_data = ply_image_get_data (frames[frame_number]);
-
- ply_frame_buffer_fill_with_argb32_data (throbber->frame_buffer,
- &throbber->frame_area, 0, 0,
- frame_data);
- ply_frame_buffer_unpause_updates (throbber->frame_buffer);
-}
-
-static void
-on_timeout (throbber_t *throbber)
-{
- double sleep_time;
- throbber->now = ply_get_timestamp ();
-
-#ifdef REAL_TIME_ANIMATION
- animate_at_time (throbber,
- throbber->now - throbber->start_time);
-#else
- static double time = 0.0;
- time += 1.0 / FRAMES_PER_SECOND;
- animate_at_time (throbber, time);
-#endif
-
- sleep_time = 1.0 / FRAMES_PER_SECOND;
- sleep_time = MAX (sleep_time - (ply_get_timestamp () - throbber->now),
- 0.005);
-
- ply_event_loop_watch_for_timeout (throbber->loop,
- sleep_time,
- (ply_event_loop_timeout_handler_t)
- on_timeout, throbber);
-}
-
-static bool
-throbber_add_frame (throbber_t *throbber,
- const char *filename)
-{
- ply_image_t *image;
-
- image = ply_image_new (filename);
-
- if (!ply_image_load (image))
- {
- ply_image_free (image);
- return false;
- }
-
- ply_array_add_element (throbber->frames, image);
-
- throbber->width = MAX (throbber->width, ply_image_get_width (image));
- throbber->height = MAX (throbber->width, ply_image_get_height (image));
-
- return true;
-}
-
-static bool
-throbber_add_frames (throbber_t *throbber)
-{
- struct dirent **entries;
- int number_of_entries;
- int i;
- bool load_finished;
-
- entries = NULL;
-
- number_of_entries = scandir (throbber->image_dir, &entries, NULL, versionsort);
-
- if (number_of_entries < 0)
- return false;
-
- load_finished = false;
- for (i = 0; i < number_of_entries; i++)
- {
- if (strncmp (entries[i]->d_name,
- throbber->frames_prefix,
- strlen (throbber->frames_prefix)) == 0
- && (strlen (entries[i]->d_name) > 4)
- && strcmp (entries[i]->d_name + strlen (entries[i]->d_name) - 4, ".png") == 0)
- {
- char *filename;
-
- filename = NULL;
- asprintf (&filename, "%s/%s", throbber->image_dir, entries[i]->d_name);
-
- if (!throbber_add_frame (throbber, filename))
- goto out;
-
- free (filename);
- }
-
- free (entries[i]);
- entries[i] = NULL;
- }
- load_finished = true;
-
-out:
- if (!load_finished)
- {
- throbber_remove_frames (throbber);
-
- while (entries[i] != NULL)
- {
- free (entries[i]);
- i++;
- }
- }
- free (entries);
-
- return load_finished;
-}
-
-bool
-throbber_load (throbber_t *throbber)
-{
- if (ply_array_get_size (throbber->frames) != 0)
- throbber_remove_frames (throbber->frames);
-
- if (!throbber_add_frames (throbber))
- return false;
-
- return true;
-}
-
-bool
-throbber_start (throbber_t *throbber,
- ply_event_loop_t *loop,
- ply_window_t *window,
- long x,
- long y)
-{
- assert (throbber != NULL);
- assert (throbber->loop == NULL);
-
- throbber->loop = loop;
- throbber->window = window;
- throbber->frame_buffer = ply_window_get_frame_buffer (window);;
-
- throbber->x = x;
- throbber->y = y;
-
- throbber->start_time = ply_get_timestamp ();
-
- ply_event_loop_watch_for_timeout (throbber->loop,
- 1.0 / FRAMES_PER_SECOND,
- (ply_event_loop_timeout_handler_t)
- on_timeout, throbber);
-
- return true;
-}
-
-void
-throbber_stop (throbber_t *throbber)
-{
- if (throbber->frame_area.width > 0)
- ply_frame_buffer_fill_with_hex_color (throbber->frame_buffer, &throbber->frame_area,
- PLYMOUTH_BACKGROUND_COLOR);
- throbber->frame_buffer = NULL;
- throbber->window = NULL;
-
- if (throbber->loop != NULL)
- {
- ply_event_loop_stop_watching_for_timeout (throbber->loop,
- (ply_event_loop_timeout_handler_t)
- on_timeout, throbber);
- throbber->loop = NULL;
- }
-}
-
-long
-throbber_get_width (throbber_t *throbber)
-{
- return throbber->width;
-}
-
-long
-throbber_get_height (throbber_t *throbber)
-{
- return throbber->height;
-}
-
-/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
diff --git a/src/splash-plugins/spinfinity/throbber.h b/src/splash-plugins/spinfinity/throbber.h
deleted file mode 100644
index c1e7b1a..0000000
--- a/src/splash-plugins/spinfinity/throbber.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* throbber.h - simple throbber animation
- *
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written By: Ray Strode <rstrode@redhat.com>
- */
-#ifndef THROBBER_H
-#define THROBBER_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <unistd.h>
-
-#include "ply-event-loop.h"
-#include "ply-frame-buffer.h"
-#include "ply-window.h"
-
-typedef struct _throbber throbber_t;
-
-#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
-throbber_t *throbber_new (const char *image_dir,
- const char *frames_prefix);
-void throbber_free (throbber_t *throbber);
-
-bool throbber_load (throbber_t *throbber);
-bool throbber_start (throbber_t *throbber,
- ply_event_loop_t *loop,
- ply_window_t *window,
- long x,
- long y);
-void throbber_stop (throbber_t *throbber);
-
-long throbber_get_width (throbber_t *throbber);
-long throbber_get_height (throbber_t *throbber);
-#endif
-
-#endif /* THROBBER_H */
-/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */