[Xfce4-commits] [apps/xfce4-screensaver] 419/425: Convert tabs to spaces for savers/*.{c, h}
noreply at xfce.org
noreply at xfce.org
Mon Oct 15 01:54:26 CEST 2018
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screensaver.
commit e05784c8a7fcbfa7baee836517700d1f5c04301a
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sat Oct 13 13:49:21 2018 -0400
Convert tabs to spaces for savers/*.{c,h}
---
savers/floaters.c | 1536 +++++++++++++++++++++---------------------
savers/gs-theme-engine.c | 176 ++---
savers/gs-theme-engine.h | 30 +-
savers/gs-theme-window.c | 208 +++---
savers/gs-theme-window.h | 22 +-
savers/gste-popsquares.c | 852 +++++++++++------------
savers/gste-popsquares.h | 12 +-
savers/gste-slideshow.c | 1515 ++++++++++++++++++++---------------------
savers/gste-slideshow.h | 16 +-
savers/popsquares.c | 55 +-
savers/slideshow.c | 200 +++---
savers/xdg-user-dir-lookup.c | 240 +++----
12 files changed, 2431 insertions(+), 2431 deletions(-)
diff --git a/savers/floaters.c b/savers/floaters.c
index 77eb4f0..e0d2c9a 100644
--- a/savers/floaters.c
+++ b/savers/floaters.c
@@ -84,37 +84,37 @@ static gchar **filenames = NULL;
static GOptionEntry options[] =
{
- {
- "show-paths", 'p', 0, G_OPTION_ARG_NONE, &should_show_paths,
- N_("Show paths that images follow"), NULL
- },
-
- {
- "do-rotations", 'r', 0, G_OPTION_ARG_NONE, &should_do_rotations,
- N_("Occasionally rotate images as they move"), NULL
- },
-
- {
- "print-stats", 's', 0, G_OPTION_ARG_NONE, &should_print_stats,
- N_("Print out frame rate and other statistics"), NULL
- },
-
- {
- "number-of-images", 'n', 0, G_OPTION_ARG_INT, &max_floater_count,
- N_("The maximum number of images to keep on screen"), N_("MAX_IMAGES")
- },
-
- {
- "geometry", 0, 0, G_OPTION_ARG_STRING, &geometry,
- N_("The initial size and position of window"), N_("WIDTHxHEIGHT+X+Y")
- },
-
- {
- G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
- N_("The source image to use"), NULL
- },
-
- {NULL}
+ {
+ "show-paths", 'p', 0, G_OPTION_ARG_NONE, &should_show_paths,
+ N_("Show paths that images follow"), NULL
+ },
+
+ {
+ "do-rotations", 'r', 0, G_OPTION_ARG_NONE, &should_do_rotations,
+ N_("Occasionally rotate images as they move"), NULL
+ },
+
+ {
+ "print-stats", 's', 0, G_OPTION_ARG_NONE, &should_print_stats,
+ N_("Print out frame rate and other statistics"), NULL
+ },
+
+ {
+ "number-of-images", 'n', 0, G_OPTION_ARG_INT, &max_floater_count,
+ N_("The maximum number of images to keep on screen"), N_("MAX_IMAGES")
+ },
+
+ {
+ "geometry", 0, 0, G_OPTION_ARG_STRING, &geometry,
+ N_("The initial size and position of window"), N_("WIDTHxHEIGHT+X+Y")
+ },
+
+ {
+ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
+ N_("The source image to use"), NULL
+ },
+
+ {NULL}
};
@@ -127,85 +127,85 @@ typedef struct _ScreenSaver ScreenSaver;
struct _Point
{
- gdouble x, y;
+ gdouble x, y;
};
struct _Path
{
- Point start_point;
- Point start_control_point;
- Point end_control_point;
- Point end_point;
+ Point start_point;
+ Point start_control_point;
+ Point end_control_point;
+ Point end_point;
- gdouble x_linear_coefficient,
- y_linear_coefficient;
+ gdouble x_linear_coefficient,
+ y_linear_coefficient;
- gdouble x_quadratic_coefficient,
- y_quadratic_coefficient;
+ gdouble x_quadratic_coefficient,
+ y_quadratic_coefficient;
- gdouble x_cubic_coefficient,
- y_cubic_coefficient;
+ gdouble x_cubic_coefficient,
+ y_cubic_coefficient;
- gdouble duration;
+ gdouble duration;
};
struct _CachedSource
{
- cairo_pattern_t *pattern;
- gint width, height;
+ cairo_pattern_t *pattern;
+ gint width, height;
};
struct _Rectangle
{
- Point top_left_point;
- Point bottom_right_point;
+ Point top_left_point;
+ Point bottom_right_point;
};
struct _ScreenSaverFloater
{
- GdkRectangle bounds;
+ GdkRectangle bounds;
- Point start_position;
- Point position;
+ Point start_position;
+ Point position;
- gdouble scale;
- gdouble opacity;
+ gdouble scale;
+ gdouble opacity;
- Path *path;
- gdouble path_start_time;
- gdouble path_start_scale;
- gdouble path_end_scale;
+ Path *path;
+ gdouble path_start_time;
+ gdouble path_start_scale;
+ gdouble path_end_scale;
- gdouble angle;
- gdouble angle_increment;
+ gdouble angle;
+ gdouble angle_increment;
};
struct _ScreenSaver
{
- GtkWidget *drawing_area;
- Rectangle canvas_rectangle;
- GHashTable *cached_sources;
+ GtkWidget *drawing_area;
+ Rectangle canvas_rectangle;
+ GHashTable *cached_sources;
- char *filename;
+ char *filename;
- gdouble first_update_time;
+ gdouble first_update_time;
- gdouble last_calculated_stats_time,
- current_calculated_stats_time;
- gint update_count, frame_count;
+ gdouble last_calculated_stats_time,
+ current_calculated_stats_time;
+ gint update_count, frame_count;
- gdouble updates_per_second;
- gdouble frames_per_second;
+ gdouble updates_per_second;
+ gdouble frames_per_second;
- guint state_update_timeout_id;
- guint stats_update_timeout_id;
+ guint state_update_timeout_id;
+ guint stats_update_timeout_id;
- GList *floaters;
- gint max_floater_count;
+ GList *floaters;
+ gint max_floater_count;
- guint should_do_rotations: 1;
- guint should_show_paths : 1;
- guint draw_ops_pending : 1;
+ guint should_do_rotations: 1;
+ guint should_show_paths : 1;
+ guint draw_ops_pending : 1;
};
static Path *path_new (Point *start_point,
@@ -216,48 +216,48 @@ static Path *path_new (Point *start_point,
static void path_free (Path *path);
static ScreenSaverFloater *screen_saver_floater_new (ScreenSaver *screen_saver,
- Point *position,
- gdouble scale);
+ Point *position,
+ gdouble scale);
static void screen_saver_floater_free (ScreenSaver *screen_saver,
ScreenSaverFloater *floater);
static gboolean screen_saver_floater_is_off_canvas (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater);
+ ScreenSaverFloater *floater);
static gboolean screen_saver_floater_should_bubble_up (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble performance_ratio,
- gdouble *duration);
+ ScreenSaverFloater *floater,
+ gdouble performance_ratio,
+ gdouble *duration);
static gboolean screen_saver_floater_should_come_on_screen (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble performance_ratio,
- gdouble *duration);
+ ScreenSaverFloater *floater,
+ gdouble performance_ratio,
+ gdouble *duration);
static Point screen_saver_floater_get_position_from_time (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time);
+ ScreenSaverFloater *floater,
+ gdouble time);
static gdouble screen_saver_floater_get_scale_from_time (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time);
+ ScreenSaverFloater *floater,
+ gdouble time);
static gdouble screen_saver_floater_get_angle_from_time (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time);
+ ScreenSaverFloater *floater,
+ gdouble time);
static Path *screen_saver_floater_create_path_to_on_screen (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble duration);
+ ScreenSaverFloater *floater,
+ gdouble duration);
static Path *screen_saver_floater_create_path_to_bubble_up (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble duration);
+ ScreenSaverFloater *floater,
+ gdouble duration);
static Path *screen_saver_floater_create_path_to_random_point (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble duration);
+ ScreenSaverFloater *floater,
+ gdouble duration);
static Path *screen_saver_floater_create_path (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater);
+ ScreenSaverFloater *floater);
static void screen_saver_floater_update_state (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time);
+ ScreenSaverFloater *floater,
+ gdouble time);
static gboolean screen_saver_floater_do_draw (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- cairo_t *context);
+ ScreenSaverFloater *floater,
+ cairo_t *context);
static CachedSource *cached_source_new (cairo_pattern_t *pattern,
gint width,
@@ -282,81 +282,81 @@ static gdouble screen_saver_get_image_cache_usage (ScreenSaver *screen_saver);
static void screen_saver_create_floaters (ScreenSaver *screen_saver);
static void screen_saver_destroy_floaters (ScreenSaver *screen_saver);
static void screen_saver_on_size_allocate (ScreenSaver *screen_saver,
- GtkAllocation *allocation);
-static void screen_saver_on_draw (ScreenSaver *screen_saver,
- cairo_t *context);
+ GtkAllocation *allocation);
+static void screen_saver_on_draw (ScreenSaver *screen_saver,
+ cairo_t *context);
static gboolean do_print_screen_saver_stats (ScreenSaver *screen_saver);
static GdkPixbuf *gamma_correct (const GdkPixbuf *input_pixbuf);
static CachedSource*
cached_source_new (cairo_pattern_t *pattern,
- gint width,
+ gint width,
gint height)
{
- CachedSource *source;
+ CachedSource *source;
- source = g_new (CachedSource, 1);
- source->pattern = cairo_pattern_reference (pattern);
- source->width = width;
- source->height = height;
+ source = g_new (CachedSource, 1);
+ source->pattern = cairo_pattern_reference (pattern);
+ source->width = width;
+ source->height = height;
- return source;
+ return source;
}
static void
cached_source_free (CachedSource *source)
{
- if (source == NULL)
- return;
+ if (source == NULL)
+ return;
- cairo_pattern_destroy (source->pattern);
+ cairo_pattern_destroy (source->pattern);
- g_free (source);
+ g_free (source);
}
static Path *
-path_new (Point *start_point,
- Point *start_control_point,
- Point *end_control_point,
- Point *end_point,
- gdouble duration)
+path_new (Point *start_point,
+ Point *start_control_point,
+ Point *end_control_point,
+ Point *end_point,
+ gdouble duration)
{
- Path *path;
-
- path = g_new (Path, 1);
- path->start_point = *start_point;
- path->start_control_point = *start_control_point;
- path->end_control_point = *end_control_point;
- path->end_point = *end_point;
- path->duration = duration;
-
- /* we precompute the coefficients to the cubic bezier curve here
- * so that we don't have to do it repeatedly later The equation is:
- *
- * B(t) = A * t^3 + B * t^2 + C * t + start_point
- */
- path->x_linear_coefficient = 3 * (start_control_point->x - start_point->x);
- path->x_quadratic_coefficient = 3 * (end_control_point->x -
- start_control_point->x) -
- path->x_linear_coefficient;
- path->x_cubic_coefficient = end_point->x - start_point->x -
- path->x_linear_coefficient -
- path->x_quadratic_coefficient;
-
- path->y_linear_coefficient = 3 * (start_control_point->y - start_point->y);
- path->y_quadratic_coefficient = 3 * (end_control_point->y -
- start_control_point->y) -
- path->y_linear_coefficient;
- path->y_cubic_coefficient = end_point->y - start_point->y -
- path->y_linear_coefficient -
- path->y_quadratic_coefficient;
- return path;
+ Path *path;
+
+ path = g_new (Path, 1);
+ path->start_point = *start_point;
+ path->start_control_point = *start_control_point;
+ path->end_control_point = *end_control_point;
+ path->end_point = *end_point;
+ path->duration = duration;
+
+ /* we precompute the coefficients to the cubic bezier curve here
+ * so that we don't have to do it repeatedly later The equation is:
+ *
+ * B(t) = A * t^3 + B * t^2 + C * t + start_point
+ */
+ path->x_linear_coefficient = 3 * (start_control_point->x - start_point->x);
+ path->x_quadratic_coefficient = 3 * (end_control_point->x -
+ start_control_point->x) -
+ path->x_linear_coefficient;
+ path->x_cubic_coefficient = end_point->x - start_point->x -
+ path->x_linear_coefficient -
+ path->x_quadratic_coefficient;
+
+ path->y_linear_coefficient = 3 * (start_control_point->y - start_point->y);
+ path->y_quadratic_coefficient = 3 * (end_control_point->y -
+ start_control_point->y) -
+ path->y_linear_coefficient;
+ path->y_cubic_coefficient = end_point->y - start_point->y -
+ path->y_linear_coefficient -
+ path->y_quadratic_coefficient;
+ return path;
}
static void
path_free (Path *path)
{
- g_free (path);
+ g_free (path);
}
static ScreenSaverFloater*
@@ -364,70 +364,69 @@ screen_saver_floater_new (ScreenSaver *screen_saver,
Point *position,
gdouble scale)
{
- ScreenSaverFloater *floater;
-
- floater = g_new (ScreenSaverFloater, 1);
- floater->bounds.width = 0;
- floater->start_position = *position;
- floater->position = *position;
- floater->scale = scale;
- floater->opacity = pow (scale, 1.0 / GAMMA);
- floater->path = NULL;
- floater->path_start_time = 0.0;
- floater->path_start_scale = 1.0;
- floater->path_end_scale = 0.0;
-
- floater->angle = 0.0;
- floater->angle_increment = 0.0;
-
- return floater;
+ ScreenSaverFloater *floater;
+
+ floater = g_new (ScreenSaverFloater, 1);
+ floater->bounds.width = 0;
+ floater->start_position = *position;
+ floater->position = *position;
+ floater->scale = scale;
+ floater->opacity = pow (scale, 1.0 / GAMMA);
+ floater->path = NULL;
+ floater->path_start_time = 0.0;
+ floater->path_start_scale = 1.0;
+ floater->path_end_scale = 0.0;
+
+ floater->angle = 0.0;
+ floater->angle_increment = 0.0;
+
+ return floater;
}
void
screen_saver_floater_free (ScreenSaver *screen_saver,
ScreenSaverFloater *floater)
{
- if (floater == NULL)
- return;
+ if (floater == NULL)
+ return;
- path_free (floater->path);
+ path_free (floater->path);
- g_free (floater);
+ g_free (floater);
}
static gboolean
screen_saver_floater_is_off_canvas (ScreenSaver *screen_saver,
ScreenSaverFloater *floater)
{
- if ((floater->position.x < screen_saver->canvas_rectangle.top_left_point.x) ||
- (floater->position.x > screen_saver->canvas_rectangle.bottom_right_point.x) ||
- (floater->position.y < screen_saver->canvas_rectangle.top_left_point.y) ||
- (floater->position.y > screen_saver->canvas_rectangle.bottom_right_point.y))
- return TRUE;
+ if ((floater->position.x < screen_saver->canvas_rectangle.top_left_point.x) ||
+ (floater->position.x > screen_saver->canvas_rectangle.bottom_right_point.x) ||
+ (floater->position.y < screen_saver->canvas_rectangle.top_left_point.y) ||
+ (floater->position.y > screen_saver->canvas_rectangle.bottom_right_point.y))
+ return TRUE;
- return FALSE;
+ return FALSE;
}
static gboolean
screen_saver_floater_should_come_on_screen (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble performance_ratio,
- gdouble *duration)
+ ScreenSaverFloater *floater,
+ gdouble performance_ratio,
+ gdouble *duration)
{
+ if (!screen_saver_floater_is_off_canvas (screen_saver, floater))
+ return FALSE;
- if (!screen_saver_floater_is_off_canvas (screen_saver, floater))
- return FALSE;
+ if ((abs (performance_ratio - .5) >= G_MINDOUBLE) &&
+ (g_random_double () > .5))
+ {
+ if (duration)
+ *duration = g_random_double_range (3.0, 7.0);
- if ((abs (performance_ratio - .5) >= G_MINDOUBLE) &&
- (g_random_double () > .5))
- {
- if (duration)
- *duration = g_random_double_range (3.0, 7.0);
+ return TRUE;
+ }
- return TRUE;
- }
-
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -436,164 +435,163 @@ screen_saver_floater_should_bubble_up (ScreenSaver *screen_saver,
gdouble performance_ratio,
gdouble *duration)
{
+ if ((performance_ratio < .5) && (g_random_double () > .5))
+ {
+ if (duration)
+ *duration = performance_ratio * 30.0;
- if ((performance_ratio < .5) && (g_random_double () > .5))
- {
- if (duration)
- *duration = performance_ratio * 30.0;
-
- return TRUE;
- }
+ return TRUE;
+ }
- if ((floater->scale < .3) && (g_random_double () > .6))
- {
- if (duration)
- *duration = 30.0;
+ if ((floater->scale < .3) && (g_random_double () > .6))
+ {
+ if (duration)
+ *duration = 30.0;
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static Point
screen_saver_floater_get_position_from_time (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time)
+ ScreenSaverFloater *floater,
+ gdouble time)
{
- Point point;
+ Point point;
- time = time / floater->path->duration;
+ time = time / floater->path->duration;
- point.x = floater->path->x_cubic_coefficient * (time * time * time) +
- floater->path->x_quadratic_coefficient * (time * time) +
- floater->path->x_linear_coefficient * (time) +
- floater->path->start_point.x;
- point.y = floater->path->y_cubic_coefficient * (time * time * time) +
- floater->path->y_quadratic_coefficient * (time * time) +
- floater->path->y_linear_coefficient * (time) +
- floater->path->start_point.y;
+ point.x = floater->path->x_cubic_coefficient * (time * time * time) +
+ floater->path->x_quadratic_coefficient * (time * time) +
+ floater->path->x_linear_coefficient * (time) +
+ floater->path->start_point.x;
+ point.y = floater->path->y_cubic_coefficient * (time * time * time) +
+ floater->path->y_quadratic_coefficient * (time * time) +
+ floater->path->y_linear_coefficient * (time) +
+ floater->path->start_point.y;
- return point;
+ return point;
}
static gdouble
screen_saver_floater_get_scale_from_time (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time)
+ ScreenSaverFloater *floater,
+ gdouble time)
{
- gdouble completion_ratio, total_scale_growth, new_scale;
+ gdouble completion_ratio, total_scale_growth, new_scale;
- completion_ratio = time / floater->path->duration;
- total_scale_growth = (floater->path_end_scale - floater->path_start_scale);
- new_scale = floater->path_start_scale + total_scale_growth * completion_ratio;
+ completion_ratio = time / floater->path->duration;
+ total_scale_growth = (floater->path_end_scale - floater->path_start_scale);
+ new_scale = floater->path_start_scale + total_scale_growth * completion_ratio;
- return CLAMP (new_scale, 0.0, 1.0);
+ return CLAMP (new_scale, 0.0, 1.0);
}
static gdouble
screen_saver_floater_get_angle_from_time (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble time)
+ ScreenSaverFloater *floater,
+ gdouble time)
{
- gdouble completion_ratio;
- gdouble total_rotation;
+ gdouble completion_ratio;
+ gdouble total_rotation;
- completion_ratio = time / floater->path->duration;
- total_rotation = floater->angle_increment * floater->path->duration;
+ completion_ratio = time / floater->path->duration;
+ total_rotation = floater->angle_increment * floater->path->duration;
- return floater->angle + total_rotation * completion_ratio;
+ return floater->angle + total_rotation * completion_ratio;
}
static Path *
screen_saver_floater_create_path_to_on_screen (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble duration)
+ ScreenSaverFloater *floater,
+ gdouble duration)
{
- Point start_position, end_position, start_control_point, end_control_point;
- start_position = floater->position;
+ Point start_position, end_position, start_control_point, end_control_point;
+ start_position = floater->position;
- end_position.x = g_random_double_range (.25, .75) *
- (screen_saver->canvas_rectangle.top_left_point.x +
- screen_saver->canvas_rectangle.bottom_right_point.x);
- end_position.y = g_random_double_range (.25, .75) *
- (screen_saver->canvas_rectangle.top_left_point.y +
- screen_saver->canvas_rectangle.bottom_right_point.y);
+ end_position.x = g_random_double_range (.25, .75) *
+ (screen_saver->canvas_rectangle.top_left_point.x +
+ screen_saver->canvas_rectangle.bottom_right_point.x);
+ end_position.y = g_random_double_range (.25, .75) *
+ (screen_saver->canvas_rectangle.top_left_point.y +
+ screen_saver->canvas_rectangle.bottom_right_point.y);
- start_control_point.x = start_position.x + .9 * (end_position.x - start_position.x);
- start_control_point.y = start_position.y + .9 * (end_position.y - start_position.y);
+ start_control_point.x = start_position.x + .9 * (end_position.x - start_position.x);
+ start_control_point.y = start_position.y + .9 * (end_position.y - start_position.y);
- end_control_point.x = start_position.x + 1.0 * (end_position.x - start_position.x);
- end_control_point.y = start_position.y + 1.0 * (end_position.y - start_position.y);
+ end_control_point.x = start_position.x + 1.0 * (end_position.x - start_position.x);
+ end_control_point.y = start_position.y + 1.0 * (end_position.y - start_position.y);
- return path_new (&start_position, &start_control_point, &end_control_point,
- &end_position, duration);
+ return path_new (&start_position, &start_control_point, &end_control_point,
+ &end_position, duration);
}
static Path *
screen_saver_floater_create_path_to_bubble_up (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble duration)
+ ScreenSaverFloater *floater,
+ gdouble duration)
{
- Point start_position, end_position, start_control_point, end_control_point;
-
- start_position = floater->position;
- end_position.x = start_position.x;
- end_position.y = screen_saver->canvas_rectangle.top_left_point.y - FLOATER_MAX_SIZE;
- start_control_point.x = .5 * start_position.x;
- start_control_point.y = .5 * start_position.y;
- end_control_point.x = 1.5 * end_position.x;
- end_control_point.y = .5 * end_position.y;
-
- return path_new (&start_position, &start_control_point, &end_control_point,
- &end_position, duration);
+ Point start_position, end_position, start_control_point, end_control_point;
+
+ start_position = floater->position;
+ end_position.x = start_position.x;
+ end_position.y = screen_saver->canvas_rectangle.top_left_point.y - FLOATER_MAX_SIZE;
+ start_control_point.x = .5 * start_position.x;
+ start_control_point.y = .5 * start_position.y;
+ end_control_point.x = 1.5 * end_position.x;
+ end_control_point.y = .5 * end_position.y;
+
+ return path_new (&start_position, &start_control_point, &end_control_point,
+ &end_position, duration);
}
static Path *
screen_saver_floater_create_path_to_random_point (ScreenSaver *screen_saver,
- ScreenSaverFloater *floater,
- gdouble duration)
+ ScreenSaverFloater *floater,
+ gdouble duration)
{
- Point start_position, end_position, start_control_point, end_control_point;
+ Point start_position, end_position, start_control_point, end_control_point;
- start_position = floater->position;
+ start_position = floater->position;
- end_position.x = start_position.x +
- (g_random_double_range (-.5, .5) * 4 * FLOATER_MAX_SIZE);
- end_position.y = start_position.y +
- (g_random_double_range (-.5, .5) * 4 * FLOATER_MAX_SIZE);
+ end_position.x = start_position.x +
+ (g_random_double_range (-.5, .5) * 4 * FLOATER_MAX_SIZE);
+ end_position.y = start_position.y +
+ (g_random_double_range (-.5, .5) * 4 * FLOATER_MAX_SIZE);
- start_control_point.x = start_position.x + .95 * (end_position.x - start_position.x);
- start_control_point.y = start_position.y + .95 * (end_position.y - start_position.y);
+ start_control_point.x = start_position.x + .95 * (end_position.x - start_position.x);
+ start_control_point.y = start_position.y + .95 * (end_position.y - start_position.y);
- end_control_point.x = start_position.x + 1.0 * (end_position.x - start_position.x);
- end_control_point.y = start_position.y + 1.0 * (end_position.y - start_position.y);
+ end_control_point.x = start_position.x + 1.0 * (end_position.x - start_position.x);
+ end_control_point.y = start_position.y + 1.0 * (end_position.y - start_position.y);
- return path_new (&start_position, &start_control_point, &end_control_point,
- &end_position, duration);
+ return path_new (&start_position, &start_control_point, &end_control_point,
+ &end_position, duration);
}
static Path *
screen_saver_floater_create_path (ScreenSaver *screen_saver,
ScreenSaverFloater *floater)
{
- gdouble performance_ratio;
- gdouble duration;
+ gdouble performance_ratio;
+ gdouble duration;
- performance_ratio =
- screen_saver_get_frames_per_second (screen_saver) / OPTIMAL_FRAME_RATE;
+ performance_ratio =
+ screen_saver_get_frames_per_second (screen_saver) / OPTIMAL_FRAME_RATE;
- if (abs (performance_ratio) <= G_MINDOUBLE)
- performance_ratio = 1.0;
+ if (abs (performance_ratio) <= G_MINDOUBLE)
+ performance_ratio = 1.0;
- if (screen_saver_floater_should_bubble_up (screen_saver, floater, performance_ratio, &duration))
- return screen_saver_floater_create_path_to_bubble_up (screen_saver, floater, duration);
+ if (screen_saver_floater_should_bubble_up (screen_saver, floater, performance_ratio, &duration))
+ return screen_saver_floater_create_path_to_bubble_up (screen_saver, floater, duration);
- if (screen_saver_floater_should_come_on_screen (screen_saver, floater, performance_ratio, &duration))
- return screen_saver_floater_create_path_to_on_screen (screen_saver, floater, duration);
+ if (screen_saver_floater_should_come_on_screen (screen_saver, floater, performance_ratio, &duration))
+ return screen_saver_floater_create_path_to_on_screen (screen_saver, floater, duration);
- return screen_saver_floater_create_path_to_random_point (screen_saver, floater,
- g_random_double_range (3.0, 7.0));
+ return screen_saver_floater_create_path_to_random_point (screen_saver, floater,
+ g_random_double_range (3.0, 7.0));
}
static void
@@ -601,90 +599,90 @@ screen_saver_floater_update_state (ScreenSaver *screen_saver,
ScreenSaverFloater *floater,
gdouble time)
{
- gdouble performance_ratio;
-
- performance_ratio =
- screen_saver_get_frames_per_second (screen_saver) / OPTIMAL_FRAME_RATE;
-
- if (floater->path == NULL)
- {
- floater->path = screen_saver_floater_create_path (screen_saver, floater);
- floater->path_start_time = time;
-
- floater->path_start_scale = floater->scale;
-
- if (g_random_double () > .5)
- floater->path_end_scale = g_random_double_range (0.10, performance_ratio);
-
- /* poor man's distribution */
- if (screen_saver->should_do_rotations &&
- (g_random_double () < .75 * performance_ratio))
- {
- gint r;
-
- r = g_random_int_range (0, 100);
- if (r < 80)
- floater->angle_increment = 0.0;
- else if (r < 95)
- floater->angle_increment = g_random_double_range (-SMALL_ANGLE, SMALL_ANGLE);
- else
- floater->angle_increment = g_random_double_range (-BIG_ANGLE, BIG_ANGLE);
- }
- }
-
- if (time < (floater->path_start_time + floater->path->duration))
- {
- gdouble path_time;
-
- path_time = time - floater->path_start_time;
-
- floater->position =
- screen_saver_floater_get_position_from_time (screen_saver, floater,
- path_time);
- floater->scale =
- screen_saver_floater_get_scale_from_time (screen_saver, floater, path_time);
-
- floater->angle =
- screen_saver_floater_get_angle_from_time (screen_saver, floater, path_time);
-
- floater->opacity = pow (floater->scale, 1.0 / GAMMA);
- }
- else
- {
- path_free (floater->path);
-
- floater->path = NULL;
- floater->path_start_time = 0.0;
- }
+ gdouble performance_ratio;
+
+ performance_ratio =
+ screen_saver_get_frames_per_second (screen_saver) / OPTIMAL_FRAME_RATE;
+
+ if (floater->path == NULL)
+ {
+ floater->path = screen_saver_floater_create_path (screen_saver, floater);
+ floater->path_start_time = time;
+
+ floater->path_start_scale = floater->scale;
+
+ if (g_random_double () > .5)
+ floater->path_end_scale = g_random_double_range (0.10, performance_ratio);
+
+ /* poor man's distribution */
+ if (screen_saver->should_do_rotations &&
+ (g_random_double () < .75 * performance_ratio))
+ {
+ gint r;
+
+ r = g_random_int_range (0, 100);
+ if (r < 80)
+ floater->angle_increment = 0.0;
+ else if (r < 95)
+ floater->angle_increment = g_random_double_range (-SMALL_ANGLE, SMALL_ANGLE);
+ else
+ floater->angle_increment = g_random_double_range (-BIG_ANGLE, BIG_ANGLE);
+ }
+ }
+
+ if (time < (floater->path_start_time + floater->path->duration))
+ {
+ gdouble path_time;
+
+ path_time = time - floater->path_start_time;
+
+ floater->position =
+ screen_saver_floater_get_position_from_time (screen_saver, floater,
+ path_time);
+ floater->scale =
+ screen_saver_floater_get_scale_from_time (screen_saver, floater, path_time);
+
+ floater->angle =
+ screen_saver_floater_get_angle_from_time (screen_saver, floater, path_time);
+
+ floater->opacity = pow (floater->scale, 1.0 / GAMMA);
+ }
+ else
+ {
+ path_free (floater->path);
+
+ floater->path = NULL;
+ floater->path_start_time = 0.0;
+ }
}
static GdkPixbuf *
gamma_correct (const GdkPixbuf *input_pixbuf)
{
- gint x, y, width, height, rowstride;
- GdkPixbuf *output_pixbuf;
- guchar *pixels;
+ gint x, y, width, height, rowstride;
+ GdkPixbuf *output_pixbuf;
+ guchar *pixels;
- output_pixbuf = gdk_pixbuf_copy (input_pixbuf);
- pixels = gdk_pixbuf_get_pixels (output_pixbuf);
+ output_pixbuf = gdk_pixbuf_copy (input_pixbuf);
+ pixels = gdk_pixbuf_get_pixels (output_pixbuf);
- width = gdk_pixbuf_get_width (output_pixbuf);
- height = gdk_pixbuf_get_height (output_pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (output_pixbuf);
+ width = gdk_pixbuf_get_width (output_pixbuf);
+ height = gdk_pixbuf_get_height (output_pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (output_pixbuf);
- for (y = 0; y < height; y++)
- for (x = 0; x < width; x++)
- {
- guchar *alpha_channel;
- guchar opacity;
+ for (y = 0; y < height; y++)
+ for (x = 0; x < width; x++)
+ {
+ guchar *alpha_channel;
+ guchar opacity;
- alpha_channel = pixels + y * (rowstride / 4) + x + 3;
- opacity = (guchar) (255 * pow ((*alpha_channel / 255.0), 1.0 / GAMMA));
+ alpha_channel = pixels + y * (rowstride / 4) + x + 3;
+ opacity = (guchar) (255 * pow ((*alpha_channel / 255.0), 1.0 / GAMMA));
- *alpha_channel = opacity;
- }
+ *alpha_channel = opacity;
+ }
- return output_pixbuf;
+ return output_pixbuf;
}
static gboolean
@@ -692,548 +690,548 @@ screen_saver_floater_do_draw (ScreenSaver *screen_saver,
ScreenSaverFloater *floater,
cairo_t *context)
{
- gint size;
- CachedSource *source;
-
- size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
- FLOATER_MIN_SIZE, FLOATER_MAX_SIZE);
-
- source = g_hash_table_lookup (screen_saver->cached_sources, GINT_TO_POINTER (size));
-
- if (source == NULL)
- {
- GdkPixbuf *pixbuf;
- GError *error;
-
- pixbuf = NULL;
- error = NULL;
-
- pixbuf = gdk_pixbuf_new_from_file_at_size (screen_saver->filename, size, -1,
- &error);
- if (pixbuf == NULL)
- {
- g_assert (error != NULL);
- g_printerr ("%s", _(error->message));
- g_error_free (error);
- return FALSE;
- }
-
- if (gdk_pixbuf_get_has_alpha (pixbuf))
- gamma_correct (pixbuf);
-
- gdk_cairo_set_source_pixbuf (context, pixbuf, 0.0, 0.0);
-
- source = cached_source_new (cairo_get_source (context),
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
- g_object_unref (pixbuf);
- g_hash_table_insert (screen_saver->cached_sources, GINT_TO_POINTER (size),
- source);
- }
-
- cairo_save (context);
-
- if (screen_saver->should_do_rotations && (abs (floater->angle) > G_MINDOUBLE))
- {
- floater->bounds.width = G_SQRT2 * source->width + 2;
- floater->bounds.height = G_SQRT2 * source->height + 2;
- floater->bounds.x = (int) (floater->position.x - .5 * G_SQRT2 * source->width) - 1;
- floater->bounds.y = (int) (floater->position.y - .5 * G_SQRT2 * source->height) - 1;
-
- cairo_translate (context,
- trunc (floater->position.x),
- trunc (floater->position.y));
- cairo_rotate (context, floater->angle);
- cairo_translate (context,
- -trunc (floater->position.x),
- -trunc (floater->position.y));
- }
- else
- {
- floater->bounds.width = source->width + 2;
- floater->bounds.height = source->height + 2;
- floater->bounds.x = (int) (floater->position.x - .5 * source->width) - 1;
- floater->bounds.y = (int) (floater->position.y - .5 * source->height) - 1;
- }
-
- cairo_translate (context,
- trunc (floater->position.x - .5 * source->width),
- trunc (floater->position.y - .5 * source->height));
-
- cairo_set_source (context, source->pattern);
-
- cairo_rectangle (context,
- trunc (.5 * (source->width - floater->bounds.width)),
- trunc (.5 * (source->height - floater->bounds.height)),
- floater->bounds.width, floater->bounds.height);
-
- cairo_clip (context);
- cairo_paint_with_alpha (context, floater->opacity);
- cairo_restore (context);
-
- if (screen_saver->should_show_paths && (floater->path != NULL))
- {
- gdouble dash_pattern[] = { 5.0 };
-
- cairo_save (context);
- cairo_set_source_rgba (context, 1.0, 1.0, 1.0, .2 * floater->opacity);
- cairo_move_to (context,
- floater->path->start_point.x,
- floater->path->start_point.y);
- cairo_curve_to (context,
- floater->path->start_control_point.x,
- floater->path->start_control_point.y,
- floater->path->end_control_point.x,
- floater->path->end_control_point.y,
- floater->path->end_point.x,
- floater->path->end_point.y);
- cairo_set_line_cap (context, CAIRO_LINE_CAP_ROUND);
- cairo_stroke (context);
- cairo_set_source_rgba (context, 1.0, 0.0, 0.0, .5 * floater->opacity);
- cairo_rectangle (context,
- floater->path->start_point.x - 3,
- floater->path->start_point.y - 3,
- 6, 6);
- cairo_fill (context);
- cairo_set_source_rgba (context, 0.0, 0.5, 0.0, .5 * floater->opacity);
- cairo_arc (context,
- floater->path->start_control_point.x,
- floater->path->start_control_point.y,
- 3, 0.0, 2.0 * G_PI);
- cairo_stroke (context);
- cairo_set_source_rgba (context, 0.5, 0.0, 0.5, .5 * floater->opacity);
- cairo_arc (context,
- floater->path->end_control_point.x,
- floater->path->end_control_point.y,
- 3, 0.0, 2.0 * G_PI);
- cairo_stroke (context);
- cairo_set_source_rgba (context, 0.0, 0.0, 1.0, .5 * floater->opacity);
- cairo_rectangle (context,
- floater->path->end_point.x - 3,
- floater->path->end_point.y - 3,
- 6, 6);
- cairo_fill (context);
-
- cairo_set_dash (context, dash_pattern, G_N_ELEMENTS (dash_pattern), 0);
- cairo_set_source_rgba (context, .5, .5, .5, .2 * floater->scale);
- cairo_move_to (context, floater->path->start_point.x,
- floater->path->start_point.y);
- cairo_line_to (context, floater->path->start_control_point.x,
- floater->path->start_control_point.y);
- cairo_stroke (context);
-
- cairo_move_to (context, floater->path->end_point.x,
- floater->path->end_point.y);
- cairo_line_to (context, floater->path->end_control_point.x,
- floater->path->end_control_point.y);
- cairo_stroke (context);
-
- cairo_restore (context);
- }
-
- return TRUE;
+ gint size;
+ CachedSource *source;
+
+ size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
+ FLOATER_MIN_SIZE, FLOATER_MAX_SIZE);
+
+ source = g_hash_table_lookup (screen_saver->cached_sources, GINT_TO_POINTER (size));
+
+ if (source == NULL)
+ {
+ GdkPixbuf *pixbuf;
+ GError *error;
+
+ pixbuf = NULL;
+ error = NULL;
+
+ pixbuf = gdk_pixbuf_new_from_file_at_size (screen_saver->filename, size, -1,
+ &error);
+ if (pixbuf == NULL)
+ {
+ g_assert (error != NULL);
+ g_printerr ("%s", _(error->message));
+ g_error_free (error);
+ return FALSE;
+ }
+
+ if (gdk_pixbuf_get_has_alpha (pixbuf))
+ gamma_correct (pixbuf);
+
+ gdk_cairo_set_source_pixbuf (context, pixbuf, 0.0, 0.0);
+
+ source = cached_source_new (cairo_get_source (context),
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
+ g_object_unref (pixbuf);
+ g_hash_table_insert (screen_saver->cached_sources, GINT_TO_POINTER (size),
+ source);
+ }
+
+ cairo_save (context);
+
+ if (screen_saver->should_do_rotations && (abs (floater->angle) > G_MINDOUBLE))
+ {
+ floater->bounds.width = G_SQRT2 * source->width + 2;
+ floater->bounds.height = G_SQRT2 * source->height + 2;
+ floater->bounds.x = (int) (floater->position.x - .5 * G_SQRT2 * source->width) - 1;
+ floater->bounds.y = (int) (floater->position.y - .5 * G_SQRT2 * source->height) - 1;
+
+ cairo_translate (context,
+ trunc (floater->position.x),
+ trunc (floater->position.y));
+ cairo_rotate (context, floater->angle);
+ cairo_translate (context,
+ -trunc (floater->position.x),
+ -trunc (floater->position.y));
+ }
+ else
+ {
+ floater->bounds.width = source->width + 2;
+ floater->bounds.height = source->height + 2;
+ floater->bounds.x = (int) (floater->position.x - .5 * source->width) - 1;
+ floater->bounds.y = (int) (floater->position.y - .5 * source->height) - 1;
+ }
+
+ cairo_translate (context,
+ trunc (floater->position.x - .5 * source->width),
+ trunc (floater->position.y - .5 * source->height));
+
+ cairo_set_source (context, source->pattern);
+
+ cairo_rectangle (context,
+ trunc (.5 * (source->width - floater->bounds.width)),
+ trunc (.5 * (source->height - floater->bounds.height)),
+ floater->bounds.width, floater->bounds.height);
+
+ cairo_clip (context);
+ cairo_paint_with_alpha (context, floater->opacity);
+ cairo_restore (context);
+
+ if (screen_saver->should_show_paths && (floater->path != NULL))
+ {
+ gdouble dash_pattern[] = { 5.0 };
+
+ cairo_save (context);
+ cairo_set_source_rgba (context, 1.0, 1.0, 1.0, .2 * floater->opacity);
+ cairo_move_to (context,
+ floater->path->start_point.x,
+ floater->path->start_point.y);
+ cairo_curve_to (context,
+ floater->path->start_control_point.x,
+ floater->path->start_control_point.y,
+ floater->path->end_control_point.x,
+ floater->path->end_control_point.y,
+ floater->path->end_point.x,
+ floater->path->end_point.y);
+ cairo_set_line_cap (context, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke (context);
+ cairo_set_source_rgba (context, 1.0, 0.0, 0.0, .5 * floater->opacity);
+ cairo_rectangle (context,
+ floater->path->start_point.x - 3,
+ floater->path->start_point.y - 3,
+ 6, 6);
+ cairo_fill (context);
+ cairo_set_source_rgba (context, 0.0, 0.5, 0.0, .5 * floater->opacity);
+ cairo_arc (context,
+ floater->path->start_control_point.x,
+ floater->path->start_control_point.y,
+ 3, 0.0, 2.0 * G_PI);
+ cairo_stroke (context);
+ cairo_set_source_rgba (context, 0.5, 0.0, 0.5, .5 * floater->opacity);
+ cairo_arc (context,
+ floater->path->end_control_point.x,
+ floater->path->end_control_point.y,
+ 3, 0.0, 2.0 * G_PI);
+ cairo_stroke (context);
+ cairo_set_source_rgba (context, 0.0, 0.0, 1.0, .5 * floater->opacity);
+ cairo_rectangle (context,
+ floater->path->end_point.x - 3,
+ floater->path->end_point.y - 3,
+ 6, 6);
+ cairo_fill (context);
+
+ cairo_set_dash (context, dash_pattern, G_N_ELEMENTS (dash_pattern), 0);
+ cairo_set_source_rgba (context, .5, .5, .5, .2 * floater->scale);
+ cairo_move_to (context, floater->path->start_point.x,
+ floater->path->start_point.y);
+ cairo_line_to (context, floater->path->start_control_point.x,
+ floater->path->start_control_point.y);
+ cairo_stroke (context);
+
+ cairo_move_to (context, floater->path->end_point.x,
+ floater->path->end_point.y);
+ cairo_line_to (context, floater->path->end_control_point.x,
+ floater->path->end_control_point.y);
+ cairo_stroke (context);
+
+ cairo_restore (context);
+ }
+
+ return TRUE;
}
static ScreenSaver *
-screen_saver_new (GtkWidget *drawing_area,
- const gchar *filename,
- gint max_floater_count,
- gboolean should_do_rotations,
- gboolean should_show_paths)
+screen_saver_new (GtkWidget *drawing_area,
+ const gchar *filename,
+ gint max_floater_count,
+ gboolean should_do_rotations,
+ gboolean should_show_paths)
{
- ScreenSaver *screen_saver;
-
- screen_saver = g_new (ScreenSaver, 1);
- screen_saver->filename = g_strdup (filename);
- screen_saver->drawing_area = drawing_area;
- screen_saver->cached_sources =
- g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) cached_source_free);
-
- g_signal_connect_swapped (G_OBJECT (drawing_area), "size-allocate",
- G_CALLBACK (screen_saver_on_size_allocate),
- screen_saver);
-
- g_signal_connect_swapped (G_OBJECT (drawing_area), "draw",
- G_CALLBACK (screen_saver_on_draw),
- screen_saver);
-
- screen_saver->first_update_time = 0.0;
- screen_saver->current_calculated_stats_time = 0.0;
- screen_saver->last_calculated_stats_time = 0.0;
- screen_saver->update_count = 0;
- screen_saver->frame_count = 0;
- screen_saver->updates_per_second = 0.0;
- screen_saver->frames_per_second = 0.0;
- screen_saver->floaters = NULL;
- screen_saver->max_floater_count = max_floater_count;
-
- screen_saver->should_show_paths = should_show_paths;
- screen_saver->should_do_rotations = should_do_rotations;
-
- screen_saver_get_initial_state (screen_saver);
-
- screen_saver->state_update_timeout_id =
- g_timeout_add (1000 / (2.0 * OPTIMAL_FRAME_RATE),
- (GSourceFunc) screen_saver_do_update_state, screen_saver);
-
- screen_saver->stats_update_timeout_id =
- g_timeout_add (1000, (GSourceFunc) screen_saver_do_update_stats,
- screen_saver);
-
- return screen_saver;
+ ScreenSaver *screen_saver;
+
+ screen_saver = g_new (ScreenSaver, 1);
+ screen_saver->filename = g_strdup (filename);
+ screen_saver->drawing_area = drawing_area;
+ screen_saver->cached_sources =
+ g_hash_table_new_full (NULL, NULL, NULL,
+ (GDestroyNotify) cached_source_free);
+
+ g_signal_connect_swapped (G_OBJECT (drawing_area), "size-allocate",
+ G_CALLBACK (screen_saver_on_size_allocate),
+ screen_saver);
+
+ g_signal_connect_swapped (G_OBJECT (drawing_area), "draw",
+ G_CALLBACK (screen_saver_on_draw),
+ screen_saver);
+
+ screen_saver->first_update_time = 0.0;
+ screen_saver->current_calculated_stats_time = 0.0;
+ screen_saver->last_calculated_stats_time = 0.0;
+ screen_saver->update_count = 0;
+ screen_saver->frame_count = 0;
+ screen_saver->updates_per_second = 0.0;
+ screen_saver->frames_per_second = 0.0;
+ screen_saver->floaters = NULL;
+ screen_saver->max_floater_count = max_floater_count;
+
+ screen_saver->should_show_paths = should_show_paths;
+ screen_saver->should_do_rotations = should_do_rotations;
+
+ screen_saver_get_initial_state (screen_saver);
+
+ screen_saver->state_update_timeout_id =
+ g_timeout_add (1000 / (2.0 * OPTIMAL_FRAME_RATE),
+ (GSourceFunc) screen_saver_do_update_state, screen_saver);
+
+ screen_saver->stats_update_timeout_id =
+ g_timeout_add (1000, (GSourceFunc) screen_saver_do_update_stats,
+ screen_saver);
+
+ return screen_saver;
}
static void
screen_saver_free (ScreenSaver *screen_saver)
{
- if (screen_saver == NULL)
- return;
+ if (screen_saver == NULL)
+ return;
- g_free (screen_saver->filename);
+ g_free (screen_saver->filename);
- g_hash_table_destroy (screen_saver->cached_sources);
+ g_hash_table_destroy (screen_saver->cached_sources);
- if (screen_saver->state_update_timeout_id != 0) {
- g_source_remove (screen_saver->state_update_timeout_id);
- screen_saver->state_update_timeout_id = 0;
- }
+ if (screen_saver->state_update_timeout_id != 0) {
+ g_source_remove (screen_saver->state_update_timeout_id);
+ screen_saver->state_update_timeout_id = 0;
+ }
- if (screen_saver->stats_update_timeout_id != 0) {
- g_source_remove (screen_saver->stats_update_timeout_id);
- screen_saver->stats_update_timeout_id = 0;
- }
+ if (screen_saver->stats_update_timeout_id != 0) {
+ g_source_remove (screen_saver->stats_update_timeout_id);
+ screen_saver->stats_update_timeout_id = 0;
+ }
- screen_saver_destroy_floaters (screen_saver);
+ screen_saver_destroy_floaters (screen_saver);
- g_free (screen_saver);
+ g_free (screen_saver);
}
static gdouble
screen_saver_get_timestamp (ScreenSaver *screen_saver)
{
- const gdouble microseconds_per_second = (gdouble ) G_USEC_PER_SEC;
- gdouble timestamp;
- GTimeVal now = { 0L, /* zero-filled */ };
+ const gdouble microseconds_per_second = (gdouble ) G_USEC_PER_SEC;
+ gdouble timestamp;
+ GTimeVal now = { 0L, /* zero-filled */ };
- g_get_current_time (&now);
- timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) /
- microseconds_per_second;
+ g_get_current_time (&now);
+ timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) /
+ microseconds_per_second;
- return timestamp;
+ return timestamp;
}
static void
screen_saver_create_floaters (ScreenSaver *screen_saver)
{
- gint i;
+ gint i;
- for (i = 0; i < screen_saver->max_floater_count; i++)
- {
- ScreenSaverFloater *floater;
- Point position;
- gdouble scale;
+ for (i = 0; i < screen_saver->max_floater_count; i++)
+ {
+ ScreenSaverFloater *floater;
+ Point position;
+ gdouble scale;
- position.x = g_random_double_range (screen_saver->canvas_rectangle.top_left_point.x,
- screen_saver->canvas_rectangle.bottom_right_point.x);
- position.y = g_random_double_range (screen_saver->canvas_rectangle.top_left_point.y,
- screen_saver->canvas_rectangle.bottom_right_point.y);
+ position.x = g_random_double_range (screen_saver->canvas_rectangle.top_left_point.x,
+ screen_saver->canvas_rectangle.bottom_right_point.x);
+ position.y = g_random_double_range (screen_saver->canvas_rectangle.top_left_point.y,
+ screen_saver->canvas_rectangle.bottom_right_point.y);
- scale = g_random_double ();
+ scale = g_random_double ();
- floater = screen_saver_floater_new (screen_saver, &position, scale);
+ floater = screen_saver_floater_new (screen_saver, &position, scale);
- screen_saver->floaters = g_list_prepend (screen_saver->floaters,
- floater);
- }
+ screen_saver->floaters = g_list_prepend (screen_saver->floaters,
+ floater);
+ }
}
static gdouble
screen_saver_get_updates_per_second (ScreenSaver *screen_saver)
{
- return screen_saver->updates_per_second;
+ return screen_saver->updates_per_second;
}
static gdouble
screen_saver_get_frames_per_second (ScreenSaver *screen_saver)
{
- return screen_saver->frames_per_second;
+ return screen_saver->frames_per_second;
}
static gdouble
screen_saver_get_image_cache_usage (ScreenSaver *screen_saver)
{
- static const gdouble cache_capacity = (FLOATER_MAX_SIZE - FLOATER_MIN_SIZE + 1);
+ static const gdouble cache_capacity = (FLOATER_MAX_SIZE - FLOATER_MIN_SIZE + 1);
- return g_hash_table_size (screen_saver->cached_sources) / cache_capacity;
+ return g_hash_table_size (screen_saver->cached_sources) / cache_capacity;
}
static void
screen_saver_destroy_floaters (ScreenSaver *screen_saver)
{
- if (screen_saver->floaters == NULL)
- return;
+ if (screen_saver->floaters == NULL)
+ return;
- g_list_foreach (screen_saver->floaters, (GFunc) screen_saver_floater_free,
- NULL);
- g_list_free (screen_saver->floaters);
+ g_list_foreach (screen_saver->floaters, (GFunc) screen_saver_floater_free,
+ NULL);
+ g_list_free (screen_saver->floaters);
- screen_saver->floaters = NULL;
+ screen_saver->floaters = NULL;
}
static void
screen_saver_on_size_allocate (ScreenSaver *screen_saver,
GtkAllocation *allocation)
{
- Rectangle canvas_rectangle;
+ Rectangle canvas_rectangle;
- canvas_rectangle.top_left_point.x = allocation->x - .1 * allocation->width;
- canvas_rectangle.top_left_point.y = allocation->y - .1 * allocation->height;
+ canvas_rectangle.top_left_point.x = allocation->x - .1 * allocation->width;
+ canvas_rectangle.top_left_point.y = allocation->y - .1 * allocation->height;
- canvas_rectangle.bottom_right_point.x = allocation->x + (1.1 * allocation->width);
- canvas_rectangle.bottom_right_point.y = allocation->y + (1.1 * allocation->height);
+ canvas_rectangle.bottom_right_point.x = allocation->x + (1.1 * allocation->width);
+ canvas_rectangle.bottom_right_point.y = allocation->y + (1.1 * allocation->height);
- screen_saver->canvas_rectangle = canvas_rectangle;
+ screen_saver->canvas_rectangle = canvas_rectangle;
}
static gint
compare_floaters (ScreenSaverFloater *a,
ScreenSaverFloater *b)
{
- if (a->scale > b->scale)
- return 1;
- else if (abs (a->scale - b->scale) <= G_MINDOUBLE)
- return 0;
- else
- return -1;
+ if (a->scale > b->scale)
+ return 1;
+ else if (abs (a->scale - b->scale) <= G_MINDOUBLE)
+ return 0;
+ else
+ return -1;
}
static void
-screen_saver_on_draw (ScreenSaver *screen_saver,
- cairo_t *context)
+screen_saver_on_draw (ScreenSaver *screen_saver,
+ cairo_t *context)
{
- GList *tmp;
+ GList *tmp;
- if (screen_saver->floaters == NULL)
- screen_saver_create_floaters (screen_saver);
+ if (screen_saver->floaters == NULL)
+ screen_saver_create_floaters (screen_saver);
- screen_saver->floaters = g_list_sort (screen_saver->floaters,
- (GCompareFunc)compare_floaters);
+ screen_saver->floaters = g_list_sort (screen_saver->floaters,
+ (GCompareFunc)compare_floaters);
- for (tmp = screen_saver->floaters; tmp != NULL; tmp = tmp->next)
- {
- ScreenSaverFloater *floater;
+ for (tmp = screen_saver->floaters; tmp != NULL; tmp = tmp->next)
+ {
+ ScreenSaverFloater *floater;
- floater = (ScreenSaverFloater *) tmp->data;
+ floater = (ScreenSaverFloater *) tmp->data;
- if (!screen_saver_floater_do_draw (screen_saver, floater, context))
- {
- gtk_main_quit ();
- break;
- }
- }
+ if (!screen_saver_floater_do_draw (screen_saver, floater, context))
+ {
+ gtk_main_quit ();
+ break;
+ }
+ }
- screen_saver->draw_ops_pending = TRUE;
- screen_saver->frame_count++;
+ screen_saver->draw_ops_pending = TRUE;
+ screen_saver->frame_count++;
}
static void
screen_saver_update_state (ScreenSaver *screen_saver,
gdouble time)
{
- GList *tmp;
-
- tmp = screen_saver->floaters;
- while (tmp != NULL)
- {
- ScreenSaverFloater *floater;
- floater = (ScreenSaverFloater *) tmp->data;
-
- screen_saver_floater_update_state (screen_saver, floater, time);
-
- if (screen_saver->drawing_area != NULL &&
- gtk_widget_get_realized (screen_saver->drawing_area) &&
- (floater->bounds.width > 0) && (floater->bounds.height > 0))
- {
- gint size;
- size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
- FLOATER_MIN_SIZE, FLOATER_MAX_SIZE);
-
- gtk_widget_queue_draw_area (screen_saver->drawing_area,
- floater->bounds.x,
- floater->bounds.y,
- floater->bounds.width,
- floater->bounds.height);
-
- /* the edges could concievably be spread across two
- * pixels so we add +2 to invalidated region
- */
- if (screen_saver->should_do_rotations)
- gtk_widget_queue_draw_area (screen_saver->drawing_area,
- (int) (floater->position.x -
- .5 * G_SQRT2 * size),
- (int) (floater->position.y -
- .5 * G_SQRT2 * size),
- G_SQRT2 * size + 2,
- G_SQRT2 * size + 2);
- else
- gtk_widget_queue_draw_area (screen_saver->drawing_area,
- (int) (floater->position.x -
- .5 * size),
- (int) (floater->position.y -
- .5 * size),
- size + 2, size + 2);
-
- if (screen_saver->should_show_paths)
- gtk_widget_queue_draw (screen_saver->drawing_area);
- }
-
- tmp = tmp->next;
- }
+ GList *tmp;
+
+ tmp = screen_saver->floaters;
+ while (tmp != NULL)
+ {
+ ScreenSaverFloater *floater;
+ floater = (ScreenSaverFloater *) tmp->data;
+
+ screen_saver_floater_update_state (screen_saver, floater, time);
+
+ if (screen_saver->drawing_area != NULL &&
+ gtk_widget_get_realized (screen_saver->drawing_area) &&
+ (floater->bounds.width > 0) && (floater->bounds.height > 0))
+ {
+ gint size;
+ size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
+ FLOATER_MIN_SIZE, FLOATER_MAX_SIZE);
+
+ gtk_widget_queue_draw_area (screen_saver->drawing_area,
+ floater->bounds.x,
+ floater->bounds.y,
+ floater->bounds.width,
+ floater->bounds.height);
+
+ /* the edges could concievably be spread across two
+ * pixels so we add +2 to invalidated region
+ */
+ if (screen_saver->should_do_rotations)
+ gtk_widget_queue_draw_area (screen_saver->drawing_area,
+ (int) (floater->position.x -
+ .5 * G_SQRT2 * size),
+ (int) (floater->position.y -
+ .5 * G_SQRT2 * size),
+ G_SQRT2 * size + 2,
+ G_SQRT2 * size + 2);
+ else
+ gtk_widget_queue_draw_area (screen_saver->drawing_area,
+ (int) (floater->position.x -
+ .5 * size),
+ (int) (floater->position.y -
+ .5 * size),
+ size + 2, size + 2);
+
+ if (screen_saver->should_show_paths)
+ gtk_widget_queue_draw (screen_saver->drawing_area);
+ }
+
+ tmp = tmp->next;
+ }
}
static void
screen_saver_get_initial_state (ScreenSaver *screen_saver)
{
- screen_saver->first_update_time = screen_saver_get_timestamp (screen_saver);
- screen_saver_update_state (screen_saver, 0.0);
+ screen_saver->first_update_time = screen_saver_get_timestamp (screen_saver);
+ screen_saver_update_state (screen_saver, 0.0);
}
static gboolean
screen_saver_do_update_state (ScreenSaver *screen_saver)
{
- gdouble current_update_time;
-
- /* flush pending requests to the X server and block for
- * replies before proceeding to help prevent the X server from
- * getting overrun with requests
- */
- if (screen_saver->draw_ops_pending)
- {
- GdkDisplay *display;
-
- display = gtk_widget_get_display (GTK_WIDGET(screen_saver->drawing_area));
- gdk_display_flush (display);
- screen_saver->draw_ops_pending = FALSE;
- }
-
- current_update_time = screen_saver_get_timestamp (screen_saver);
- screen_saver_update_state (screen_saver, current_update_time -
- screen_saver->first_update_time);
- screen_saver->update_count++;
- return TRUE;
+ gdouble current_update_time;
+
+ /* flush pending requests to the X server and block for
+ * replies before proceeding to help prevent the X server from
+ * getting overrun with requests
+ */
+ if (screen_saver->draw_ops_pending)
+ {
+ GdkDisplay *display;
+
+ display = gtk_widget_get_display (GTK_WIDGET(screen_saver->drawing_area));
+ gdk_display_flush (display);
+ screen_saver->draw_ops_pending = FALSE;
+ }
+
+ current_update_time = screen_saver_get_timestamp (screen_saver);
+ screen_saver_update_state (screen_saver, current_update_time -
+ screen_saver->first_update_time);
+ screen_saver->update_count++;
+ return TRUE;
}
static gboolean
screen_saver_do_update_stats (ScreenSaver *screen_saver)
{
- gdouble last_calculated_stats_time, seconds_since_last_stats_update;
+ gdouble last_calculated_stats_time, seconds_since_last_stats_update;
- last_calculated_stats_time = screen_saver->current_calculated_stats_time;
- screen_saver->current_calculated_stats_time =
- screen_saver_get_timestamp (screen_saver);
- screen_saver->last_calculated_stats_time = last_calculated_stats_time;
+ last_calculated_stats_time = screen_saver->current_calculated_stats_time;
+ screen_saver->current_calculated_stats_time =
+ screen_saver_get_timestamp (screen_saver);
+ screen_saver->last_calculated_stats_time = last_calculated_stats_time;
- if (abs (last_calculated_stats_time) <= G_MINDOUBLE)
- return TRUE;
+ if (abs (last_calculated_stats_time) <= G_MINDOUBLE)
+ return TRUE;
- seconds_since_last_stats_update =
- screen_saver->current_calculated_stats_time - last_calculated_stats_time;
+ seconds_since_last_stats_update =
+ screen_saver->current_calculated_stats_time - last_calculated_stats_time;
- screen_saver->updates_per_second =
- screen_saver->update_count / seconds_since_last_stats_update;
- screen_saver->frames_per_second =
- screen_saver->frame_count / seconds_since_last_stats_update;
+ screen_saver->updates_per_second =
+ screen_saver->update_count / seconds_since_last_stats_update;
+ screen_saver->frames_per_second =
+ screen_saver->frame_count / seconds_since_last_stats_update;
- screen_saver->update_count = 0;
- screen_saver->frame_count = 0;
+ screen_saver->update_count = 0;
+ screen_saver->frame_count = 0;
- return TRUE;
+ return TRUE;
}
static gboolean
do_print_screen_saver_stats (ScreenSaver *screen_saver)
{
- g_print ("updates per second: %.2f, frames per second: %.2f, "
- "image cache %.0f%% full\n",
- screen_saver_get_updates_per_second (screen_saver),
- screen_saver_get_frames_per_second (screen_saver),
- screen_saver_get_image_cache_usage (screen_saver) * 100.0);
+ g_print ("updates per second: %.2f, frames per second: %.2f, "
+ "image cache %.0f%% full\n",
+ screen_saver_get_updates_per_second (screen_saver),
+ screen_saver_get_frames_per_second (screen_saver),
+ screen_saver_get_image_cache_usage (screen_saver) * 100.0);
- return TRUE;
+ return TRUE;
}
int
main (int argc,
char *argv[])
{
- ScreenSaver *screen_saver;
- GtkWidget *window;
- GtkWidget *drawing_area;
- GError *error;
+ ScreenSaver *screen_saver;
+ GtkWidget *window;
+ GtkWidget *drawing_area;
+ GError *error;
- error = NULL;
+ error = NULL;
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- gtk_init_with_args (&argc, &argv,
- /* translators: the word "image" here
- * represents a command line argument
- */
- _("image - floats images around the screen"),
- options, GETTEXT_PACKAGE, &error);
+ gtk_init_with_args (&argc, &argv,
+ /* translators: the word "image" here
+ * represents a command line argument
+ */
+ _("image - floats images around the screen"),
+ options, GETTEXT_PACKAGE, &error);
- if (error != NULL)
- {
- g_printerr (_("%s. See --help for usage information.\n"),
- _(error->message));
- g_error_free (error);
- return EX_SOFTWARE;
- }
+ if (error != NULL)
+ {
+ g_printerr (_("%s. See --help for usage information.\n"),
+ _(error->message));
+ g_error_free (error);
+ return EX_SOFTWARE;
+ }
- if ((filenames == NULL) || (filenames[0] == NULL) ||
- (filenames[1] != NULL))
- {
- g_printerr (_("You must specify one image. See --help for usage "
- "information.\n"));
- return EX_USAGE;
- }
+ if ((filenames == NULL) || (filenames[0] == NULL) ||
+ (filenames[1] != NULL))
+ {
+ g_printerr (_("You must specify one image. See --help for usage "
+ "information.\n"));
+ return EX_USAGE;
+ }
- window = gs_theme_window_new ();
+ window = gs_theme_window_new ();
- g_signal_connect (G_OBJECT (window), "delete-event",
- G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (G_OBJECT (window), "delete-event",
+ G_CALLBACK (gtk_main_quit), NULL);
- drawing_area = GTK_WIDGET (gtk_drawing_area_new ());
+ drawing_area = GTK_WIDGET (gtk_drawing_area_new ());
- gtk_widget_show (drawing_area);
- gtk_container_add (GTK_CONTAINER (window), drawing_area);
+ gtk_widget_show (drawing_area);
+ gtk_container_add (GTK_CONTAINER (window), drawing_area);
- screen_saver = screen_saver_new (drawing_area,
- filenames[0], max_floater_count,
- should_do_rotations, should_show_paths);
- g_strfreev (filenames);
+ screen_saver = screen_saver_new (drawing_area,
+ filenames[0], max_floater_count,
+ should_do_rotations, should_show_paths);
+ g_strfreev (filenames);
- if (should_print_stats)
- g_timeout_add (STAT_PRINT_FREQUENCY,
- (GSourceFunc) do_print_screen_saver_stats,
- screen_saver);
+ if (should_print_stats)
+ g_timeout_add (STAT_PRINT_FREQUENCY,
+ (GSourceFunc) do_print_screen_saver_stats,
+ screen_saver);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.20 */
- if ((geometry == NULL)
- || !gtk_window_parse_geometry (GTK_WINDOW (window), geometry))
- gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
- G_GNUC_END_IGNORE_DEPRECATIONS
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.20 */
+ if ((geometry == NULL)
+ || !gtk_window_parse_geometry (GTK_WINDOW (window), geometry))
+ gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
+ G_GNUC_END_IGNORE_DEPRECATIONS
- gtk_widget_show (window);
+ gtk_widget_show (window);
- gtk_main ();
+ gtk_main ();
- screen_saver_free (screen_saver);
+ screen_saver_free (screen_saver);
- return EX_OK;
+ return EX_OK;
}
diff --git a/savers/gs-theme-engine.c b/savers/gs-theme-engine.c
index a4e4780..883ee99 100644
--- a/savers/gs-theme-engine.c
+++ b/savers/gs-theme-engine.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -37,7 +37,7 @@ static void gs_theme_engine_finalize (GObject *object);
struct GSThemeEnginePrivate
{
- gpointer reserved;
+ gpointer reserved;
};
static GObjectClass *parent_class = NULL;
@@ -50,106 +50,106 @@ _gs_theme_engine_profile_log (const char *func,
const char *format,
...)
{
- va_list args;
- char *str;
- char *formatted;
-
- va_start (args, format);
- formatted = g_strdup_vprintf (format, args);
- va_end (args);
-
- if (func != NULL)
- {
- str = g_strdup_printf ("MARK: %s %s: %s %s", g_get_prgname(), func, note ? note : "", formatted);
- }
- else
- {
- str = g_strdup_printf ("MARK: %s: %s %s", g_get_prgname(), note ? note : "", formatted);
- }
-
- g_free (formatted);
-
- access (str, F_OK);
- g_free (str);
+ va_list args;
+ char *str;
+ char *formatted;
+
+ va_start (args, format);
+ formatted = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ if (func != NULL)
+ {
+ str = g_strdup_printf ("MARK: %s %s: %s %s", g_get_prgname(), func, note ? note : "", formatted);
+ }
+ else
+ {
+ str = g_strdup_printf ("MARK: %s: %s %s", g_get_prgname(), note ? note : "", formatted);
+ }
+
+ g_free (formatted);
+
+ access (str, F_OK);
+ g_free (str);
}
static void
-gs_theme_engine_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gs_theme_engine_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GS_THEME_ENGINE (object);
-
- switch (prop_id)
- {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GS_THEME_ENGINE (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gs_theme_engine_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gs_theme_engine_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GS_THEME_ENGINE (object);
-
- switch (prop_id)
- {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GS_THEME_ENGINE (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static gboolean
gs_theme_engine_real_draw (GtkWidget *widget,
cairo_t *cr)
{
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_paint (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
- return FALSE;
+ return FALSE;
}
static void
gs_theme_engine_class_init (GSThemeEngineClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = gs_theme_engine_finalize;
- object_class->get_property = gs_theme_engine_get_property;
- object_class->set_property = gs_theme_engine_set_property;
+ object_class->finalize = gs_theme_engine_finalize;
+ object_class->get_property = gs_theme_engine_get_property;
+ object_class->set_property = gs_theme_engine_set_property;
- widget_class->draw = gs_theme_engine_real_draw;
+ widget_class->draw = gs_theme_engine_real_draw;
}
static void
gs_theme_engine_init (GSThemeEngine *engine)
{
- engine->priv = gs_theme_engine_get_instance_private (engine);
+ engine->priv = gs_theme_engine_get_instance_private (engine);
}
static void
gs_theme_engine_finalize (GObject *object)
{
- GSThemeEngine *engine;
+ GSThemeEngine *engine;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_THEME_ENGINE (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GS_IS_THEME_ENGINE (object));
- engine = GS_THEME_ENGINE (object);
+ engine = GS_THEME_ENGINE (object);
- g_return_if_fail (engine->priv != NULL);
+ g_return_if_fail (engine->priv != NULL);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
@@ -157,33 +157,33 @@ gs_theme_engine_get_window_size (GSThemeEngine *engine,
int *width,
int *height)
{
- if (width != NULL)
- {
- *width = 0;
- }
- if (height != NULL)
- {
- *height = 0;
- }
-
- g_return_if_fail (GS_IS_THEME_ENGINE (engine));
-
- if (! gtk_widget_get_visible (GTK_WIDGET (engine)))
- {
- return;
- }
-
- gdk_window_get_geometry (gtk_widget_get_window (GTK_WIDGET (engine)),
- NULL,
- NULL,
- width,
- height);
+ if (width != NULL)
+ {
+ *width = 0;
+ }
+ if (height != NULL)
+ {
+ *height = 0;
+ }
+
+ g_return_if_fail (GS_IS_THEME_ENGINE (engine));
+
+ if (! gtk_widget_get_visible (GTK_WIDGET (engine)))
+ {
+ return;
+ }
+
+ gdk_window_get_geometry (gtk_widget_get_window (GTK_WIDGET (engine)),
+ NULL,
+ NULL,
+ width,
+ height);
}
GdkWindow *
gs_theme_engine_get_window (GSThemeEngine *engine)
{
- g_return_val_if_fail (GS_IS_THEME_ENGINE (engine), NULL);
+ g_return_val_if_fail (GS_IS_THEME_ENGINE (engine), NULL);
- return gtk_widget_get_window (GTK_WIDGET (engine));
+ return gtk_widget_get_window (GTK_WIDGET (engine));
}
diff --git a/savers/gs-theme-engine.h b/savers/gs-theme-engine.h
index f3492ab..b49286a 100644
--- a/savers/gs-theme-engine.h
+++ b/savers/gs-theme-engine.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -39,26 +39,26 @@ typedef struct GSThemeEnginePrivate GSThemeEnginePrivate;
typedef struct
{
- GtkDrawingArea parent;
- GSThemeEnginePrivate *priv;
+ GtkDrawingArea parent;
+ GSThemeEnginePrivate *priv;
} GSThemeEngine;
typedef struct
{
- GtkDrawingAreaClass parent_class;
+ GtkDrawingAreaClass parent_class;
- /* for signals later if needed */
- gpointer reserved_1;
- gpointer reserved_2;
- gpointer reserved_3;
- gpointer reserved_4;
+ /* for signals later if needed */
+ gpointer reserved_1;
+ gpointer reserved_2;
+ gpointer reserved_3;
+ gpointer reserved_4;
} GSThemeEngineClass;
-GType gs_theme_engine_get_type (void);
+GType gs_theme_engine_get_type (void);
void gs_theme_engine_get_window_size (GSThemeEngine *engine,
- int *width,
- int *height);
+ int *width,
+ int *height);
GdkWindow *gs_theme_engine_get_window (GSThemeEngine *engine);
#define ENABLE_PROFILING 1
@@ -79,9 +79,9 @@ GdkWindow *gs_theme_engine_get_window (GSThemeEngine *engine);
#endif
void _gs_theme_engine_profile_log (const char *func,
- const char *note,
- const char *format,
- ...) G_GNUC_PRINTF (3, 4);
+ const char *note,
+ const char *format,
+ ...) G_GNUC_PRINTF (3, 4);
G_END_DECLS
diff --git a/savers/gs-theme-window.c b/savers/gs-theme-window.c
index 98f79e7..3fabd23 100644
--- a/savers/gs-theme-window.c
+++ b/savers/gs-theme-window.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* gs-theme-window.c - special toplevel for screensavers
*
@@ -48,136 +48,136 @@ G_DEFINE_TYPE (GSThemeWindow, gs_theme_window, GTK_TYPE_WINDOW)
static void
gs_theme_window_class_init (GSThemeWindowClass *klass)
{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = gs_theme_window_finalize;
+ object_class->finalize = gs_theme_window_finalize;
- widget_class->realize = gs_theme_window_real_realize;
+ widget_class->realize = gs_theme_window_real_realize;
}
static void
gs_theme_window_init (GSThemeWindow *window)
{
- gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+ gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
}
static void
gs_theme_window_finalize (GObject *object)
{
- GObjectClass *parent_class;
+ GObjectClass *parent_class;
- GS_THEME_WINDOW (object);
+ GS_THEME_WINDOW (object);
- parent_class = G_OBJECT_CLASS (gs_theme_window_parent_class);
+ parent_class = G_OBJECT_CLASS (gs_theme_window_parent_class);
- if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ if (parent_class->finalize != NULL)
+ parent_class->finalize (object);
}
static void
gs_theme_window_real_realize (GtkWidget *widget)
{
- GdkWindow *window;
- Window remote_xwindow;
- GtkRequisition requisition;
- GtkAllocation allocation;
- const char *preview_xid;
- int x;
- int y;
- int width;
- int height;
- int event_mask;
-
- event_mask = 0;
- window = NULL;
- preview_xid = g_getenv ("XSCREENSAVER_WINDOW");
-
- if (preview_xid != NULL)
- {
- char *end;
-
- remote_xwindow = (Window) strtoul (preview_xid, &end, 0);
-
- if ((remote_xwindow != 0) && (end != NULL) &&
- ((*end == ' ') || (*end == '\0')) &&
- ((remote_xwindow < G_MAXULONG) || (errno != ERANGE)))
- {
- window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), remote_xwindow);
- if (window != NULL)
- {
- /* This is a kludge; we need to set the same
- * flags gs-window-x11.c does, to ensure they
- * don't get unset by gtk_window_map() later.
- */
- gtk_window_set_decorated (GTK_WINDOW (widget), FALSE);
-
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (widget), TRUE);
- gtk_window_set_skip_pager_hint (GTK_WINDOW (widget), TRUE);
-
- gtk_window_set_keep_above (GTK_WINDOW (widget), TRUE);
-
- gtk_window_fullscreen (GTK_WINDOW (widget));
-
- event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK;
- gtk_widget_set_events (widget, gtk_widget_get_events (widget) | event_mask);
- }
- }
- }
-
- if (window == NULL)
- {
- GtkWidgetClass *parent_class;
-
- parent_class = GTK_WIDGET_CLASS (gs_theme_window_parent_class);
-
- if (parent_class->realize != NULL)
- parent_class->realize (widget);
-
- return;
- }
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.18 */
- gtk_style_context_set_background (gtk_widget_get_style_context (widget),
- window);
- G_GNUC_END_IGNORE_DEPRECATIONS
- gdk_window_set_decorations (window, (GdkWMDecoration) 0);
- gdk_window_set_events (window, gdk_window_get_events (window) | event_mask);
-
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
- gtk_widget_set_realized (widget, TRUE);
-
- gdk_window_get_geometry (window, &x, &y, &width, &height);
-
- if (width < MIN_SIZE || height < MIN_SIZE)
- {
- g_critical ("This window is way too small to use");
- exit (1);
- }
-
- gtk_widget_get_preferred_size (widget, &requisition, NULL);
- allocation.x = x;
- allocation.y = y;
- allocation.width = width;
- allocation.height = height;
- gtk_widget_size_allocate (widget, &allocation);
- gtk_window_resize (GTK_WINDOW (widget), width, height);
+ GdkWindow *window;
+ Window remote_xwindow;
+ GtkRequisition requisition;
+ GtkAllocation allocation;
+ const char *preview_xid;
+ int x;
+ int y;
+ int width;
+ int height;
+ int event_mask;
+
+ event_mask = 0;
+ window = NULL;
+ preview_xid = g_getenv ("XSCREENSAVER_WINDOW");
+
+ if (preview_xid != NULL)
+ {
+ char *end;
+
+ remote_xwindow = (Window) strtoul (preview_xid, &end, 0);
+
+ if ((remote_xwindow != 0) && (end != NULL) &&
+ ((*end == ' ') || (*end == '\0')) &&
+ ((remote_xwindow < G_MAXULONG) || (errno != ERANGE)))
+ {
+ window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), remote_xwindow);
+ if (window != NULL)
+ {
+ /* This is a kludge; we need to set the same
+ * flags gs-window-x11.c does, to ensure they
+ * don't get unset by gtk_window_map() later.
+ */
+ gtk_window_set_decorated (GTK_WINDOW (widget), FALSE);
+
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (widget), TRUE);
+ gtk_window_set_skip_pager_hint (GTK_WINDOW (widget), TRUE);
+
+ gtk_window_set_keep_above (GTK_WINDOW (widget), TRUE);
+
+ gtk_window_fullscreen (GTK_WINDOW (widget));
+
+ event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK;
+ gtk_widget_set_events (widget, gtk_widget_get_events (widget) | event_mask);
+ }
+ }
+ }
+
+ if (window == NULL)
+ {
+ GtkWidgetClass *parent_class;
+
+ parent_class = GTK_WIDGET_CLASS (gs_theme_window_parent_class);
+
+ if (parent_class->realize != NULL)
+ parent_class->realize (widget);
+
+ return;
+ }
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.18 */
+ gtk_style_context_set_background (gtk_widget_get_style_context (widget),
+ window);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ gdk_window_set_decorations (window, (GdkWMDecoration) 0);
+ gdk_window_set_events (window, gdk_window_get_events (window) | event_mask);
+
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+ gtk_widget_set_realized (widget, TRUE);
+
+ gdk_window_get_geometry (window, &x, &y, &width, &height);
+
+ if (width < MIN_SIZE || height < MIN_SIZE)
+ {
+ g_critical ("This window is way too small to use");
+ exit (1);
+ }
+
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ allocation.x = x;
+ allocation.y = y;
+ allocation.width = width;
+ allocation.height = height;
+ gtk_widget_size_allocate (widget, &allocation);
+ gtk_window_resize (GTK_WINDOW (widget), width, height);
}
GtkWidget *
gs_theme_window_new (void)
{
- GSThemeWindow *window;
+ GSThemeWindow *window;
- window = g_object_new (GS_TYPE_THEME_WINDOW,
- "type", GTK_WINDOW_TOPLEVEL,
- NULL);
+ window = g_object_new (GS_TYPE_THEME_WINDOW,
+ "type", GTK_WINDOW_TOPLEVEL,
+ NULL);
- return GTK_WIDGET (window);
+ return GTK_WIDGET (window);
}
diff --git a/savers/gs-theme-window.h b/savers/gs-theme-window.h
index 5da4d93..1cc00a0 100644
--- a/savers/gs-theme-window.h
+++ b/savers/gs-theme-window.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* gs-theme-window.h - special toplevel for screensavers
*
@@ -45,22 +45,22 @@ typedef struct _GSThemeWindowClass GSThemeWindowClass;
struct _GSThemeWindow
{
- GtkWindow parent;
+ GtkWindow parent;
- /*< private >*/
- /* reserved for priv pointer */
- gpointer reserved;
+ /*< private >*/
+ /* reserved for priv pointer */
+ gpointer reserved;
};
struct _GSThemeWindowClass
{
- GtkWindowClass parent_class;
+ GtkWindowClass parent_class;
- /* for signals later if needed */
- gpointer reserved_1;
- gpointer reserved_2;
- gpointer reserved_3;
- gpointer reserved_4;
+ /* for signals later if needed */
+ gpointer reserved_1;
+ gpointer reserved_2;
+ gpointer reserved_3;
+ gpointer reserved_4;
};
#ifndef GS_HIDE_FUNCTION_DECLARATIONS
diff --git a/savers/gste-popsquares.c b/savers/gste-popsquares.c
index 37e8bac..10b9685 100644
--- a/savers/gste-popsquares.c
+++ b/savers/gste-popsquares.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -36,23 +36,23 @@ static void gste_popsquares_class_init (GSTEPopsquaresClass *klass);
static void gste_popsquares_init (GSTEPopsquares *engine);
static void gste_popsquares_finalize (GObject *object);
static void draw_frame (GSTEPopsquares *pop,
- cairo_t *cr);
+ cairo_t *cr);
typedef struct _square
{
- int x, y, w, h;
- int color;
+ int x, y, w, h;
+ int color;
} square;
struct GSTEPopsquaresPrivate
{
- guint timeout_id;
+ guint timeout_id;
- int ncolors;
- int subdivision;
+ int ncolors;
+ int subdivision;
- GdkRGBA *colors;
- square *squares;
+ GdkRGBA *colors;
+ square *squares;
};
static GObjectClass *parent_class = NULL;
@@ -67,77 +67,77 @@ hsv_to_rgb (int h,
double *g,
double *b)
{
- double H, S, V, R, G, B;
- double p1, p2, p3;
- double f;
- int i;
-
- if (s < 0)
- {
- s = 0;
- }
- if (v < 0)
- {
- v = 0;
- }
- if (s > 1)
- {
- s = 1;
- }
- if (v > 1)
- {
- v = 1;
- }
-
- S = s;
- V = v;
- H = (h % 360) / 60.0;
- i = H;
- f = H - i;
- p1 = V * (1 - S);
- p2 = V * (1 - (S * f));
- p3 = V * (1 - (S * (1 - f)));
-
- if (i == 0)
- {
- R = V;
- G = p3;
- B = p1;
- }
- else if (i == 1)
- {
- R = p2;
- G = V;
- B = p1;
- }
- else if (i == 2)
- {
- R = p1;
- G = V;
- B = p3;
- }
- else if (i == 3)
- {
- R = p1;
- G = p2;
- B = V;
- }
- else if (i == 4)
- {
- R = p3;
- G = p1;
- B = V;
- }
- else
- {
- R = V;
- G = p1;
- B = p2;
- }
-
- *r = R;
- *g = G;
- *b = B;
+ double H, S, V, R, G, B;
+ double p1, p2, p3;
+ double f;
+ int i;
+
+ if (s < 0)
+ {
+ s = 0;
+ }
+ if (v < 0)
+ {
+ v = 0;
+ }
+ if (s > 1)
+ {
+ s = 1;
+ }
+ if (v > 1)
+ {
+ v = 1;
+ }
+
+ S = s;
+ V = v;
+ H = (h % 360) / 60.0;
+ i = H;
+ f = H - i;
+ p1 = V * (1 - S);
+ p2 = V * (1 - (S * f));
+ p3 = V * (1 - (S * (1 - f)));
+
+ if (i == 0)
+ {
+ R = V;
+ G = p3;
+ B = p1;
+ }
+ else if (i == 1)
+ {
+ R = p2;
+ G = V;
+ B = p1;
+ }
+ else if (i == 2)
+ {
+ R = p1;
+ G = V;
+ B = p3;
+ }
+ else if (i == 3)
+ {
+ R = p1;
+ G = p2;
+ B = V;
+ }
+ else if (i == 4)
+ {
+ R = p3;
+ G = p1;
+ B = V;
+ }
+ else
+ {
+ R = V;
+ G = p1;
+ B = p2;
+ }
+
+ *r = R;
+ *g = G;
+ *b = B;
}
static void
@@ -148,127 +148,127 @@ rgb_to_hsv (double r,
double *s,
double *v)
{
- double R, G, B, H, S, V;
- double cmax, cmin;
- double cmm;
- int imax;
-
- R = r;
- G = g;
- B = b;
- cmax = R;
- cmin = G;
- imax = 1;
-
- if (cmax < G)
- {
- cmax = G;
- cmin = R;
- imax = 2;
- }
- if (cmax < B)
- {
- cmax = B;
- imax = 3;
- }
- if (cmin > B)
- {
- cmin = B;
- }
-
- cmm = cmax - cmin;
- V = cmax;
-
- if (cmm == 0)
- {
- S = H = 0;
- }
- else
- {
- S = cmm / cmax;
- if (imax == 1)
- {
- H = (G - B) / cmm;
- }
- else if (imax == 2)
- {
- H = 2.0 + (B - R) / cmm;
- }
- else
- {
- /*if (imax == 3)*/
- H = 4.0 + (R - G) / cmm;
- }
-
- if (H < 0)
- {
- H += 6.0;
- }
- }
-
- *h = (H * 60.0);
- *s = S;
- *v = V;
+ double R, G, B, H, S, V;
+ double cmax, cmin;
+ double cmm;
+ int imax;
+
+ R = r;
+ G = g;
+ B = b;
+ cmax = R;
+ cmin = G;
+ imax = 1;
+
+ if (cmax < G)
+ {
+ cmax = G;
+ cmin = R;
+ imax = 2;
+ }
+ if (cmax < B)
+ {
+ cmax = B;
+ imax = 3;
+ }
+ if (cmin > B)
+ {
+ cmin = B;
+ }
+
+ cmm = cmax - cmin;
+ V = cmax;
+
+ if (cmm == 0)
+ {
+ S = H = 0;
+ }
+ else
+ {
+ S = cmm / cmax;
+ if (imax == 1)
+ {
+ H = (G - B) / cmm;
+ }
+ else if (imax == 2)
+ {
+ H = 2.0 + (B - R) / cmm;
+ }
+ else
+ {
+ /*if (imax == 3)*/
+ H = 4.0 + (R - G) / cmm;
+ }
+
+ if (H < 0)
+ {
+ H += 6.0;
+ }
+ }
+
+ *h = (H * 60.0);
+ *s = S;
+ *v = V;
}
static void
-make_color_ramp (int h1,
- double s1,
- double v1,
- int h2,
- double s2,
- double v2,
- GdkRGBA *colors,
- int n_colors,
- gboolean closed)
+make_color_ramp (int h1,
+ double s1,
+ double v1,
+ int h2,
+ double s2,
+ double v2,
+ GdkRGBA *colors,
+ int n_colors,
+ gboolean closed)
{
- double dh, ds, dv; /* deltas */
- int i;
- int ncolors, wanted;
- int total_ncolors = n_colors;
-
- wanted = total_ncolors;
- if (closed)
- {
- wanted = (wanted / 2) + 1;
- }
-
- ncolors = total_ncolors;
-
- memset (colors, 0, n_colors * sizeof (*colors));
-
- if (closed)
- {
- ncolors = (ncolors / 2) + 1;
- }
-
- /* Note: unlike other routines in this module, this function assumes that
- if h1 and h2 are more than 180 degrees apart, then the desired direction
- is always from h1 to h2 (rather than the shorter path.) make_uniform
- depends on this.
- */
- dh = ((double)h2 - (double)h1) / ncolors;
- ds = (s2 - s1) / ncolors;
- dv = (v2 - v1) / ncolors;
-
- for (i = 0; i < ncolors; i++)
- {
- hsv_to_rgb ((int) (h1 + (i * dh)),
- (s1 + (i * ds)),
- (v1 + (i * dv)),
- &colors [i].red,
- &colors [i].green,
- &colors [i].blue);
- colors [i].alpha = 1.0;
- }
-
- if (closed)
- {
- for (i = ncolors; i < n_colors; i++)
- {
- colors [i] = colors [n_colors - i];
- }
- }
+ double dh, ds, dv; /* deltas */
+ int i;
+ int ncolors, wanted;
+ int total_ncolors = n_colors;
+
+ wanted = total_ncolors;
+ if (closed)
+ {
+ wanted = (wanted / 2) + 1;
+ }
+
+ ncolors = total_ncolors;
+
+ memset (colors, 0, n_colors * sizeof (*colors));
+
+ if (closed)
+ {
+ ncolors = (ncolors / 2) + 1;
+ }
+
+ /* Note: unlike other routines in this module, this function assumes that
+ if h1 and h2 are more than 180 degrees apart, then the desired direction
+ is always from h1 to h2 (rather than the shorter path.) make_uniform
+ depends on this.
+ */
+ dh = ((double)h2 - (double)h1) / ncolors;
+ ds = (s2 - s1) / ncolors;
+ dv = (v2 - v1) / ncolors;
+
+ for (i = 0; i < ncolors; i++)
+ {
+ hsv_to_rgb ((int) (h1 + (i * dh)),
+ (s1 + (i * ds)),
+ (v1 + (i * dv)),
+ &colors [i].red,
+ &colors [i].green,
+ &colors [i].blue);
+ colors [i].alpha = 1.0;
+ }
+
+ if (closed)
+ {
+ for (i = ncolors; i < n_colors; i++)
+ {
+ colors [i] = colors [n_colors - i];
+ }
+ }
}
@@ -277,15 +277,15 @@ randomize_square_colors (square *squares,
int nsquares,
int ncolors)
{
- int i;
- square *s;
+ int i;
+ square *s;
- s = squares;
+ s = squares;
- for (i = 0; i < nsquares; i++)
- {
- s[i].color = g_random_int_range (0, ncolors);
- }
+ for (i = 0; i < nsquares; i++)
+ {
+ s[i].color = g_random_int_range (0, ncolors);
+ }
}
static void
@@ -293,316 +293,316 @@ set_colors (GtkWidget *widget,
GdkRGBA *fg,
GdkRGBA *bg)
{
- GtkStyleContext *style;
-
- style = gtk_widget_get_style_context (widget);
-
- gtk_style_context_save (style);
- gtk_style_context_set_state (style, GTK_STATE_FLAG_SELECTED);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.16 */
- gtk_style_context_get_background_color (style,
- gtk_style_context_get_state (style),
- bg);
- G_GNUC_END_IGNORE_DEPRECATIONS
- if (bg->alpha == 0.0)
- {
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_VIEW);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.16 */
- gtk_style_context_get_background_color (style,
- gtk_style_context_get_state (style),
- bg);
- G_GNUC_END_IGNORE_DEPRECATIONS
- }
- gtk_style_context_restore (style);
-
- fg->red = bg->red * 0.7;
- fg->green = bg->green * 0.7;
- fg->blue = bg->blue * 0.7;
- fg->alpha = bg->alpha;
+ GtkStyleContext *style;
+
+ style = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_SELECTED);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.16 */
+ gtk_style_context_get_background_color (style,
+ gtk_style_context_get_state (style),
+ bg);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ if (bg->alpha == 0.0)
+ {
+ gtk_style_context_add_class (style, GTK_STYLE_CLASS_VIEW);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.16 */
+ gtk_style_context_get_background_color (style,
+ gtk_style_context_get_state (style),
+ bg);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ }
+ gtk_style_context_restore (style);
+
+ fg->red = bg->red * 0.7;
+ fg->green = bg->green * 0.7;
+ fg->blue = bg->blue * 0.7;
+ fg->alpha = bg->alpha;
}
static void
-gste_popsquares_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gste_popsquares_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GSTE_POPSQUARES (object);
-
- switch (prop_id)
- {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSTE_POPSQUARES (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gste_popsquares_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gste_popsquares_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GSTE_POPSQUARES (object);
-
- switch (prop_id)
- {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSTE_POPSQUARES (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
setup_squares (GSTEPopsquares *pop)
{
- int window_width;
- int window_height;
- int nsquares;
- int x, y;
- int sw, sh, gw, gh;
- GdkWindow *window;
-
- window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop));
-
- if (window == NULL)
- {
- return;
- }
-
- gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop), &window_width, &window_height);
-
- sw = window_width / pop->priv->subdivision;
- sh = window_height / pop->priv->subdivision;
-
- gw = pop->priv->subdivision;
- gh = pop->priv->subdivision;
- nsquares = gw * gh;
-
- if (pop->priv->squares)
- {
- g_free (pop->priv->squares);
- }
- pop->priv->squares = g_new0 (square, nsquares);
-
- for (y = 0; y < gh; y++)
- {
- for (x = 0; x < gw; x++)
- {
- square *s = (square *) &pop->priv->squares [gw * y + x];
- s->w = sw;
- s->h = sh;
- s->x = x * sw;
- s->y = y * sh;
- }
- }
+ int window_width;
+ int window_height;
+ int nsquares;
+ int x, y;
+ int sw, sh, gw, gh;
+ GdkWindow *window;
+
+ window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop));
+
+ if (window == NULL)
+ {
+ return;
+ }
+
+ gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop), &window_width, &window_height);
+
+ sw = window_width / pop->priv->subdivision;
+ sh = window_height / pop->priv->subdivision;
+
+ gw = pop->priv->subdivision;
+ gh = pop->priv->subdivision;
+ nsquares = gw * gh;
+
+ if (pop->priv->squares)
+ {
+ g_free (pop->priv->squares);
+ }
+ pop->priv->squares = g_new0 (square, nsquares);
+
+ for (y = 0; y < gh; y++)
+ {
+ for (x = 0; x < gw; x++)
+ {
+ square *s = (square *) &pop->priv->squares [gw * y + x];
+ s->w = sw;
+ s->h = sh;
+ s->x = x * sw;
+ s->y = y * sh;
+ }
+ }
}
static void
setup_colors (GSTEPopsquares *pop)
{
- double s1, v1, s2, v2 = 0;
- int h1, h2 = 0;
- int nsquares;
- GdkRGBA fg;
- GdkRGBA bg;
- GdkWindow *window;
+ double s1, v1, s2, v2 = 0;
+ int h1, h2 = 0;
+ int nsquares;
+ GdkRGBA fg;
+ GdkRGBA bg;
+ GdkWindow *window;
- window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop));
+ window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop));
- if (window == NULL)
- {
- return;
- }
+ if (window == NULL)
+ {
+ return;
+ }
- set_colors (GTK_WIDGET (pop), &fg, &bg);
+ set_colors (GTK_WIDGET (pop), &fg, &bg);
- if (pop->priv->colors)
- {
- g_free (pop->priv->colors);
- }
- pop->priv->colors = g_new0 (GdkRGBA, pop->priv->ncolors);
+ if (pop->priv->colors)
+ {
+ g_free (pop->priv->colors);
+ }
+ pop->priv->colors = g_new0 (GdkRGBA, pop->priv->ncolors);
- rgb_to_hsv (fg.red, fg.green, fg.blue, &h1, &s1, &v1);
- rgb_to_hsv (bg.red, bg.green, bg.blue, &h2, &s2, &v2);
+ rgb_to_hsv (fg.red, fg.green, fg.blue, &h1, &s1, &v1);
+ rgb_to_hsv (bg.red, bg.green, bg.blue, &h2, &s2, &v2);
- make_color_ramp (h1, s1, v1,
- h2, s2, v2,
- pop->priv->colors,
- pop->priv->ncolors,
- TRUE);
+ make_color_ramp (h1, s1, v1,
+ h2, s2, v2,
+ pop->priv->colors,
+ pop->priv->ncolors,
+ TRUE);
- nsquares = pop->priv->subdivision * pop->priv->subdivision;
+ nsquares = pop->priv->subdivision * pop->priv->subdivision;
- randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
+ randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
}
static void
gste_popsquares_real_show (GtkWidget *widget)
{
- GSTEPopsquares *pop = GSTE_POPSQUARES (widget);
+ GSTEPopsquares *pop = GSTE_POPSQUARES (widget);
- /* start */
- setup_squares (pop);
- setup_colors (pop);
+ /* start */
+ setup_squares (pop);
+ setup_colors (pop);
- if (GTK_WIDGET_CLASS (parent_class)->show)
- {
- GTK_WIDGET_CLASS (parent_class)->show (widget);
- }
+ if (GTK_WIDGET_CLASS (parent_class)->show)
+ {
+ GTK_WIDGET_CLASS (parent_class)->show (widget);
+ }
}
static gboolean
gste_popsquares_real_draw (GtkWidget *widget,
cairo_t *cr)
{
- if (GTK_WIDGET_CLASS (parent_class)->draw) {
- GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- }
+ if (GTK_WIDGET_CLASS (parent_class)->draw) {
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+ }
- draw_frame (GSTE_POPSQUARES (widget), cr);
+ draw_frame (GSTE_POPSQUARES (widget), cr);
- return TRUE;
+ return TRUE;
}
static gboolean
gste_popsquares_real_configure (GtkWidget *widget,
GdkEventConfigure *event)
{
- GSTEPopsquares *pop = GSTE_POPSQUARES (widget);
- gboolean handled = FALSE;
+ GSTEPopsquares *pop = GSTE_POPSQUARES (widget);
+ gboolean handled = FALSE;
- /* resize */
+ /* resize */
- /* just reset everything */
- setup_squares (pop);
- setup_colors (pop);
+ /* just reset everything */
+ setup_squares (pop);
+ setup_colors (pop);
- /* schedule a redraw */
- gtk_widget_queue_draw (widget);
+ /* schedule a redraw */
+ gtk_widget_queue_draw (widget);
- if (GTK_WIDGET_CLASS (parent_class)->configure_event)
- {
- handled = GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
- }
+ if (GTK_WIDGET_CLASS (parent_class)->configure_event)
+ {
+ handled = GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
+ }
- return handled;
+ return handled;
}
static void
gste_popsquares_class_init (GSTEPopsquaresClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = gste_popsquares_finalize;
- object_class->get_property = gste_popsquares_get_property;
- object_class->set_property = gste_popsquares_set_property;
+ object_class->finalize = gste_popsquares_finalize;
+ object_class->get_property = gste_popsquares_get_property;
+ object_class->set_property = gste_popsquares_set_property;
- widget_class->show = gste_popsquares_real_show;
- widget_class->draw = gste_popsquares_real_draw;
- widget_class->configure_event = gste_popsquares_real_configure;
+ widget_class->show = gste_popsquares_real_show;
+ widget_class->draw = gste_popsquares_real_draw;
+ widget_class->configure_event = gste_popsquares_real_configure;
}
static void
draw_frame (GSTEPopsquares *pop,
cairo_t *cr)
{
- int border = 1;
- gboolean twitch = FALSE;
- int x, y;
- int gw, gh;
- int nsquares;
- int window_width;
- int window_height;
- GdkWindow *window;
-
- window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop));
-
- if (window == NULL)
- {
- return;
- }
-
- gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop),
- &window_width,
- &window_height);
-
- gw = pop->priv->subdivision;
- gh = pop->priv->subdivision;
- nsquares = gw * gh;
-
- for (y = 0; y < gh; y++)
- {
- for (x = 0; x < gw; x++)
- {
- square *s = (square *) &pop->priv->squares [gw * y + x];
-
- gdk_cairo_set_source_rgba (cr, &(pop->priv->colors [s->color]));
- cairo_rectangle (cr, s->x, s->y,
- border ? s->w - border : s->w,
- border ? s->h - border : s->h);
- cairo_fill (cr);
- s->color++;
-
- if (s->color == pop->priv->ncolors)
- {
- if (twitch && ((g_random_int_range (0, 4)) == 0))
- {
- randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
- }
- else
- {
- s->color = g_random_int_range (0, pop->priv->ncolors);
- }
- }
- }
- }
+ int border = 1;
+ gboolean twitch = FALSE;
+ int x, y;
+ int gw, gh;
+ int nsquares;
+ int window_width;
+ int window_height;
+ GdkWindow *window;
+
+ window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop));
+
+ if (window == NULL)
+ {
+ return;
+ }
+
+ gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop),
+ &window_width,
+ &window_height);
+
+ gw = pop->priv->subdivision;
+ gh = pop->priv->subdivision;
+ nsquares = gw * gh;
+
+ for (y = 0; y < gh; y++)
+ {
+ for (x = 0; x < gw; x++)
+ {
+ square *s = (square *) &pop->priv->squares [gw * y + x];
+
+ gdk_cairo_set_source_rgba (cr, &(pop->priv->colors [s->color]));
+ cairo_rectangle (cr, s->x, s->y,
+ border ? s->w - border : s->w,
+ border ? s->h - border : s->h);
+ cairo_fill (cr);
+ s->color++;
+
+ if (s->color == pop->priv->ncolors)
+ {
+ if (twitch && ((g_random_int_range (0, 4)) == 0))
+ {
+ randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
+ }
+ else
+ {
+ s->color = g_random_int_range (0, pop->priv->ncolors);
+ }
+ }
+ }
+ }
}
static gboolean
draw_iter (GSTEPopsquares *pop)
{
- gtk_widget_queue_draw (GTK_WIDGET (pop));
- return TRUE;
+ gtk_widget_queue_draw (GTK_WIDGET (pop));
+ return TRUE;
}
static void
gste_popsquares_init (GSTEPopsquares *pop)
{
- int delay;
+ int delay;
- pop->priv = gste_popsquares_get_instance_private (pop);
+ pop->priv = gste_popsquares_get_instance_private (pop);
- pop->priv->ncolors = 128;
- pop->priv->subdivision = 5;
+ pop->priv->ncolors = 128;
+ pop->priv->subdivision = 5;
- delay = 25;
- pop->priv->timeout_id = g_timeout_add (delay, (GSourceFunc)draw_iter, pop);
+ delay = 25;
+ pop->priv->timeout_id = g_timeout_add (delay, (GSourceFunc)draw_iter, pop);
}
static void
gste_popsquares_finalize (GObject *object)
{
- GSTEPopsquares *pop;
+ GSTEPopsquares *pop;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GSTE_IS_POPSQUARES (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GSTE_IS_POPSQUARES (object));
- pop = GSTE_POPSQUARES (object);
+ pop = GSTE_POPSQUARES (object);
- g_return_if_fail (pop->priv != NULL);
+ g_return_if_fail (pop->priv != NULL);
- if (pop->priv->timeout_id > 0)
- {
- g_source_remove (pop->priv->timeout_id);
- pop->priv->timeout_id = 0;
- }
+ if (pop->priv->timeout_id > 0)
+ {
+ g_source_remove (pop->priv->timeout_id);
+ pop->priv->timeout_id = 0;
+ }
- g_free (pop->priv->squares);
- g_free (pop->priv->colors);
+ g_free (pop->priv->squares);
+ g_free (pop->priv->colors);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/savers/gste-popsquares.h b/savers/gste-popsquares.h
index a4130c2..a0ddc81 100644
--- a/savers/gste-popsquares.h
+++ b/savers/gste-popsquares.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -40,17 +40,17 @@ typedef struct GSTEPopsquaresPrivate GSTEPopsquaresPrivate;
typedef struct
{
- GSThemeEngine parent;
- GSTEPopsquaresPrivate *priv;
+ GSThemeEngine parent;
+ GSTEPopsquaresPrivate *priv;
} GSTEPopsquares;
typedef struct
{
- GSThemeEngineClass parent_class;
+ GSThemeEngineClass parent_class;
} GSTEPopsquaresClass;
-GType gste_popsquares_get_type (void);
-GSThemeEngine *gste_popsquares_new (void);
+GType gste_popsquares_get_type (void);
+GSThemeEngine *gste_popsquares_new (void);
G_END_DECLS
diff --git a/savers/gste-slideshow.c b/savers/gste-slideshow.c
index e131d29..08ea463 100644
--- a/savers/gste-slideshow.c
+++ b/savers/gste-slideshow.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (C) 2005-2006 William Jon McCann <mccann at jhu.edu>
*
@@ -38,44 +38,44 @@ static void gste_slideshow_finalize (GObject *object);
struct GSTESlideshowPrivate
{
- /* Image at full opacity */
- cairo_pattern_t *pat1;
- /* Image at partial opacity */
- cairo_pattern_t *pat2;
- /* Alpha of pat2 */
- gdouble alpha2;
- /* edges of pat2 */
- int pat2top;
- int pat2bottom;
- int pat2left;
- int pat2right;
-
- /* backbuffer that we do all the alpha drawing into (no round
- * trips to the X server when the server doesn't support drawing
- * pixmaps with alpha?) */
- cairo_surface_t *surf;
-
- gint64 fade_ticks;
-
- GThread *load_thread;
- GAsyncQueue *op_q;
- GAsyncQueue *results_q;
-
- guint results_pull_id;
- guint update_image_id;
-
- GSList *filename_list;
- char *images_location;
- gboolean sort_images;
- int window_width;
- int window_height;
- PangoColor *background_color;
- gboolean no_stretch_hint;
-
- guint timeout_id;
-
- GTimer *timer;
- gboolean fade_disabled;
+ /* Image at full opacity */
+ cairo_pattern_t *pat1;
+ /* Image at partial opacity */
+ cairo_pattern_t *pat2;
+ /* Alpha of pat2 */
+ gdouble alpha2;
+ /* edges of pat2 */
+ int pat2top;
+ int pat2bottom;
+ int pat2left;
+ int pat2right;
+
+ /* backbuffer that we do all the alpha drawing into (no round
+ * trips to the X server when the server doesn't support drawing
+ * pixmaps with alpha?) */
+ cairo_surface_t *surf;
+
+ gint64 fade_ticks;
+
+ GThread *load_thread;
+ GAsyncQueue *op_q;
+ GAsyncQueue *results_q;
+
+ guint results_pull_id;
+ guint update_image_id;
+
+ GSList *filename_list;
+ char *images_location;
+ gboolean sort_images;
+ int window_width;
+ int window_height;
+ PangoColor *background_color;
+ gboolean no_stretch_hint;
+
+ guint timeout_id;
+
+ GTimer *timer;
+ gboolean fade_disabled;
};
enum
@@ -98,352 +98,352 @@ G_DEFINE_TYPE_WITH_PRIVATE (GSTESlideshow, gste_slideshow, GS_TYPE_THEME_ENGINE)
typedef struct _Op
{
- char *location;
- GSTESlideshow *slideshow;
+ char *location;
+ GSTESlideshow *slideshow;
} Op;
typedef struct _OpResult
{
- GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf;
} OpResult;
static gboolean
push_load_image_func (GSTESlideshow *show)
{
- Op *op;
+ Op *op;
- gs_theme_engine_profile_msg ("Starting a new image load");
+ gs_theme_engine_profile_msg ("Starting a new image load");
- op = g_new (Op, 1);
+ op = g_new (Op, 1);
- op->location = g_strdup (show->priv->images_location);
- op->slideshow = g_object_ref (show);
+ op->location = g_strdup (show->priv->images_location);
+ op->slideshow = g_object_ref (show);
- g_async_queue_push (show->priv->op_q, op);
+ g_async_queue_push (show->priv->op_q, op);
- show->priv->update_image_id = 0;
+ show->priv->update_image_id = 0;
- return FALSE;
+ return FALSE;
}
static void
start_new_load (GSTESlideshow *show,
guint timeout)
{
- gs_theme_engine_profile_msg ("Scheduling a new image load");
-
- /* queue a new load */
- if (show->priv->update_image_id <= 0)
- {
- show->priv->update_image_id = g_timeout_add_full (G_PRIORITY_LOW, timeout,
- (GSourceFunc)push_load_image_func,
- show, NULL);
- }
+ gs_theme_engine_profile_msg ("Scheduling a new image load");
+
+ /* queue a new load */
+ if (show->priv->update_image_id <= 0)
+ {
+ show->priv->update_image_id = g_timeout_add_full (G_PRIORITY_LOW, timeout,
+ (GSourceFunc)push_load_image_func,
+ show, NULL);
+ }
}
static void
start_fade (GSTESlideshow *show,
GdkPixbuf *pixbuf)
{
- int pw;
- int ph;
- int x;
- int y;
- cairo_t *cr;
- int window_width;
- int window_height;
-
- gs_theme_engine_profile_start ("start");
-
- window_width = show->priv->window_width;
- window_height = show->priv->window_height;
-
- if (show->priv->pat2 != NULL)
- {
- cairo_pattern_destroy (show->priv->pat2);
- }
-
- pw = gdk_pixbuf_get_width (pixbuf);
- ph = gdk_pixbuf_get_height (pixbuf);
- x = (window_width - pw) / 2;
- y = (window_height - ph) / 2;
-
- if (gdk_pixbuf_get_has_alpha (pixbuf) && show->priv->background_color)
- {
- GdkPixbuf *colored;
- guint32 color;
-
- color = (show->priv->background_color->red << 16)
- + (show->priv->background_color->green / 256 << 8)
- + show->priv->background_color->blue / 256;
- colored = gdk_pixbuf_composite_color_simple (pixbuf,
- pw, ph,
- GDK_INTERP_BILINEAR,
- 255,
- 256,
- color,
- color);
-
- gdk_pixbuf_copy_area (colored, 0, 0,
- gdk_pixbuf_get_width (colored),
- gdk_pixbuf_get_height (colored),
- pixbuf, 0, 0);
-
- g_object_unref(colored);
- }
-
- cr = cairo_create (show->priv->surf);
-
- /* XXX Handle out of memory? */
- gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
- show->priv->pat2 = cairo_pattern_reference (cairo_get_source (cr));
- show->priv->pat2top = y;
- show->priv->pat2bottom = y + ph;
- show->priv->pat2left = x;
- show->priv->pat2right = x + pw;
-
- cairo_destroy (cr);
-
- show->priv->fade_ticks = 0;
- g_timer_start (show->priv->timer);
-
- gs_theme_engine_profile_end ("end");
+ int pw;
+ int ph;
+ int x;
+ int y;
+ cairo_t *cr;
+ int window_width;
+ int window_height;
+
+ gs_theme_engine_profile_start ("start");
+
+ window_width = show->priv->window_width;
+ window_height = show->priv->window_height;
+
+ if (show->priv->pat2 != NULL)
+ {
+ cairo_pattern_destroy (show->priv->pat2);
+ }
+
+ pw = gdk_pixbuf_get_width (pixbuf);
+ ph = gdk_pixbuf_get_height (pixbuf);
+ x = (window_width - pw) / 2;
+ y = (window_height - ph) / 2;
+
+ if (gdk_pixbuf_get_has_alpha (pixbuf) && show->priv->background_color)
+ {
+ GdkPixbuf *colored;
+ guint32 color;
+
+ color = (show->priv->background_color->red << 16)
+ + (show->priv->background_color->green / 256 << 8)
+ + show->priv->background_color->blue / 256;
+ colored = gdk_pixbuf_composite_color_simple (pixbuf,
+ pw, ph,
+ GDK_INTERP_BILINEAR,
+ 255,
+ 256,
+ color,
+ color);
+
+ gdk_pixbuf_copy_area (colored, 0, 0,
+ gdk_pixbuf_get_width (colored),
+ gdk_pixbuf_get_height (colored),
+ pixbuf, 0, 0);
+
+ g_object_unref(colored);
+ }
+
+ cr = cairo_create (show->priv->surf);
+
+ /* XXX Handle out of memory? */
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
+ show->priv->pat2 = cairo_pattern_reference (cairo_get_source (cr));
+ show->priv->pat2top = y;
+ show->priv->pat2bottom = y + ph;
+ show->priv->pat2left = x;
+ show->priv->pat2right = x + pw;
+
+ cairo_destroy (cr);
+
+ show->priv->fade_ticks = 0;
+ g_timer_start (show->priv->timer);
+
+ gs_theme_engine_profile_end ("end");
}
static void
finish_fade (GSTESlideshow *show)
{
- gs_theme_engine_profile_start ("start");
+ gs_theme_engine_profile_start ("start");
- if (show->priv->pat1 != NULL)
- {
- cairo_pattern_destroy (show->priv->pat1);
- }
+ if (show->priv->pat1 != NULL)
+ {
+ cairo_pattern_destroy (show->priv->pat1);
+ }
- show->priv->pat1 = show->priv->pat2;
- show->priv->pat2 = NULL;
+ show->priv->pat1 = show->priv->pat2;
+ show->priv->pat2 = NULL;
- start_new_load (show, IMAGE_LOAD_TIMEOUT);
+ start_new_load (show, IMAGE_LOAD_TIMEOUT);
- gs_theme_engine_profile_end ("end");
+ gs_theme_engine_profile_end ("end");
}
static void
update_display (GSTESlideshow *show)
{
- int window_width;
- int window_height;
- cairo_t *cr;
-
- gs_theme_engine_profile_start ("start");
-
- cr = cairo_create (show->priv->surf);
-
- gs_theme_engine_get_window_size (GS_THEME_ENGINE (show),
- &window_width,
- &window_height);
-
- if (show->priv->pat2 != NULL)
- {
- /* fade out areas not covered by the new image */
- /* top */
- cairo_rectangle (cr, 0, 0, window_width, show->priv->pat2top);
- if (show->priv->background_color)
- {
- cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
- show->priv->background_color->green / 65535.0,
- show->priv->background_color->blue / 65535.0, show->priv->alpha2);
- }
- else
- {
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
- }
- cairo_fill (cr);
- /* left (excluding what's covered by top and bottom) */
- cairo_rectangle (cr, 0, show->priv->pat2top,
- show->priv->pat2left,
- show->priv->pat2bottom - show->priv->pat2top);
- if (show->priv->background_color)
- {
- cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
- show->priv->background_color->green / 65535.0,
- show->priv->background_color->blue / 65535.0, show->priv->alpha2);
- }
- else
- {
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
- }
- cairo_fill (cr);
- /* bottom */
- cairo_rectangle (cr, 0, show->priv->pat2bottom, window_width,
- window_height - show->priv->pat2bottom);
- if (show->priv->background_color)
- {
- cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
- show->priv->background_color->green / 65535.0,
- show->priv->background_color->blue / 65535.0, show->priv->alpha2);
- }
- else
- {
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
- }
- cairo_fill (cr);
- /* right (excluding what's covered by top and bottom) */
- cairo_rectangle (cr, show->priv->pat2right,
- show->priv->pat2top,
- window_width - show->priv->pat2right,
- show->priv->pat2bottom - show->priv->pat2top);
- if (show->priv->background_color)
- {
- cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
- show->priv->background_color->green / 65535.0,
- show->priv->background_color->blue / 65535.0, show->priv->alpha2);
- }
- else
- {
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
- }
- cairo_fill (cr);
-
- gs_theme_engine_profile_start ("paint pattern to surface");
- cairo_set_source (cr, show->priv->pat2);
-
- cairo_paint_with_alpha (cr, show->priv->alpha2);
- gs_theme_engine_profile_end ("paint pattern to surface");
- }
- else
- {
- if (show->priv->pat1 != NULL)
- {
- cairo_set_source (cr, show->priv->pat1);
- cairo_paint (cr);
- }
- }
-
- cairo_destroy (cr);
-
- gtk_widget_queue_draw (GTK_WIDGET (show));
+ int window_width;
+ int window_height;
+ cairo_t *cr;
+
+ gs_theme_engine_profile_start ("start");
+
+ cr = cairo_create (show->priv->surf);
+
+ gs_theme_engine_get_window_size (GS_THEME_ENGINE (show),
+ &window_width,
+ &window_height);
+
+ if (show->priv->pat2 != NULL)
+ {
+ /* fade out areas not covered by the new image */
+ /* top */
+ cairo_rectangle (cr, 0, 0, window_width, show->priv->pat2top);
+ if (show->priv->background_color)
+ {
+ cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
+ show->priv->background_color->green / 65535.0,
+ show->priv->background_color->blue / 65535.0, show->priv->alpha2);
+ }
+ else
+ {
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
+ }
+ cairo_fill (cr);
+ /* left (excluding what's covered by top and bottom) */
+ cairo_rectangle (cr, 0, show->priv->pat2top,
+ show->priv->pat2left,
+ show->priv->pat2bottom - show->priv->pat2top);
+ if (show->priv->background_color)
+ {
+ cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
+ show->priv->background_color->green / 65535.0,
+ show->priv->background_color->blue / 65535.0, show->priv->alpha2);
+ }
+ else
+ {
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
+ }
+ cairo_fill (cr);
+ /* bottom */
+ cairo_rectangle (cr, 0, show->priv->pat2bottom, window_width,
+ window_height - show->priv->pat2bottom);
+ if (show->priv->background_color)
+ {
+ cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
+ show->priv->background_color->green / 65535.0,
+ show->priv->background_color->blue / 65535.0, show->priv->alpha2);
+ }
+ else
+ {
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
+ }
+ cairo_fill (cr);
+ /* right (excluding what's covered by top and bottom) */
+ cairo_rectangle (cr, show->priv->pat2right,
+ show->priv->pat2top,
+ window_width - show->priv->pat2right,
+ show->priv->pat2bottom - show->priv->pat2top);
+ if (show->priv->background_color)
+ {
+ cairo_set_source_rgba (cr, show->priv->background_color->red / 65535.0,
+ show->priv->background_color->green / 65535.0,
+ show->priv->background_color->blue / 65535.0, show->priv->alpha2);
+ }
+ else
+ {
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, show->priv->alpha2);
+ }
+ cairo_fill (cr);
+
+ gs_theme_engine_profile_start ("paint pattern to surface");
+ cairo_set_source (cr, show->priv->pat2);
+
+ cairo_paint_with_alpha (cr, show->priv->alpha2);
+ gs_theme_engine_profile_end ("paint pattern to surface");
+ }
+ else
+ {
+ if (show->priv->pat1 != NULL)
+ {
+ cairo_set_source (cr, show->priv->pat1);
+ cairo_paint (cr);
+ }
+ }
+
+ cairo_destroy (cr);
+
+ gtk_widget_queue_draw (GTK_WIDGET (show));
}
static gboolean
draw_iter (GSTESlideshow *show)
{
- double old_opacity;
- double new_opacity;
-
- if (show->priv->pat2 != NULL)
- {
- gdouble fps;
- gdouble elapsed;
-
- if (show->priv->fade_disabled)
- {
- show->priv->alpha2 = 1.0;
- update_display (show);
- finish_fade (show);
- return TRUE;
- }
-
- /* we are in a fade */
- show->priv->fade_ticks++;
-
- /*
- * We have currently drawn pat2 with old_opacity, and we
- * want to set alpha2 so that drawing pat2 at alpha2
- * yields it drawn with new_opacity
- *
- * Solving
- * new_opacity = 1 - (1 - alpha2) * (1 - old_opacity)
- * yields
- * alpha2 = 1 - (1 - new_opacity) / (1 - old_opacity)
- *
- * XXX This assumes that cairo doesn't correct alpha for
- * the color profile. However, any error is guaranteed
- * to be cleaned up by the last iteration, where alpha2
- * becomes 1 because new_opacity is 1.
- */
- old_opacity = (double) (show->priv->fade_ticks - 1) /
- (double) N_FADE_TICKS;
- new_opacity = (double) show->priv->fade_ticks /
- (double) N_FADE_TICKS;
- show->priv->alpha2 = 1.0 - (1.0 - new_opacity) /
- (1.0 - old_opacity);
-
- update_display (show);
-
- elapsed = g_timer_elapsed (show->priv->timer, NULL);
- fps = (gdouble)show->priv->fade_ticks / elapsed;
- if (fps < MINIMUM_FPS)
- {
- g_warning ("Getting less than %.2f frames per second, disabling fade", MINIMUM_FPS);
- show->priv->fade_ticks = N_FADE_TICKS - 1;
- show->priv->fade_disabled = TRUE;
- }
-
- if (show->priv->fade_ticks >= N_FADE_TICKS)
- {
- finish_fade (show);
- }
- }
-
- return TRUE;
+ double old_opacity;
+ double new_opacity;
+
+ if (show->priv->pat2 != NULL)
+ {
+ gdouble fps;
+ gdouble elapsed;
+
+ if (show->priv->fade_disabled)
+ {
+ show->priv->alpha2 = 1.0;
+ update_display (show);
+ finish_fade (show);
+ return TRUE;
+ }
+
+ /* we are in a fade */
+ show->priv->fade_ticks++;
+
+ /*
+ * We have currently drawn pat2 with old_opacity, and we
+ * want to set alpha2 so that drawing pat2 at alpha2
+ * yields it drawn with new_opacity
+ *
+ * Solving
+ * new_opacity = 1 - (1 - alpha2) * (1 - old_opacity)
+ * yields
+ * alpha2 = 1 - (1 - new_opacity) / (1 - old_opacity)
+ *
+ * XXX This assumes that cairo doesn't correct alpha for
+ * the color profile. However, any error is guaranteed
+ * to be cleaned up by the last iteration, where alpha2
+ * becomes 1 because new_opacity is 1.
+ */
+ old_opacity = (double) (show->priv->fade_ticks - 1) /
+ (double) N_FADE_TICKS;
+ new_opacity = (double) show->priv->fade_ticks /
+ (double) N_FADE_TICKS;
+ show->priv->alpha2 = 1.0 - (1.0 - new_opacity) /
+ (1.0 - old_opacity);
+
+ update_display (show);
+
+ elapsed = g_timer_elapsed (show->priv->timer, NULL);
+ fps = (gdouble)show->priv->fade_ticks / elapsed;
+ if (fps < MINIMUM_FPS)
+ {
+ g_warning ("Getting less than %.2f frames per second, disabling fade", MINIMUM_FPS);
+ show->priv->fade_ticks = N_FADE_TICKS - 1;
+ show->priv->fade_disabled = TRUE;
+ }
+
+ if (show->priv->fade_ticks >= N_FADE_TICKS)
+ {
+ finish_fade (show);
+ }
+ }
+
+ return TRUE;
}
static void
process_new_pixbuf (GSTESlideshow *show,
GdkPixbuf *pixbuf)
{
- gs_theme_engine_profile_msg ("Processing a new image");
-
- if (pixbuf != NULL)
- {
- start_fade (show, pixbuf);
- }
- else
- {
- start_new_load (show, 10);
- }
+ gs_theme_engine_profile_msg ("Processing a new image");
+
+ if (pixbuf != NULL)
+ {
+ start_fade (show, pixbuf);
+ }
+ else
+ {
+ start_new_load (show, 10);
+ }
}
static void
op_result_free (OpResult *result)
{
- if (result == NULL)
- {
- return;
- }
+ if (result == NULL)
+ {
+ return;
+ }
- if (result->pixbuf != NULL)
- {
- g_object_unref (result->pixbuf);
- }
+ if (result->pixbuf != NULL)
+ {
+ g_object_unref (result->pixbuf);
+ }
- g_free (result);
+ g_free (result);
}
static gboolean
results_pull_func (GSTESlideshow *show)
{
- OpResult *result;
+ OpResult *result;
- g_async_queue_lock (show->priv->results_q);
+ g_async_queue_lock (show->priv->results_q);
- result = g_async_queue_try_pop_unlocked (show->priv->results_q);
- g_assert (result);
+ result = g_async_queue_try_pop_unlocked (show->priv->results_q);
+ g_assert (result);
- while (result != NULL)
- {
- process_new_pixbuf (show, result->pixbuf);
- op_result_free (result);
+ while (result != NULL)
+ {
+ process_new_pixbuf (show, result->pixbuf);
+ op_result_free (result);
- result = g_async_queue_try_pop_unlocked (show->priv->results_q);
- }
+ result = g_async_queue_try_pop_unlocked (show->priv->results_q);
+ }
- show->priv->results_pull_id = 0;
+ show->priv->results_pull_id = 0;
- g_async_queue_unlock (show->priv->results_q);
+ g_async_queue_unlock (show->priv->results_q);
- return FALSE;
+ return FALSE;
}
static GdkPixbuf *
@@ -452,108 +452,109 @@ scale_pixbuf (GdkPixbuf *pixbuf,
int max_height,
gboolean no_stretch_hint)
{
- int pw;
- int ph;
- float scale_factor_x = 1.0;
- float scale_factor_y = 1.0;
- float scale_factor = 1.0;
-
- pw = gdk_pixbuf_get_width (pixbuf);
- ph = gdk_pixbuf_get_height (pixbuf);
-
- /* If the image is less than 256 wide or high then it
- is probably a thumbnail and we should ignore it */
- if (pw < 256 || ph < 256)
- {
- return NULL;
- }
-
- /* Determine which dimension requires the smallest scale. */
- scale_factor_x = (float) max_width / (float) pw;
- scale_factor_y = (float) max_height / (float) ph;
-
- if (scale_factor_x > scale_factor_y)
- {
- scale_factor = scale_factor_y;
- }
- else
- {
- scale_factor = scale_factor_x;
- }
-
- /* always scale down, allow to disable scaling up */
- if (scale_factor < 1.0 || !no_stretch_hint)
- {
- int scale_x;
- int scale_y;
-
- scale_x = (int) (pw * scale_factor);
- scale_y = (int) (ph * scale_factor);
- return gdk_pixbuf_scale_simple (pixbuf,
- scale_x,
- scale_y,
- GDK_INTERP_BILINEAR);
- }
- else
- {
- return g_object_ref (pixbuf);
- }
+ int pw;
+ int ph;
+ float scale_factor_x = 1.0;
+ float scale_factor_y = 1.0;
+ float scale_factor = 1.0;
+
+ pw = gdk_pixbuf_get_width (pixbuf);
+ ph = gdk_pixbuf_get_height (pixbuf);
+
+ /* If the image is less than 256 wide or high then it
+ is probably a thumbnail and we should ignore it */
+ if (pw < 256 || ph < 256)
+ {
+ return NULL;
+ }
+
+ /* Determine which dimension requires the smallest scale. */
+ scale_factor_x = (float) max_width / (float) pw;
+ scale_factor_y = (float) max_height / (float) ph;
+
+ if (scale_factor_x > scale_factor_y)
+ {
+ scale_factor = scale_factor_y;
+ }
+ else
+ {
+ scale_factor = scale_factor_x;
+ }
+
+ /* always scale down, allow to disable scaling up */
+ if (scale_factor < 1.0 || !no_stretch_hint)
+ {
+ int scale_x;
+ int scale_y;
+
+ scale_x = (int) (pw * scale_factor);
+ scale_y = (int) (ph * scale_factor);
+ return gdk_pixbuf_scale_simple (pixbuf,
+ scale_x,
+ scale_y,
+ GDK_INTERP_BILINEAR);
+ }
+ else
+ {
+ return g_object_ref (pixbuf);
+ }
}
static void
-add_files_to_list (GSList **list,
- const char *base)
+add_files_to_list (GSList **list,
+ const char *base)
{
- GDir *d;
- const char *d_name;
-
- d = g_dir_open (base, 0, NULL);
- if (d == NULL)
- {
- g_warning ("Could not open directory: %s", base);
- return;
- }
-
- while ((d_name = g_dir_read_name (d)) != NULL)
- {
- char *path;
-
- /* skip hidden files */
- if (d_name[0] == '.')
- {
- continue;
- }
-
- path = g_build_filename (base, d_name, NULL);
- if (g_file_test (path, G_FILE_TEST_IS_DIR))
- {
- add_files_to_list (list, path);
- g_free (path);
- }
- else
- {
- *list = g_slist_prepend (*list, path);
- }
- }
-
- g_dir_close (d);
+ GDir *d;
+ const char *d_name;
+
+ d = g_dir_open (base, 0, NULL);
+ if (d == NULL)
+ {
+ g_warning ("Could not open directory: %s", base);
+ return;
+ }
+
+ while ((d_name = g_dir_read_name (d)) != NULL)
+ {
+ char *path;
+
+ /* skip hidden files */
+ if (d_name[0] == '.')
+ {
+ continue;
+ }
+
+ path = g_build_filename (base, d_name, NULL);
+ if (g_file_test (path, G_FILE_TEST_IS_DIR))
+ {
+ add_files_to_list (list, path);
+ g_free (path);
+ }
+ else
+ {
+ *list = g_slist_prepend (*list, path);
+ }
+ }
+
+ g_dir_close (d);
}
static GSList *
build_filename_list_local_dir (const char *base)
{
- GSList *list = NULL;
+ GSList *list = NULL;
- add_files_to_list (&list, base);
+ add_files_to_list (&list, base);
- return list;
+ return list;
}
static int
-gste_strcmp_compare_func (gconstpointer string_a, gconstpointer string_b)
+gste_strcmp_compare_func (gconstpointer string_a,
+ gconstpointer string_b)
{
- return strcmp (string_a == NULL ? "" : string_a,
- string_b == NULL ? "" : string_b);
+ return strcmp (string_a == NULL ? "" : string_a,
+ string_b == NULL ? "" : string_b);
}
@@ -561,79 +562,79 @@ static GdkPixbuf *
get_pixbuf_from_local_dir (GSTESlideshow *show,
const char *location)
{
- GdkPixbuf *pixbuf, *transformed_pixbuf;
- char *filename;
- int i;
- GSList *l;
-
- /* rebuild the cache */
- if (show->priv->filename_list == NULL)
- {
- show->priv->filename_list = build_filename_list_local_dir (location);
- }
-
- if (show->priv->filename_list == NULL)
- {
- return NULL;
- }
- else
- {
- if (show->priv->sort_images)
- {
- show->priv->filename_list = g_slist_sort (show->priv->filename_list, gste_strcmp_compare_func);
- }
- }
-
- /* get a random filename if needed */
- if (! show->priv->sort_images)
- {
- i = g_random_int_range (0, g_slist_length (show->priv->filename_list));
- l = g_slist_nth (show->priv->filename_list, i);
- }
- else
- {
- l = show->priv->filename_list;
- }
- filename = l->data;
-
- pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
-
- if (pixbuf != NULL)
- {
- transformed_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
- g_object_unref (pixbuf);
- }
- else
- {
- transformed_pixbuf = NULL;
- }
-
- g_free (filename);
- show->priv->filename_list = g_slist_delete_link (show->priv->filename_list, l);
-
- return transformed_pixbuf;
+ GdkPixbuf *pixbuf, *transformed_pixbuf;
+ char *filename;
+ int i;
+ GSList *l;
+
+ /* rebuild the cache */
+ if (show->priv->filename_list == NULL)
+ {
+ show->priv->filename_list = build_filename_list_local_dir (location);
+ }
+
+ if (show->priv->filename_list == NULL)
+ {
+ return NULL;
+ }
+ else
+ {
+ if (show->priv->sort_images)
+ {
+ show->priv->filename_list = g_slist_sort (show->priv->filename_list, gste_strcmp_compare_func);
+ }
+ }
+
+ /* get a random filename if needed */
+ if (! show->priv->sort_images)
+ {
+ i = g_random_int_range (0, g_slist_length (show->priv->filename_list));
+ l = g_slist_nth (show->priv->filename_list, i);
+ }
+ else
+ {
+ l = show->priv->filename_list;
+ }
+ filename = l->data;
+
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+
+ if (pixbuf != NULL)
+ {
+ transformed_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
+ g_object_unref (pixbuf);
+ }
+ else
+ {
+ transformed_pixbuf = NULL;
+ }
+
+ g_free (filename);
+ show->priv->filename_list = g_slist_delete_link (show->priv->filename_list, l);
+
+ return transformed_pixbuf;
}
static GdkPixbuf *
get_pixbuf_from_location (GSTESlideshow *show,
const char *location)
{
- GdkPixbuf *pixbuf = NULL;
- gboolean is_dir;
+ GdkPixbuf *pixbuf = NULL;
+ gboolean is_dir;
- if (location == NULL)
- {
- return NULL;
- }
+ if (location == NULL)
+ {
+ return NULL;
+ }
- is_dir = g_file_test (location, G_FILE_TEST_IS_DIR);
+ is_dir = g_file_test (location, G_FILE_TEST_IS_DIR);
- if (is_dir)
- {
- pixbuf = get_pixbuf_from_local_dir (show, location);
- }
+ if (is_dir)
+ {
+ pixbuf = get_pixbuf_from_local_dir (show, location);
+ }
- return pixbuf;
+ return pixbuf;
}
static GdkPixbuf *
@@ -642,88 +643,88 @@ get_pixbuf (GSTESlideshow *show,
int width,
int height)
{
- GdkPixbuf *pixbuf;
- GdkPixbuf *scaled = NULL;
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled = NULL;
- if (location == NULL)
- {
- return NULL;
- }
+ if (location == NULL)
+ {
+ return NULL;
+ }
- pixbuf = get_pixbuf_from_location (show, location);
+ pixbuf = get_pixbuf_from_location (show, location);
- if (pixbuf != NULL)
- {
- scaled = scale_pixbuf (pixbuf, width, height, show->priv->no_stretch_hint);
- g_object_unref (pixbuf);
- }
+ if (pixbuf != NULL)
+ {
+ scaled = scale_pixbuf (pixbuf, width, height, show->priv->no_stretch_hint);
+ g_object_unref (pixbuf);
+ }
- return scaled;
+ return scaled;
}
static void
op_load_image (GSTESlideshow *show,
const char *location)
{
- OpResult *op_result;
- int window_width;
- int window_height;
+ OpResult *op_result;
+ int window_width;
+ int window_height;
- window_width = show->priv->window_width;
- window_height = show->priv->window_height;
+ window_width = show->priv->window_width;
+ window_height = show->priv->window_height;
- op_result = g_new0 (OpResult, 1);
+ op_result = g_new0 (OpResult, 1);
- op_result->pixbuf = get_pixbuf (show,
- location,
- window_width,
- window_height);
+ op_result->pixbuf = get_pixbuf (show,
+ location,
+ window_width,
+ window_height);
- g_async_queue_lock (show->priv->results_q);
- g_async_queue_push_unlocked (show->priv->results_q, op_result);
+ g_async_queue_lock (show->priv->results_q);
+ g_async_queue_push_unlocked (show->priv->results_q, op_result);
- if (show->priv->results_pull_id == 0)
- {
- show->priv->results_pull_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)results_pull_func,
- show, NULL);
- }
+ if (show->priv->results_pull_id == 0)
+ {
+ show->priv->results_pull_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
+ (GSourceFunc)results_pull_func,
+ show, NULL);
+ }
- g_async_queue_unlock (show->priv->results_q);
+ g_async_queue_unlock (show->priv->results_q);
}
static gpointer
load_threadfunc (GAsyncQueue *op_q)
{
- Op *op;
+ Op *op;
- op = g_async_queue_pop (op_q);
- while (op)
- {
- op_load_image (op->slideshow,
- op->location);
+ op = g_async_queue_pop (op_q);
+ while (op)
+ {
+ op_load_image (op->slideshow,
+ op->location);
- if (op->slideshow != NULL)
- {
- g_object_unref (op->slideshow);
- }
- g_free (op->location);
- g_free (op);
+ if (op->slideshow != NULL)
+ {
+ g_object_unref (op->slideshow);
+ }
+ g_free (op->location);
+ g_free (op);
- op = g_async_queue_pop (op_q);
- }
+ op = g_async_queue_pop (op_q);
+ }
- return NULL;
+ return NULL;
}
void
gste_slideshow_set_images_location (GSTESlideshow *show,
const char *location)
{
- g_return_if_fail (GSTE_IS_SLIDESHOW (show));
+ g_return_if_fail (GSTE_IS_SLIDESHOW (show));
- g_free (show->priv->images_location);
- show->priv->images_location = g_strdup (location);
+ g_free (show->priv->images_location);
+ show->priv->images_location = g_strdup (location);
}
@@ -731,42 +732,42 @@ void
gste_slideshow_set_sort_images (GSTESlideshow *show,
gboolean sort_images)
{
- g_return_if_fail (GSTE_IS_SLIDESHOW (show));
+ g_return_if_fail (GSTE_IS_SLIDESHOW (show));
- show->priv->sort_images = sort_images;
+ show->priv->sort_images = sort_images;
}
void
gste_slideshow_set_no_stretch_hint (GSTESlideshow *show,
gboolean no_stretch_hint)
{
- g_return_if_fail (GSTE_IS_SLIDESHOW (show));
+ g_return_if_fail (GSTE_IS_SLIDESHOW (show));
- show->priv->no_stretch_hint = no_stretch_hint;
+ show->priv->no_stretch_hint = no_stretch_hint;
}
void
gste_slideshow_set_background_color (GSTESlideshow *show,
const char *background_color)
{
- g_return_if_fail (GSTE_IS_SLIDESHOW (show));
-
- if (show->priv->background_color != NULL)
- {
- g_slice_free (PangoColor, show->priv->background_color);
- show->priv->background_color = NULL;
- }
-
- if (background_color != NULL)
- {
- show->priv->background_color = g_slice_new (PangoColor);
-
- if (pango_color_parse (show->priv->background_color, background_color) == FALSE)
- {
- g_slice_free (PangoColor, show->priv->background_color);
- show->priv->background_color = NULL;
- }
- }
+ g_return_if_fail (GSTE_IS_SLIDESHOW (show));
+
+ if (show->priv->background_color != NULL)
+ {
+ g_slice_free (PangoColor, show->priv->background_color);
+ show->priv->background_color = NULL;
+ }
+
+ if (background_color != NULL)
+ {
+ show->priv->background_color = g_slice_new (PangoColor);
+
+ if (pango_color_parse (show->priv->background_color, background_color) == FALSE)
+ {
+ g_slice_free (PangoColor, show->priv->background_color);
+ show->priv->background_color = NULL;
+ }
+ }
}
static void
@@ -775,280 +776,280 @@ gste_slideshow_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GSTESlideshow *self;
-
- self = GSTE_SLIDESHOW (object);
-
- switch (prop_id)
- {
- case PROP_IMAGES_LOCATION:
- gste_slideshow_set_images_location (self, g_value_get_string (value));
- break;
- case PROP_SORT_IMAGES:
- gste_slideshow_set_sort_images (self, g_value_get_boolean (value));
- break;
- case PROP_SOLID_BACKGROUND:
- gste_slideshow_set_background_color (self, g_value_get_string (value));
- break;
- case PROP_NO_STRETCH_HINT:
- gste_slideshow_set_no_stretch_hint (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSTESlideshow *self;
+
+ self = GSTE_SLIDESHOW (object);
+
+ switch (prop_id)
+ {
+ case PROP_IMAGES_LOCATION:
+ gste_slideshow_set_images_location (self, g_value_get_string (value));
+ break;
+ case PROP_SORT_IMAGES:
+ gste_slideshow_set_sort_images (self, g_value_get_boolean (value));
+ break;
+ case PROP_SOLID_BACKGROUND:
+ gste_slideshow_set_background_color (self, g_value_get_string (value));
+ break;
+ case PROP_NO_STRETCH_HINT:
+ gste_slideshow_set_no_stretch_hint (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gste_slideshow_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gste_slideshow_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GSTESlideshow *self;
-
- self = GSTE_SLIDESHOW (object);
-
- switch (prop_id)
- {
- case PROP_IMAGES_LOCATION:
- g_value_set_string (value, self->priv->images_location);
- break;
- case PROP_SORT_IMAGES:
- g_value_set_boolean (value, self->priv->sort_images);
- break;
- case PROP_SOLID_BACKGROUND:
- {
- char *color = NULL;
- color = pango_color_to_string (self->priv->background_color);
- g_value_set_string (value, color);
- g_free (color);
- break;
- }
- case PROP_NO_STRETCH_HINT:
- g_value_set_boolean (value, self->priv->no_stretch_hint);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GSTESlideshow *self;
+
+ self = GSTE_SLIDESHOW (object);
+
+ switch (prop_id)
+ {
+ case PROP_IMAGES_LOCATION:
+ g_value_set_string (value, self->priv->images_location);
+ break;
+ case PROP_SORT_IMAGES:
+ g_value_set_boolean (value, self->priv->sort_images);
+ break;
+ case PROP_SOLID_BACKGROUND:
+ {
+ char *color = NULL;
+ color = pango_color_to_string (self->priv->background_color);
+ g_value_set_string (value, color);
+ g_free (color);
+ break;
+ }
+ case PROP_NO_STRETCH_HINT:
+ g_value_set_boolean (value, self->priv->no_stretch_hint);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gste_slideshow_real_show (GtkWidget *widget)
{
- GSTESlideshow *show = GSTE_SLIDESHOW (widget);
- int delay;
+ GSTESlideshow *show = GSTE_SLIDESHOW (widget);
+ int delay;
- if (GTK_WIDGET_CLASS (parent_class)->show)
- {
- GTK_WIDGET_CLASS (parent_class)->show (widget);
- }
+ if (GTK_WIDGET_CLASS (parent_class)->show)
+ {
+ GTK_WIDGET_CLASS (parent_class)->show (widget);
+ }
- start_new_load (show, 10);
+ start_new_load (show, 10);
- delay = 25;
- show->priv->timeout_id = g_timeout_add (delay, (GSourceFunc)draw_iter, show);
+ delay = 25;
+ show->priv->timeout_id = g_timeout_add (delay, (GSourceFunc)draw_iter, show);
- if (show->priv->timer != NULL)
- {
- g_timer_destroy (show->priv->timer);
- }
- show->priv->timer = g_timer_new ();
+ if (show->priv->timer != NULL)
+ {
+ g_timer_destroy (show->priv->timer);
+ }
+ show->priv->timer = g_timer_new ();
}
static gboolean
gste_slideshow_real_draw (GtkWidget *widget,
cairo_t *cr)
{
- GSTESlideshow *show = GSTE_SLIDESHOW (widget);
+ GSTESlideshow *show = GSTE_SLIDESHOW (widget);
- if (GTK_WIDGET_CLASS (parent_class)->draw) {
- GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- }
+ if (GTK_WIDGET_CLASS (parent_class)->draw) {
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+ }
- cairo_set_source_surface (cr, show->priv->surf, 0, 0);
+ cairo_set_source_surface (cr, show->priv->surf, 0, 0);
- gs_theme_engine_profile_start ("paint surface to window");
- cairo_paint (cr);
- gs_theme_engine_profile_end ("paint surface to window");
+ gs_theme_engine_profile_start ("paint surface to window");
+ cairo_paint (cr);
+ gs_theme_engine_profile_end ("paint surface to window");
- return TRUE;
+ return TRUE;
}
static gboolean
gste_slideshow_real_configure (GtkWidget *widget,
GdkEventConfigure *event)
{
- GSTESlideshow *show = GSTE_SLIDESHOW (widget);
- gboolean handled = FALSE;
- cairo_t *cr;
-
- /* resize */
- gs_theme_engine_get_window_size (GS_THEME_ENGINE (show),
- &show->priv->window_width,
- &show->priv->window_height);
-
- gs_theme_engine_profile_msg ("Resize to x:%d y:%d",
- show->priv->window_width,
- show->priv->window_height);
-
- if (show->priv->surf != NULL)
- {
- cairo_surface_destroy (show->priv->surf);
- }
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.22 */
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- G_GNUC_END_IGNORE_DEPRECATIONS
- show->priv->surf = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR,
- show->priv->window_width,
- show->priv->window_height);
- cairo_destroy (cr);
-
- /* schedule a redraw */
- gtk_widget_queue_draw (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->configure_event)
- {
- handled = GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
- }
-
- return handled;
+ GSTESlideshow *show = GSTE_SLIDESHOW (widget);
+ gboolean handled = FALSE;
+ cairo_t *cr;
+
+ /* resize */
+ gs_theme_engine_get_window_size (GS_THEME_ENGINE (show),
+ &show->priv->window_width,
+ &show->priv->window_height);
+
+ gs_theme_engine_profile_msg ("Resize to x:%d y:%d",
+ show->priv->window_width,
+ show->priv->window_height);
+
+ if (show->priv->surf != NULL)
+ {
+ cairo_surface_destroy (show->priv->surf);
+ }
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* GTK 3.22 */
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ show->priv->surf = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR,
+ show->priv->window_width,
+ show->priv->window_height);
+ cairo_destroy (cr);
+
+ /* schedule a redraw */
+ gtk_widget_queue_draw (widget);
+
+ if (GTK_WIDGET_CLASS (parent_class)->configure_event)
+ {
+ handled = GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
+ }
+
+ return handled;
}
static void
gste_slideshow_class_init (GSTESlideshowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = gste_slideshow_finalize;
- object_class->get_property = gste_slideshow_get_property;
- object_class->set_property = gste_slideshow_set_property;
-
- widget_class->show = gste_slideshow_real_show;
- widget_class->draw = gste_slideshow_real_draw;
- widget_class->configure_event = gste_slideshow_real_configure;
-
- g_object_class_install_property (object_class,
- PROP_IMAGES_LOCATION,
- g_param_spec_string ("images-location",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SORT_IMAGES,
- g_param_spec_boolean ("sort-images",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SOLID_BACKGROUND,
- g_param_spec_string ("background-color",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_NO_STRETCH_HINT,
- g_param_spec_boolean ("no-stretch",
- NULL,
- NULL,
- FALSE,
- G_PARAM_READWRITE));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = gste_slideshow_finalize;
+ object_class->get_property = gste_slideshow_get_property;
+ object_class->set_property = gste_slideshow_set_property;
+
+ widget_class->show = gste_slideshow_real_show;
+ widget_class->draw = gste_slideshow_real_draw;
+ widget_class->configure_event = gste_slideshow_real_configure;
+
+ g_object_class_install_property (object_class,
+ PROP_IMAGES_LOCATION,
+ g_param_spec_string ("images-location",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SORT_IMAGES,
+ g_param_spec_boolean ("sort-images",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SOLID_BACKGROUND,
+ g_param_spec_string ("background-color",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_NO_STRETCH_HINT,
+ g_param_spec_boolean ("no-stretch",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
}
static void
set_visual (GtkWidget *widget)
{
- GdkScreen *screen;
- GdkVisual *visual;
+ GdkScreen *screen;
+ GdkVisual *visual;
- screen = gtk_widget_get_screen (widget);
- visual = gdk_screen_get_rgba_visual (screen);
- if (visual == NULL)
- {
- visual = gdk_screen_get_system_visual (screen);
- }
+ screen = gtk_widget_get_screen (widget);
+ visual = gdk_screen_get_rgba_visual (screen);
+ if (visual == NULL)
+ {
+ visual = gdk_screen_get_system_visual (screen);
+ }
- gtk_widget_set_visual (widget, visual);
+ gtk_widget_set_visual (widget, visual);
}
static void
gste_slideshow_init (GSTESlideshow *show)
{
- show->priv = gste_slideshow_get_instance_private (show);
+ show->priv = gste_slideshow_get_instance_private (show);
- show->priv->images_location = g_strdup (DEFAULT_IMAGES_LOCATION);
+ show->priv->images_location = g_strdup (DEFAULT_IMAGES_LOCATION);
- show->priv->op_q = g_async_queue_new ();
- show->priv->results_q = g_async_queue_new ();
+ show->priv->op_q = g_async_queue_new ();
+ show->priv->results_q = g_async_queue_new ();
- g_thread_new ("loadthread", (GThreadFunc)load_threadfunc, show->priv->op_q);
+ g_thread_new ("loadthread", (GThreadFunc)load_threadfunc, show->priv->op_q);
- set_visual (GTK_WIDGET (show));
+ set_visual (GTK_WIDGET (show));
}
static void
gste_slideshow_finalize (GObject *object)
{
- GSTESlideshow *show;
- gpointer result;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GSTE_IS_SLIDESHOW (object));
-
- show = GSTE_SLIDESHOW (object);
-
- g_return_if_fail (show->priv != NULL);
-
- if (show->priv->surf)
- {
- cairo_surface_destroy (show->priv->surf);
- }
-
- if (show->priv->timeout_id > 0)
- {
- g_source_remove (show->priv->timeout_id);
- show->priv->timeout_id = 0;
- }
-
- if (show->priv->results_pull_id > 0)
- {
- g_source_remove (show->priv->results_pull_id);
- show->priv->results_pull_id = 0;
- }
-
- if (show->priv->results_q != NULL)
- {
- result = g_async_queue_try_pop (show->priv->results_q);
-
- while (result)
- {
- result = g_async_queue_try_pop (show->priv->results_q);
- }
- g_async_queue_unref (show->priv->results_q);
- }
-
- g_free (show->priv->images_location);
- show->priv->images_location = NULL;
-
- if (show->priv->background_color)
- {
- g_slice_free (PangoColor, show->priv->background_color);
- show->priv->background_color = NULL;
- }
-
- if (show->priv->timer != NULL)
- {
- g_timer_destroy (show->priv->timer);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ GSTESlideshow *show;
+ gpointer result;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GSTE_IS_SLIDESHOW (object));
+
+ show = GSTE_SLIDESHOW (object);
+
+ g_return_if_fail (show->priv != NULL);
+
+ if (show->priv->surf)
+ {
+ cairo_surface_destroy (show->priv->surf);
+ }
+
+ if (show->priv->timeout_id > 0)
+ {
+ g_source_remove (show->priv->timeout_id);
+ show->priv->timeout_id = 0;
+ }
+
+ if (show->priv->results_pull_id > 0)
+ {
+ g_source_remove (show->priv->results_pull_id);
+ show->priv->results_pull_id = 0;
+ }
+
+ if (show->priv->results_q != NULL)
+ {
+ result = g_async_queue_try_pop (show->priv->results_q);
+
+ while (result)
+ {
+ result = g_async_queue_try_pop (show->priv->results_q);
+ }
+ g_async_queue_unref (show->priv->results_q);
+ }
+
+ g_free (show->priv->images_location);
+ show->priv->images_location = NULL;
+
+ if (show->priv->background_color)
+ {
+ g_slice_free (PangoColor, show->priv->background_color);
+ show->priv->background_color = NULL;
+ }
+
+ if (show->priv->timer != NULL)
+ {
+ g_timer_destroy (show->priv->timer);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/savers/gste-slideshow.h b/savers/gste-slideshow.h
index e3e1042..5b330b0 100644
--- a/savers/gste-slideshow.h
+++ b/savers/gste-slideshow.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -40,29 +40,29 @@ typedef struct GSTESlideshowPrivate GSTESlideshowPrivate;
typedef struct
{
- GSThemeEngine parent;
- GSTESlideshowPrivate *priv;
+ GSThemeEngine parent;
+ GSTESlideshowPrivate *priv;
} GSTESlideshow;
typedef struct
{
- GSThemeEngineClass parent_class;
+ GSThemeEngineClass parent_class;
} GSTESlideshowClass;
GType gste_slideshow_get_type (void);
GSThemeEngine *gste_slideshow_new (void);
void gste_slideshow_set_images_location (GSTESlideshow *show,
- const char *location);
+ const char *location);
void gste_slideshow_set_sort_images (GSTESlideshow *show,
- gboolean sort_image);
+ gboolean sort_image);
void gste_slideshow_set_background_color (GSTESlideshow *show,
- const char *background_color);
+ const char *background_color);
void gste_slideshow_set_no_stretch_hint (GSTESlideshow *show,
- gboolean no_stretch_hint);
+ gboolean no_stretch_hint);
G_END_DECLS
diff --git a/savers/popsquares.c b/savers/popsquares.c
index 0a5c2dc..b62c6e5 100644
--- a/savers/popsquares.c
+++ b/savers/popsquares.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -32,41 +32,42 @@
#include "gste-popsquares.h"
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
- GSThemeEngine *engine;
- GtkWidget *window;
- GError *error;
+ GSThemeEngine *engine;
+ GtkWidget *window;
+ GError *error;
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- error = NULL;
+ error = NULL;
- if (!gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
- {
- g_printerr (_("%s. See --help for usage information.\n"),
- error->message);
- g_error_free (error);
- exit (1);
- }
+ if (!gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error))
+ {
+ g_printerr (_("%s. See --help for usage information.\n"),
+ error->message);
+ g_error_free (error);
+ exit (1);
+ }
- window = gs_theme_window_new ();
- g_signal_connect (G_OBJECT (window), "delete-event",
- G_CALLBACK (gtk_main_quit), NULL);
+ window = gs_theme_window_new ();
+ g_signal_connect (G_OBJECT (window), "delete-event",
+ G_CALLBACK (gtk_main_quit), NULL);
- g_set_prgname ("popsquares");
+ g_set_prgname ("popsquares");
- engine = g_object_new (GSTE_TYPE_POPSQUARES, NULL);
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (engine));
+ engine = g_object_new (GSTE_TYPE_POPSQUARES, NULL);
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (engine));
- gtk_widget_show (GTK_WIDGET (engine));
+ gtk_widget_show (GTK_WIDGET (engine));
- gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
- gtk_widget_show (window);
+ gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
+ gtk_widget_show (window);
- gtk_main ();
+ gtk_main ();
- return 0;
+ return 0;
}
diff --git a/savers/slideshow.c b/savers/slideshow.c
index c4ab745..93da2f0 100644
--- a/savers/slideshow.c
+++ b/savers/slideshow.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (C) 2005 William Jon McCann <mccann at jhu.edu>
*
@@ -40,103 +40,103 @@
int
main (int argc, char **argv)
{
- GSThemeEngine *engine;
- GtkWidget *window;
- GError *error;
- gboolean ret;
- char *location = NULL;
- char *background_color = NULL;
- gboolean sort_images = FALSE;
- gboolean no_stretch = FALSE;
- GOptionEntry entries [] =
- {
- {
- "location", 0, 0, G_OPTION_ARG_STRING, &location,
- N_("Location to get images from"), N_("PATH")
- },
- {
- "background-color", 0, 0, G_OPTION_ARG_STRING, &background_color,
- N_("Color to use for images background"), N_("\"#rrggbb\"")
- },
- {
- "sort-images", 0, 0, G_OPTION_ARG_NONE, &sort_images,
- N_("Do not randomize pictures from location"), NULL
- },
- {
- "no-stretch", 0, 0, G_OPTION_ARG_NONE, &no_stretch,
- N_("Do not try to stretch images on screen"), NULL
- },
- { NULL }
- };
-
- bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-
- error = NULL;
-
- ret = gtk_init_with_args (&argc, &argv,
- NULL,
- entries,
- NULL,
- &error);
- if (! ret)
- {
- g_message ("%s", error->message);
- g_error_free (error);
- exit (1);
- }
-
- g_chdir (g_get_home_dir ());
-
- g_set_prgname ("slideshow");
-
- window = gs_theme_window_new ();
- g_signal_connect (G_OBJECT (window), "delete-event",
- G_CALLBACK (gtk_main_quit), NULL);
-
- engine = g_object_new (GSTE_TYPE_SLIDESHOW, NULL);
-
- if (location == NULL)
- {
- location = xdg_user_dir_lookup ("PICTURES");
- if (location == NULL ||
- strcmp (location, "/tmp") == 0 ||
- strcmp (location, g_get_home_dir ()) == 0)
- {
- free (location);
- location = g_build_filename (g_get_home_dir (), "Pictures", NULL);
- }
- }
-
- if (location != NULL)
- {
- g_object_set (engine, "images-location", location, NULL);
- }
-
- if (sort_images)
- {
- g_object_set (engine, "sort-images", sort_images, NULL);
- }
-
- if (background_color != NULL)
- {
- g_object_set (engine, "background-color", background_color, NULL);
- }
-
- if (no_stretch)
- {
- g_object_set (engine, "no-stretch", no_stretch, NULL);
- }
-
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (engine));
-
- gtk_widget_show (GTK_WIDGET (engine));
-
- gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
- gtk_widget_show (window);
-
- gtk_main ();
-
- return 0;
+ GSThemeEngine *engine;
+ GtkWidget *window;
+ GError *error;
+ gboolean ret;
+ char *location = NULL;
+ char *background_color = NULL;
+ gboolean sort_images = FALSE;
+ gboolean no_stretch = FALSE;
+ GOptionEntry entries [] =
+ {
+ {
+ "location", 0, 0, G_OPTION_ARG_STRING, &location,
+ N_("Location to get images from"), N_("PATH")
+ },
+ {
+ "background-color", 0, 0, G_OPTION_ARG_STRING, &background_color,
+ N_("Color to use for images background"), N_("\"#rrggbb\"")
+ },
+ {
+ "sort-images", 0, 0, G_OPTION_ARG_NONE, &sort_images,
+ N_("Do not randomize pictures from location"), NULL
+ },
+ {
+ "no-stretch", 0, 0, G_OPTION_ARG_NONE, &no_stretch,
+ N_("Do not try to stretch images on screen"), NULL
+ },
+ { NULL }
+ };
+
+ bindtextdomain (GETTEXT_PACKAGE, XFCELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ error = NULL;
+
+ ret = gtk_init_with_args (&argc, &argv,
+ NULL,
+ entries,
+ NULL,
+ &error);
+ if (! ret)
+ {
+ g_message ("%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ g_chdir (g_get_home_dir ());
+
+ g_set_prgname ("slideshow");
+
+ window = gs_theme_window_new ();
+ g_signal_connect (G_OBJECT (window), "delete-event",
+ G_CALLBACK (gtk_main_quit), NULL);
+
+ engine = g_object_new (GSTE_TYPE_SLIDESHOW, NULL);
+
+ if (location == NULL)
+ {
+ location = xdg_user_dir_lookup ("PICTURES");
+ if (location == NULL ||
+ strcmp (location, "/tmp") == 0 ||
+ strcmp (location, g_get_home_dir ()) == 0)
+ {
+ free (location);
+ location = g_build_filename (g_get_home_dir (), "Pictures", NULL);
+ }
+ }
+
+ if (location != NULL)
+ {
+ g_object_set (engine, "images-location", location, NULL);
+ }
+
+ if (sort_images)
+ {
+ g_object_set (engine, "sort-images", sort_images, NULL);
+ }
+
+ if (background_color != NULL)
+ {
+ g_object_set (engine, "background-color", background_color, NULL);
+ }
+
+ if (no_stretch)
+ {
+ g_object_set (engine, "no-stretch", no_stretch, NULL);
+ }
+
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (engine));
+
+ gtk_widget_show (GTK_WIDGET (engine));
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
}
diff --git a/savers/xdg-user-dir-lookup.c b/savers/xdg-user-dir-lookup.c
index c9e8fe2..6ac1d5c 100644
--- a/savers/xdg-user-dir-lookup.c
+++ b/savers/xdg-user-dir-lookup.c
@@ -34,120 +34,120 @@
char *
xdg_user_dir_lookup (const char *type)
{
- FILE *file;
- char *home_dir, *config_home, *config_file;
- char buffer[512];
- char *user_dir;
- char *p, *d;
- int len;
- int relative;
-
- home_dir = getenv ("HOME");
-
- if (home_dir == NULL)
- return strdup ("/tmp");
-
- config_home = getenv ("XDG_CONFIG_HOME");
- if (config_home == NULL || config_home[0] == 0)
- {
- config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
- strcpy (config_file, home_dir);
- strcat (config_file, "/.config/user-dirs.dirs");
- }
- else
- {
- config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
- strcpy (config_file, config_home);
- strcat (config_file, "/user-dirs.dirs");
- }
-
- file = fopen (config_file, "r");
- free (config_file);
- if (file == NULL)
- goto error;
-
- user_dir = NULL;
- while (fgets (buffer, sizeof (buffer), file))
- {
- /* Remove newline at end */
- len = strlen (buffer);
- if (len > 0 && buffer[len-1] == '\n')
- buffer[len-1] = 0;
-
- p = buffer;
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (strncmp (p, "XDG_", 4) != 0)
- continue;
- p += 4;
- if (strncmp (p, type, strlen (type)) != 0)
- continue;
- p += strlen (type);
- if (strncmp (p, "_DIR", 4) != 0)
- continue;
- p += 4;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '=')
- continue;
- p++;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '"')
- continue;
- p++;
-
- relative = 0;
- if (strncmp (p, "$HOME/", 6) == 0)
- {
- p += 6;
- relative = 1;
- }
- else if (*p != '/')
- continue;
-
- if (relative)
- {
- user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
- strcpy (user_dir, home_dir);
- strcat (user_dir, "/");
- }
- else
- {
- user_dir = malloc (strlen (p) + 1);
- *user_dir = 0;
- }
-
- d = user_dir + strlen (user_dir);
- while (*p && *p != '"')
- {
- if ((*p == '\\') && (*(p+1) != 0))
- p++;
- *d++ = *p++;
- }
- *d = 0;
- }
- fclose (file);
-
- if (user_dir)
- return user_dir;
+ FILE *file;
+ char *home_dir, *config_home, *config_file;
+ char buffer[512];
+ char *user_dir;
+ char *p, *d;
+ int len;
+ int relative;
+
+ home_dir = getenv ("HOME");
+
+ if (home_dir == NULL)
+ return strdup ("/tmp");
+
+ config_home = getenv ("XDG_CONFIG_HOME");
+ if (config_home == NULL || config_home[0] == 0)
+ {
+ config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
+ strcpy (config_file, home_dir);
+ strcat (config_file, "/.config/user-dirs.dirs");
+ }
+ else
+ {
+ config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
+ strcpy (config_file, config_home);
+ strcat (config_file, "/user-dirs.dirs");
+ }
+
+ file = fopen (config_file, "r");
+ free (config_file);
+ if (file == NULL)
+ goto error;
+
+ user_dir = NULL;
+ while (fgets (buffer, sizeof (buffer), file))
+ {
+ /* Remove newline at end */
+ len = strlen (buffer);
+ if (len > 0 && buffer[len-1] == '\n')
+ buffer[len-1] = 0;
+
+ p = buffer;
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (strncmp (p, "XDG_", 4) != 0)
+ continue;
+ p += 4;
+ if (strncmp (p, type, strlen (type)) != 0)
+ continue;
+ p += strlen (type);
+ if (strncmp (p, "_DIR", 4) != 0)
+ continue;
+ p += 4;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p != '=')
+ continue;
+ p++;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p != '"')
+ continue;
+ p++;
+
+ relative = 0;
+ if (strncmp (p, "$HOME/", 6) == 0)
+ {
+ p += 6;
+ relative = 1;
+ }
+ else if (*p != '/')
+ continue;
+
+ if (relative)
+ {
+ user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
+ strcpy (user_dir, home_dir);
+ strcat (user_dir, "/");
+ }
+ else
+ {
+ user_dir = malloc (strlen (p) + 1);
+ *user_dir = 0;
+ }
+
+ d = user_dir + strlen (user_dir);
+ while (*p && *p != '"')
+ {
+ if ((*p == '\\') && (*(p+1) != 0))
+ p++;
+ *d++ = *p++;
+ }
+ *d = 0;
+ }
+ fclose (file);
+
+ if (user_dir)
+ return user_dir;
error:
- /* Special case desktop for historical compatibility */
- if (strcmp (type, "DESKTOP") == 0)
- {
- user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
- strcpy (user_dir, home_dir);
- strcat (user_dir, "/Desktop");
- return user_dir;
- }
- else
- return strdup (home_dir);
+ /* Special case desktop for historical compatibility */
+ if (strcmp (type, "DESKTOP") == 0)
+ {
+ user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
+ strcpy (user_dir, home_dir);
+ strcat (user_dir, "/Desktop");
+ return user_dir;
+ }
+ else
+ return strdup (home_dir);
}
#ifdef STANDALONE
@@ -155,14 +155,14 @@ error:
int
main (int argc, char *argv[])
{
- if (argc != 2)
- {
- fprintf (stderr, "Usage %s <dir-type>\n", argv[0]);
- exit (1);
- }
-
- printf ("%s\n", xdg_user_dir_lookup (argv[1]));
- return 0;
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage %s <dir-type>\n", argv[0]);
+ exit (1);
+ }
+
+ printf ("%s\n", xdg_user_dir_lookup (argv[1]));
+ return 0;
}
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list