Commit 66d69e4d authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

Added slideshow options to catalogs

Added ability to specify a list of audio files to play during a
slideshow, and to personalize the slidehoshow options for each
catalog.
parent 5ec11e08
......@@ -177,7 +177,8 @@ if test x$enable_gstreamer = xyes ; then
PKG_CHECK_MODULES(GSTREAMER,
[gstreamer-0.10 >= $GSTREAMER_REQUIRED
gstreamer-interfaces-0.10],
[enable_gstreamer=yes],
[AC_DEFINE(HAVE_GSTREAMER, 1, [Have gstreamer])
enable_gstreamer=yes],
[enable_gstreamer=no])
fi
AC_SUBST(GSTREAMER_LIBS)
......
......@@ -5,7 +5,6 @@
<object class="GtkDialog" id="properties_dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Properties</property>
<property name="resizable">False</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
......@@ -20,103 +19,142 @@
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="vbox1">
<object class="GtkNotebook" id="properties_notebook">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Catalog</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<property name="can_focus">True</property>
<child>
<object class="GtkAlignment" id="alignment2">
<object class="GtkVBox" id="general_vbox">
<property name="visible">True</property>
<property name="left_padding">12</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkTable" id="table1">
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">name_entry</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Date:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
<property name="label" translatable="yes">General</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="date_container_box">
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<placeholder/>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">name_entry</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Date:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="date_container_box">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Catalog</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
......
......@@ -240,6 +240,7 @@ dlg_catalog_properties (GthBrowser *browser,
/* run dialog. */
gtk_widget_grab_focus (GET_WIDGET ("name_entry"));
gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser));
gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
......
......@@ -53,6 +53,8 @@ gth_catalog_finalize (GObject *object)
{
GthCatalog *catalog = GTH_CATALOG (object);
g_value_hash_unref (catalog->attributes);
if (catalog->priv != NULL) {
if (catalog->priv->file != NULL)
g_object_unref (catalog->priv->file);
......@@ -80,7 +82,7 @@ base_create_root (GthCatalog *catalog,
static void
base_read_from_doc (GthCatalog *catalog,
base_read_from_doc (GthCatalog *catalog,
DomElement *root)
{
GList *file_list;
......@@ -111,6 +113,9 @@ base_read_from_doc (GthCatalog *catalog,
}
gth_catalog_set_file_list (catalog, file_list);
/* FIXME */
gth_hook_invoke ("gth-catalog-read-from-doc", catalog, root);
_g_object_list_unref (file_list);
}
......@@ -219,6 +224,9 @@ base_write_to_doc (GthCatalog *catalog,
g_free (uri);
}
}
/* FIXME */
gth_hook_invoke ("gth-catalog-write-to-doc", catalog, doc, root);
}
......@@ -241,6 +249,7 @@ gth_catalog_class_init (GthCatalogClass *class)
static void
gth_catalog_init (GthCatalog *catalog)
{
catalog->attributes = g_value_hash_new ();
catalog->priv = g_new0 (GthCatalogPrivate, 1);
catalog->priv->date_time = gth_datetime_new ();
catalog->priv->file_hash = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, NULL, NULL);
......@@ -764,6 +773,9 @@ gth_catalog_update_metadata (GthCatalog *catalog,
file_data->info,
catalog->priv->name,
catalog->priv->date_time);
/* FIXME */
gth_hook_invoke ("gth-catalog-write-metadata", catalog, file_data);
}
......
......@@ -48,6 +48,7 @@ typedef struct _GthCatalogClass GthCatalogClass;
struct _GthCatalog
{
GObject __parent;
GValueHash *attributes;
GthCatalogPrivate *priv;
};
......
......@@ -245,6 +245,9 @@ write_metadata_load_buffer_ready_cb (void **buffer,
g_file_info_get_attribute_string (metadata_op->file_data->info, "sort::type"),
g_file_info_get_attribute_boolean (metadata_op->file_data->info, "sort::inverse"));
/* FIXME */
gth_hook_invoke ("gth-catalog-read-metadata", metadata_op->catalog, metadata_op->file_data);
catalog_buffer = gth_catalog_to_data (metadata_op->catalog, &catalog_size);
gio_file = gth_catalog_file_to_gio_file (metadata_op->file_data->file);
g_write_file_async (gio_file,
......@@ -356,6 +359,7 @@ read_metadata_info_ready_cb (GList *files,
{
ReadMetadataOpData *read_metadata = user_data;
GthFileData *result;
GFile *gio_file;
if (error != NULL) {
read_metadata->callback (G_OBJECT (read_metadata->file_source), error, read_metadata->data);
......@@ -365,28 +369,15 @@ read_metadata_info_ready_cb (GList *files,
result = files->data;
g_file_info_copy_into (result->info, read_metadata->file_data->info);
update_file_info (read_metadata->file_source, read_metadata->file_data->file, read_metadata->file_data->info);
if (_g_file_attributes_matches_any (read_metadata->attributes,
"sort::*,"
"general::event-date,"
"standard::display-name,standard::sort-order"))
{
GFile *gio_file;
gio_file = gth_catalog_file_to_gio_file (read_metadata->file_data->file);
gth_catalog_load_from_file_async (gio_file,
gth_file_source_get_cancellable (read_metadata->file_source),
read_metadata_catalog_ready_cb,
read_metadata);
gio_file = gth_catalog_file_to_gio_file (read_metadata->file_data->file);
gth_catalog_load_from_file_async (gio_file,
gth_file_source_get_cancellable (read_metadata->file_source),
read_metadata_catalog_ready_cb,
read_metadata);
g_object_unref (gio_file);
}
else {
read_metadata->callback (G_OBJECT (read_metadata->file_source), NULL, read_metadata->data);
read_metadata_free (read_metadata);
}
g_object_unref (gio_file);
}
......
......@@ -32,14 +32,47 @@ G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
/**
* Called to create the catalog class from the given file data.
* Called to create the catalog class from the given file content.
*
* @buffer (const char *): the file data.
* @buffer (const char *): the file content.
* @return (GthCatalog *): return a pointer to the object that can
* handle the catalog data, or NULL if the data type doesn't match.
**/
gth_hook_register ("gth-catalog-load-from-data", 1);
/**
* Called to update the catalog data from a given file data.
*
* @catalog (GthCatalog *): the catalog to update
* @file_data (GthFileData *): the file data
**/
gth_hook_register ("gth-catalog-read-metadata", 2);
/**
* Called to update the file metadata from a catalog.
*
* @catalog (GthCatalog *): the catalog
* @file_data (GthFileData *): the file data to update
**/
gth_hook_register ("gth-catalog-write-metadata", 2);
/**
* Called to update the catalog from a xml file.
*
* @catalog (GthCatalog *):
* @root (DomElement *):
*/
gth_hook_register ("gth-catalog-read-from-doc", 2);
/**
* Called to update a xml file from a catalog.
*
* @catalog (GthCatalog *):
* @doc (DomDocument *):
* @root (DomElement *):
*/
gth_hook_register ("gth-catalog-write-to-doc", 3);
/**
* Called to add sections to the catalog properties dialog.
*
......
......@@ -169,8 +169,9 @@ search__dlg_catalog_properties (GtkBuilder *builder,
vbox = gtk_vbox_new (FALSE, 6);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (_gtk_builder_get_widget (builder, "main_vbox")), vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (_gtk_builder_get_widget (builder, "general_vbox")), vbox, FALSE, FALSE, 0);
/* Translators: This is not a verb, it's a name as in "the search properties". */
label = gtk_label_new (_("Search"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
attrs = pango_attr_list_new ();
......
......@@ -12,15 +12,17 @@ libslideshow_la_SOURCES = \
callbacks.h \
gth-slideshow.c \
gth-slideshow.h \
gth-slideshow-preferences.c \
gth-slideshow-preferences.h \
gth-transition.c \
gth-transition.h \
main.c \
preferences.c \
preferences.h
libslideshow_la_CFLAGS = $(GTHUMB_CFLAGS) $(CLUTTER_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libslideshow_la_CFLAGS = $(GTHUMB_CFLAGS) $(CLUTTER_CFLAGS) $(GSTREAMER_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libslideshow_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
libslideshow_la_LIBADD = $(GTHUMB_LIBS) $(CLUTTER_LIBS)
libslideshow_la_LIBADD = $(GTHUMB_LIBS) $(CLUTTER_LIBS) $(GSTREAMER_LIBS) ../catalogs/libcatalogs.la
libslideshow_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
extensioninidir = $(extensiondir)
......
......@@ -33,11 +33,12 @@ void
gth_browser_activate_action_view_slideshow (GtkAction *action,
GthBrowser *browser)
{
GList *items;
GList *file_list;
GtkWidget *slideshow;
char *transition_id;
GList *transitions = NULL;
GList *items;
GList *file_list;
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,11 +47,26 @@ gth_browser_activate_action_view_slideshow (GtkAction *action,
file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
slideshow = gth_slideshow_new (browser, file_list);
gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), eel_gconf_get_float (PREF_SLIDESHOW_CHANGE_DELAY, 5) * 1000);
gth_slideshow_set_automatic (GTH_SLIDESHOW (slideshow), eel_gconf_get_boolean (PREF_SLIDESHOW_AUTOMATIC, TRUE));
gth_slideshow_set_loop (GTH_SLIDESHOW (slideshow), eel_gconf_get_boolean (PREF_SLIDESHOW_WRAP_AROUND, FALSE));
transition_id = eel_gconf_get_string (PREF_SLIDESHOW_TRANSITION, DEFAULT_TRANSITION);
location = gth_browser_get_location_data (browser);
if (g_file_info_get_attribute_status (location->info, "slideshow::personalize") == G_FILE_ATTRIBUTE_STATUS_SET) {
gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_int32 (location->info, "slideshow::delay") / 10.0);
gth_slideshow_set_automatic (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_boolean (location->info, "slideshow::auto"));
gth_slideshow_set_loop (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_boolean (location->info, "slideshow::loop"));
transition_id = g_strdup (g_file_info_get_attribute_string (location->info, "slideshow::transition"));
}
else {
gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), eel_gconf_get_float (PREF_SLIDESHOW_CHANGE_DELAY, 5) * 1000);
gth_slideshow_set_automatic (GTH_SLIDESHOW (slideshow), eel_gconf_get_boolean (PREF_SLIDESHOW_AUTOMATIC, TRUE));
gth_slideshow_set_loop (GTH_SLIDESHOW (slideshow), eel_gconf_get_boolean (PREF_SLIDESHOW_WRAP_AROUND, FALSE));
transition_id = eel_gconf_get_string (PREF_SLIDESHOW_TRANSITION, DEFAULT_TRANSITION);
}
if (g_file_info_get_attribute_status (location->info, "slideshow::audio-files") == G_FILE_ATTRIBUTE_STATUS_SET)
gth_slideshow_set_playlist (GTH_SLIDESHOW (slideshow),
g_file_info_get_attribute_stringv (location->info, "slideshow::audio-files"),
g_file_info_get_attribute_boolean (location->info, "slideshow::audio-loop"));
if (strcmp (transition_id, "random") == 0) {
GList *scan;
......@@ -75,8 +91,8 @@ gth_browser_activate_action_view_slideshow (GtkAction *action,
}
gth_slideshow_set_transitions (GTH_SLIDESHOW (slideshow), transitions);
gtk_window_fullscreen (GTK_WINDOW (slideshow));
/*gtk_window_set_default_size (GTK_WINDOW (slideshow), 700, 700);*/
/*gtk_window_fullscreen (GTK_WINDOW (slideshow)); FIXME */
gtk_window_set_default_size (GTK_WINDOW (slideshow), 700, 700);
gtk_window_present (GTK_WINDOW (slideshow));
_g_object_list_unref (transitions);
......
......@@ -3,7 +3,7 @@
/*
* GThumb
*
* Copyright (C) 2009 Free Software Foundation, Inc.
* Copyright (C) 2009-2010 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -26,6 +26,9 @@
#include <glib-object.h>
#include <gthumb.h>
#include "actions.h"
#include "callbacks.h"
#include "gth-slideshow-preferences.h"
#include "preferences.h"
#define BROWSER_DATA_KEY "slideshow-browser-data"
......@@ -131,3 +134,305 @@ ss__slideshow_cb (GthBrowser *browser)
{
gth_browser_activate_action_view_slideshow (NULL, browser);
}
void
ss__gth_catalog_read_metadata (GthCatalog *catalog,
GthFileData *file_data)
{
if (g_file_info_get_attribute_status (file_data->info, "slideshow::personalize") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_boolean (catalog->attributes,
"slideshow::personalize",
g_file_info_get_attribute_boolean (file_data->info, "slideshow::personalize"));
if (g_file_info_get_attribute_status (file_data->info, "slideshow::auto") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_boolean (catalog->attributes,
"slideshow::auto",
g_file_info_get_attribute_boolean (file_data->info, "slideshow::auto"));
if (g_file_info_get_attribute_status (file_data->info, "slideshow::loop") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_boolean (catalog->attributes,
"slideshow::loop",
g_file_info_get_attribute_boolean (file_data->info, "slideshow::loop"));
if (g_file_info_get_attribute_status (file_data->info, "slideshow::delay") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_float (catalog->attributes,
"slideshow::delay",
g_file_info_get_attribute_int32 (file_data->info, "slideshow::delay") / 10.0);
if (g_file_info_get_attribute_status (file_data->info, "slideshow::transition") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_string (catalog->attributes,
"slideshow::transition",
g_file_info_get_attribute_string (file_data->info, "slideshow::transition"));
if (g_file_info_get_attribute_status (file_data->info, "slideshow::audio-loop") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_boolean (catalog->attributes,
"slideshow::audio-loop",
g_file_info_get_attribute_boolean (file_data->info, "slideshow::audio-loop"));
if (g_file_info_get_attribute_status (file_data->info, "slideshow::audio-files") == G_FILE_ATTRIBUTE_STATUS_SET)
g_value_hash_set_stringv (catalog->attributes,
"slideshow::audio-files",
g_file_info_get_attribute_stringv (file_data->info, "slideshow::audio-files"));
}
void
ss__gth_catalog_write_metadata (GthCatalog *catalog,
GthFileData *file_data)
{
if (g_value_hash_is_set (catalog->attributes, "slideshow::personalize")) {
g_file_info_set_attribute_boolean (file_data->info,
"slideshow::personalize",
g_value_hash_get_boolean (catalog->attributes, "slideshow::personalize"));
g_file_info_set_attribute_status (file_data->info,
"slideshow::personalize",
G_FILE_ATTRIBUTE_STATUS_SET);
}
if (g_value_hash_is_set (catalog->attributes, "slideshow::auto")) {
g_file_info_set_attribute_boolean (file_data->info,
"slideshow::auto",
g_value_hash_get_boolean (catalog->attributes, "slideshow::auto"));
g_file_info_set_attribute_status (file_data->info,
"slideshow::auto",
G_FILE_ATTRIBUTE_STATUS_SET);
}
if (g_value_hash_is_set (catalog->attributes, "slideshow::loop")) {
g_file_info_set_attribute_boolean (file_data->info,
"slideshow::loop",
g_value_hash_get_boolean (catalog->attributes, "slideshow::loop"));
g_file_info_set_attribute_status (file_data->info,
"slideshow::loop",
G_FILE_ATTRIBUTE_STATUS_SET);
}
if (g_value_hash_is_set (catalog->attributes, "slideshow::delay")) {
g_file_info_set_attribute_int32 (file_data->info,
"slideshow::delay",
(int) g_value_hash_get_float (catalog->attributes, "slideshow::delay") * 10.0);
g_file_info_set_attribute_status (file_data->info,
"slideshow::delay",
G_FILE_ATTRIBUTE_STATUS_SET);
}
if (g_value_hash_is_set (catalog->attributes, "slideshow::transition")) {
g_file_info_set_attribute_string (file_data->info,
"slideshow::transition",
g_value_hash_get_string (catalog->attributes, "slideshow::transition"));
g_file_info_set_attribute_status (file_data->info,