Commit 6814927c authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

[slideshow] use a simple slideshow if clutter is not available

If clutter is not available or the clutter initialization fails
use a simple slideshow with no transitions based on gth_image_viewer,
instead of disabling the slideshow feature altogether.
parent b3f5f2d5
if ENABLE_CLUTTER
SUBDIRS = data
extensiondir = $(pkglibdir)/extensions
......@@ -32,8 +30,6 @@ extensioninidir = $(extensiondir)
extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
DISTCLEANFILES = $(extensionini_DATA)
endif
extensionini_in_files = slideshow.extension.in.in
%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
......
......@@ -33,12 +33,13 @@ void
gth_browser_activate_action_view_slideshow (GtkAction *action,
GthBrowser *browser)
{
GList *items;
GList *file_list;
GtkWidget *slideshow;
GthFileData *location;
char *transition_id;
GList *transitions = NULL;
GList *items;
GList *file_list;
GthProjector *projector;
GtkWidget *slideshow;
GthFileData *location;
char *transition_id;
GList *transitions = NULL;
items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
if ((items == NULL) || (items->next == NULL))
......@@ -46,10 +47,18 @@ gth_browser_activate_action_view_slideshow (GtkAction *action,
else
file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
slideshow = gth_slideshow_new (browser, file_list);
projector = NULL;
#ifdef HAVE_CLUTTER
if (ClutterInitResult == CLUTTER_INIT_SUCCESS)
projector = &clutter_projector;
#endif /* HAVE_CLUTTER */
if (projector == NULL)
projector = &default_projector;
slideshow = gth_slideshow_new (projector, browser, file_list);
location = gth_browser_get_location_data (browser);
if (g_file_info_get_attribute_status (location->info, "slideshow::personalize") == G_FILE_ATTRIBUTE_STATUS_SET) {
if (g_file_info_get_attribute_boolean (location->info, "slideshow::personalize")) {
gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_int32 (location->info, "slideshow::delay"));
gth_slideshow_set_automatic (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_boolean (location->info, "slideshow::automatic"));
gth_slideshow_set_wrap_around (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_boolean (location->info, "slideshow::wrap-around"));
......
......@@ -382,6 +382,10 @@ ss__dlg_catalog_properties (GtkBuilder *builder,
gtk_widget_show (gth_slideshow_preferences_get_widget (GTH_SLIDESHOW_PREFERENCES (slideshow_preferences), "playlist_box"));
gtk_widget_show (slideshow_preferences);
#ifndef HAVE_CLUTTER
gtk_widget_hide (gth_slideshow_preferences_get_widget (GTH_SLIDESHOW_PREFERENCES (slideshow_preferences), "transition_box"));
#endif /* ! HAVE_CLUTTER */
label = gtk_label_new (_("Slideshow"));
gtk_widget_show (label);
......
This diff is collapsed.
......@@ -24,8 +24,10 @@
#define GTH_SLIDESHOW_H
#include <gthumb.h>
#ifdef HAVE_CLUTTER
#include <clutter/clutter.h>
#include <clutter-gtk/clutter-gtk.h>
#endif /* HAVE_CLUTTER */
G_BEGIN_DECLS
......@@ -43,12 +45,14 @@ typedef struct _GthSlideshowPrivate GthSlideshowPrivate;
struct _GthSlideshow
{
GtkWindow __parent;
#ifdef HAVE_CLUTTER
ClutterActor *stage;
ClutterActor *current_image;
ClutterActor *next_image;
ClutterGeometry current_geometry;
ClutterGeometry next_geometry;
gboolean first_frame;
#endif /* HAVE_CLUTTER */
GthSlideshowPrivate *priv;
};
......@@ -57,19 +61,36 @@ struct _GthSlideshowClass
GtkWindowClass __parent_class;
};
typedef struct {
void (* construct) (GthSlideshow *self);
void (* paused) (GthSlideshow *self);
void (* hide_cursor) (GthSlideshow *self);
void (* finalize) (GthSlideshow *self);
void (* image_ready) (GthSlideshow *self,
GdkPixbuf *pixbuf);
void (* load_prev_image) (GthSlideshow *self);
void (* load_next_image) (GthSlideshow *self);
} GthProjector;
extern GthProjector default_projector;
#ifdef HAVE_CLUTTER
extern GthProjector clutter_projector;
#endif /* HAVE_CLUTTER */
GType gth_slideshow_get_type (void);
GtkWidget * gth_slideshow_new (GthBrowser *browser,
GList *file_list /* GthFileData */);
void gth_slideshow_set_delay (GthSlideshow *self,
guint msecs);
void gth_slideshow_set_automatic (GthSlideshow *self,
gboolean automatic);
void gth_slideshow_set_wrap_around (GthSlideshow *self,
gboolean wrap_around);
void gth_slideshow_set_transitions (GthSlideshow *self,
GList *transitions);
void gth_slideshow_set_playlist (GthSlideshow *self,
char **files);
GtkWidget * gth_slideshow_new (GthProjector *projector,
GthBrowser *browser,
GList *file_list /* GthFileData */);
void gth_slideshow_set_delay (GthSlideshow *self,
guint msecs);
void gth_slideshow_set_automatic (GthSlideshow *self,
gboolean automatic);
void gth_slideshow_set_wrap_around (GthSlideshow *self,
gboolean wrap_around);
void gth_slideshow_set_transitions (GthSlideshow *self,
GList *transitions);
void gth_slideshow_set_playlist (GthSlideshow *self,
char **files);
G_END_DECLS
......
......@@ -34,9 +34,9 @@ enum {
struct _GthTransitionPrivate {
char *id;
char *display_name;
FrameFunc frame_func;
char *id;
char *display_name;
FrameFunc frame_func;
};
......
......@@ -24,8 +24,6 @@
#define GTH_TRANSITION_H
#include <glib-object.h>
#include <clutter/clutter.h>
#include <clutter-gtk/clutter-gtk.h>
#include "gth-slideshow.h"
G_BEGIN_DECLS
......@@ -47,13 +45,13 @@ typedef void (*FrameFunc) (GthSlideshow *slideshow, int msecs);
struct _GthTransition
{
GtkWindow __parent;
GObject __parent;
GthTransitionPrivate *priv;
};
struct _GthTransitionClass
{
GtkWindowClass __parent_class;
GObjectClass __parent_class;
};
GType gth_transition_get_type (void);
......
......@@ -29,6 +29,8 @@
#include "preferences.h"
#ifdef HAVE_CLUTTER
#define VALUE_AT_MSECS(v, t)(((double) (v) * ((double) (t) / GTH_TRANSITION_DURATION)))
......@@ -264,12 +266,13 @@ cube_from_bottom_transition (GthSlideshow *self,
}
#endif /* HAVE_CLUTTER */
G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
if (ClutterInitResult != CLUTTER_INIT_SUCCESS)
return;
#ifdef HAVE_CLUTTER
gth_main_register_object (GTH_TYPE_TRANSITION,
"none",
GTH_TYPE_TRANSITION,
......@@ -324,6 +327,7 @@ gthumb_extension_activate (void)
"display-name", _("Cube from bottom"),
"frame-func", cube_from_bottom_transition,
NULL);
#endif /* HAVE_CLUTTER */
gth_hook_add_callback ("slideshow", 10, G_CALLBACK (ss__slideshow_cb), NULL);
gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (ss__gth_browser_construct_cb), NULL);
......
......@@ -102,6 +102,10 @@ ss__dlg_preferences_construct_cb (GtkWidget *dialog,
gtk_widget_show (data->preferences_page);
g_free (current_transition);
#ifndef HAVE_CLUTTER
gtk_widget_hide (gth_slideshow_preferences_get_widget (GTH_SLIDESHOW_PREFERENCES (data->preferences_page), "transition_box"));
#endif /* ! HAVE_CLUTTER */
g_signal_connect (gth_slideshow_preferences_get_widget (GTH_SLIDESHOW_PREFERENCES (data->preferences_page), "transition_combobox"),
"changed",
G_CALLBACK (transition_combobox_changed_cb),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment