Commit e2ad0755 authored by Philip Withnall's avatar Philip Withnall Committed by Philip Withnall

Add UI to allow creation of galleries, by moving the current screenshot

2008-12-27  Philip Withnall  <philip@tecnocode.co.uk>

	* configure.in:
	* data/totem.ui:
	* src/Makefile.am:
	* src/plugins/screenshot/Makefile.am:
	* src/plugins/screenshot/gallery.ui:
	* src/plugins/screenshot/screenshot.totem-plugin.in:
	* src/plugins/screenshot/totem-gallery-progress.c
	(totem_gallery_progress_class_init), 
(totem_gallery_progress_init),
	(totem_gallery_progress_finalize), (totem_gallery_progress_new),
	(dialog_response_callback), (process_line), (stdout_watch_cb),
	(totem_gallery_progress_run):
	* src/plugins/screenshot/totem-gallery-progress.h:
	* src/plugins/screenshot/totem-gallery.c
	(totem_gallery_class_init), (totem_gallery_init),
	(totem_gallery_new), 
(default_screenshot_count_toggled_callback),
	(dialog_response_callback):
	* src/plugins/screenshot/totem-gallery.h:
	* src/plugins/screenshot/totem-screenshot-plugin.c
	(totem_screenshot_plugin_class_init),
	(totem_screenshot_plugin_init), (take_screenshot_action_cb),
	(take_gallery_action_cb), (window_key_press_event_cb),
	(update_state), (got_metadata_cb), (notify_logo_mode_cb),
	(disable_save_to_disk_changed_cb), (impl_activate),
	(impl_deactivate), (make_filename_for_dir),
	(totem_screenshot_plugin_setup_file_chooser),
	(totem_screenshot_plugin_update_file_chooser):
	* src/plugins/screenshot/totem-screenshot-plugin.h:
	* src/plugins/screenshot/totem-screenshot.c
	(totem_screenshot_response), (totem_screenshot_init),
	(totem_screenshot_new):
	* src/plugins/screenshot/totem-screenshot.h:
	* src/totem-menu.c:
	* src/totem-preferences.c (totem_setup_preferences):
	* src/totem-private.h:
	* src/totem-screenshot.c:
	* src/totem-screenshot.h:
	* src/totem-video-thumbnailer.c (create_gallery), (main):
	* src/totem.c (totem_action_set_mrl_with_warning),
	(on_got_metadata_event), (totem_action_handle_key_press): Add UI 
to
	allow creation of galleries, by moving the current screenshot
	dialogue out to a built-in "screenshot" plugin, and adding a
	dialogue for creating galleries, as well as a progress dialogue.
	Currently, the progress dialogue does not fully work due to pipe
	problems. (Helps: #561088)

	* po/POTFILES.in: Added screenshot plugin files.


svn path=/trunk/; revision=5878
parent a75385e9
2008-12-27 Philip Withnall <philip@tecnocode.co.uk>
* configure.in:
* data/totem.ui:
* src/Makefile.am:
* src/plugins/screenshot/Makefile.am:
* src/plugins/screenshot/gallery.ui:
* src/plugins/screenshot/screenshot.totem-plugin.in:
* src/plugins/screenshot/totem-gallery-progress.c
(totem_gallery_progress_class_init), (totem_gallery_progress_init),
(totem_gallery_progress_finalize), (totem_gallery_progress_new),
(dialog_response_callback), (process_line), (stdout_watch_cb),
(totem_gallery_progress_run):
* src/plugins/screenshot/totem-gallery-progress.h:
* src/plugins/screenshot/totem-gallery.c
(totem_gallery_class_init), (totem_gallery_init),
(totem_gallery_new), (default_screenshot_count_toggled_callback),
(dialog_response_callback):
* src/plugins/screenshot/totem-gallery.h:
* src/plugins/screenshot/totem-screenshot-plugin.c
(totem_screenshot_plugin_class_init),
(totem_screenshot_plugin_init), (take_screenshot_action_cb),
(take_gallery_action_cb), (window_key_press_event_cb),
(update_state), (got_metadata_cb), (notify_logo_mode_cb),
(disable_save_to_disk_changed_cb), (impl_activate),
(impl_deactivate), (make_filename_for_dir),
(totem_screenshot_plugin_setup_file_chooser),
(totem_screenshot_plugin_update_file_chooser):
* src/plugins/screenshot/totem-screenshot-plugin.h:
* src/plugins/screenshot/totem-screenshot.c
(totem_screenshot_response), (totem_screenshot_init),
(totem_screenshot_new):
* src/plugins/screenshot/totem-screenshot.h:
* src/totem-menu.c:
* src/totem-preferences.c (totem_setup_preferences):
* src/totem-private.h:
* src/totem-screenshot.c:
* src/totem-screenshot.h:
* src/totem-video-thumbnailer.c (create_gallery), (main):
* src/totem.c (totem_action_set_mrl_with_warning),
(on_got_metadata_event), (totem_action_handle_key_press): Add UI to
allow creation of galleries, by moving the current screenshot
dialogue out to a built-in "screenshot" plugin, and adding a
dialogue for creating galleries, as well as a progress dialogue.
Currently, the progress dialogue does not fully work due to pipe
problems. (Helps: #561088)
2008-12-25 Eric Piel <e.a.b.piel@tudelft.nl>
reviewed by: Philip Withnall
......
......@@ -50,7 +50,7 @@ AC_SUBST(TOTEM_VERSION_MINOR)
AC_SUBST(TOTEM_VERSION_MICRO)
# The full list of plugins
allowed_plugins="thumbnail screensaver ontop galago gromit lirc media-player-keys mythtv properties sidebar-test skipto sample-python sample-vala bemused youtube publish tracker pythonconsole jamendo opensubtitles"
allowed_plugins="thumbnail screensaver ontop galago gromit lirc media-player-keys mythtv properties sidebar-test skipto sample-python sample-vala bemused youtube publish tracker pythonconsole jamendo opensubtitles screenshot"
PLUGINDIR='${libdir}/totem/plugins'
AC_SUBST(PLUGINDIR)
......@@ -257,7 +257,8 @@ PKG_CHECK_MODULES([DEPENDENCY],[
gtk+-2.0 >= $GTK_REQS
gmodule-2.0
gconf-2.0
totem-plparser >= $TOTEM_PLPARSER_REQS])
totem-plparser >= $TOTEM_PLPARSER_REQS
cairo])
PKG_CHECK_MODULES(MM, $MM)
......@@ -843,6 +844,7 @@ src/Makefile
src/plugins/Makefile
src/plugins/bemused/Makefile
src/plugins/screensaver/Makefile
src/plugins/screenshot/Makefile
src/plugins/ontop/Makefile
src/plugins/galago/Makefile
src/plugins/gromit/Makefile
......
......@@ -68,15 +68,6 @@
<property name="label" translatable="yes">_Edit</property>
</object>
</child>
<child>
<object class="GtkAction" id="take-screenshot">
<property name="label" translatable="yes">Take _Screenshot...</property>
<property name="icon-name">camera-photo</property>
<property name="tooltip" translatable="yes">Take a screenshot</property>
<signal name="activate" handler="take_screenshot_action_callback"/>
</object>
<accelerator key="S" modifiers="GDK_SHIFT_MASK"/>
</child>
<child>
<object class="GtkAction" id="clear-playlist">
<property name="label" translatable="yes">_Clear Playlist</property>
......@@ -446,8 +437,6 @@
<menuitem name="quit" action="quit"/>
</menu>
<menu name="edit" action="edit-menu">
<menuitem name="take-screenshot" action="take-screenshot"/>
<separator/>
<menuitem name="repeat-mode" action="repeat-mode"/>
<menuitem name="shuffle-mode" action="shuffle-mode"/>
<separator/>
......
2008-12-27 Philip Withnall <philip@tecnocode.co.uk>
* POTFILES.in: Added screenshot plugin files.
2008-12-20 Ihar Hrachyshka <booxter@lacinka.org>
* be@latin.po: Updated Belarusian Latin translation by Ihar Hračyška.
......
......@@ -25,7 +25,6 @@ src/totem-playlist.c
src/totem-preferences.c
src/totem-properties-main.c
src/totem-properties-view.c
src/totem-screenshot.c
src/totem-sidebar.c
src/totem-statusbar.c
src/totem-subtitle-encoding.c
......@@ -61,6 +60,12 @@ src/plugins/publish/totem-publish.c
[type: gettext/ini]src/plugins/publish/publish.totem-plugin.in
[type: gettext/glade]src/plugins/publish/publish-plugin.ui
[type: gettext/ini]src/plugins/screensaver/screensaver.totem-plugin.in
[type: gettext/ini]src/plugins/screenshot/screenshot.totem-plugin.in
[type: gettext/glade]src/plugins/screenshot/gallery.ui
src/plugins/screenshot/totem-gallery.c
src/plugins/screenshot/totem-gallery-progress.c
src/plugins/screenshot/totem-screenshot.c
src/plugins/screenshot/totem-screenshot-plugin.c
[type: gettext/ini]src/plugins/skipto/skipto.totem-plugin.in
src/plugins/skipto/totem-skipto.c
src/plugins/skipto/totem-skipto-plugin.c
......
......@@ -104,8 +104,6 @@ totem_SOURCES = \
totem-options.c totem-options.h \
totem-playlist.c totem-playlist.h \
eggfileformatchooser.c eggfileformatchooser.h \
totem-screenshot.c \
totem-screenshot.h \
totem-session.c totem-session.h \
totem-sidebar.c totem-sidebar.h \
totem-open-location.c totem-open-location.h \
......
modules_flags = -export_dynamic -avoid-version -module
plugindir = $(PLUGINDIR)/screenshot
uidir = $(plugindir)
plugin_LTLIBRARIES = libscreenshot.la
plugin_in_files = screenshot.totem-plugin.in
%.totem-plugin: %.totem-plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
plugin_DATA = $(plugin_in_files:.totem-plugin.in=.totem-plugin)
ui_DATA = gallery.ui
common_defines = \
-D_REENTRANT \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGCONF_PREFIX=\""/apps/totem"\" \
-DDATADIR=\""$(datadir)"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
-DBINDIR=\""$(bindir)"\" \
-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
$(DISABLE_DEPRECATED)
libscreenshot_la_SOURCES = \
totem-screenshot-plugin.c \
totem-screenshot-plugin.h \
totem-screenshot.c \
totem-screenshot.h \
totem-gallery.c \
totem-gallery.h \
totem-gallery-progress.c \
totem-gallery-progress.h
libscreenshot_la_LDFLAGS = $(modules_flags)
libscreenshot_la_CPPFLAGS = \
$(common_defines) \
-I$(top_srcdir)/src/backend \
-I$(top_srcdir)/plparse
libscreenshot_la_CFLAGS = \
$(DEPENDENCY_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
-I$(top_srcdir)/ \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/plugins \
-I$(srcdir)/
EXTRA_DIST = $(plugin_in_files) $(ui_DATA)
CLEANFILES = $(plugin_DATA) $(BUILT_SOURCES)
DISTCLEANFILES = $(plugin_DATA)
<?xml version="1.0"?>
<interface>
<object class="GtkAdjustment" id="screenshot_count_adjustment">
<property name="upper">30</property>
<property name="lower">1</property>
<property name="page-increment">10</property>
<property name="step-increment">1</property>
<property name="page-size">10</property>
<property name="value">1</property>
</object>
<object class="GtkAdjustment" id="screenshot_width_adjustment">
<property name="upper">500</property>
<property name="lower">20</property>
<property name="page-increment">10</property>
<property name="step-increment">1</property>
<property name="page-size">10</property>
<property name="value">128</property>
</object>
<object class="GtkVBox" id="gallery_dialog_content">
<property name="spacing">2</property>
<child>
<object class="GtkTable" id="table1">
<property name="n-rows">4</property>
<property name="n-columns">2</property>
<property name="row-spacing">5</property>
<child>
<object class="GtkSpinButton" id="screenshot_count">
<property name="sensitive">False</property><!-- made sensitive when default_screenshot_count is unchecked -->
<property name="activates-default">True</property>
<property name="adjustment">screenshot_count_adjustment</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="right-attach">2</property>
<property name="top-attach">3</property>
<property name="bottom-attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="xalign">1</property>
<property name="label" translatable="yes">Screenshot width:</property>
</object>
<packing>
<property name="top-attach">1</property>
<property name="bottom-attach">2</property>
<property name="x-options">GTK_FILL</property>
<property name="y-options">GTK_FILL</property>
<property name="x-padding">5</property>
<property name="y-padding">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="default_screenshot_count">
<property name="label" translatable="yes">Calculate the number of screenshots</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<signal name="toggled" handler="default_screenshot_count_toggled_callback"/>
</object>
<packing>
<property name="right-attach">2</property>
<property name="top-attach">2</property>
<property name="bottom-attach">3</property>
<property name="y-options">GTK_FILL</property>
<property name="y-padding">5</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="screenshot_width">
<property name="activates-default">True</property>
<property name="adjustment">screenshot_width_adjustment</property>
</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>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="xalign">1</property>
<property name="label" translatable="yes">Number of screenshots:</property>
</object>
<packing>
<property name="top-attach">3</property>
<property name="bottom-attach">4</property>
<property name="x-options">GTK_FILL</property>
<property name="y-options">GTK_FILL</property>
<property name="x-padding">5</property>
<property name="y-padding">5</property>
</packing>
</child>
</object>
<packing>
<property name="padding">5</property>
</packing>
</child>
</object>
</interface>
[Totem Plugin]
Module=screenshot
IAge=1
Builtin=true
Name=Screenshot
Description=Allows screenshots and galleries to be taken of videos.
Authors=Philip Withnall, Bastien Nocera
Copyright=Copyright © 2008 Philip Withnall, 2004 Bastien Nocera
Website=http://www.gnome.org/projects/totem/
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Philip Withnall <philip@tecnocode.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* The Totem project hereby grant permission for non-gpl compatible GStreamer
* plugins to be used and distributed together with GStreamer and Totem. This
* permission are above and beyond the permissions granted by the GPL license
* Totem is covered by.
*
* Monday 7th February 2005: Christian Schaller: Add exception clause.
* See license_change file for details.
*/
#include "config.h"
#include <signal.h>
#include <unistd.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
#include "totem-gallery-progress.h"
static void totem_gallery_progress_init (TotemGalleryProgress *self);
static void totem_gallery_progress_finalize (GObject *object);
static void dialog_response_callback (GtkDialog *dialog, gint response_id, TotemGalleryProgress *self);
struct _TotemGalleryProgressPrivate {
GPid child_pid;
GString *line;
gchar *output_filename;
GMainLoop *loop;
GtkProgressBar *progress_bar;
};
G_DEFINE_TYPE (TotemGalleryProgress, totem_gallery_progress, GTK_TYPE_DIALOG)
#define TOTEM_GALLERY_PROGRESS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOTEM_TYPE_GALLERY_PROGRESS, TotemGalleryProgressPrivate))
static void
totem_gallery_progress_class_init (TotemGalleryProgressClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (TotemGalleryProgressPrivate));
gobject_class->finalize = totem_gallery_progress_finalize;
}
static void
totem_gallery_progress_init (TotemGalleryProgress *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TOTEM_TYPE_GALLERY_PROGRESS, TotemGalleryProgressPrivate);
}
static void
totem_gallery_progress_finalize (GObject *object)
{
TotemGalleryProgressPrivate *priv = TOTEM_GALLERY_PROGRESS_GET_PRIVATE (object);
g_spawn_close_pid (priv->child_pid);
g_free (priv->output_filename);
if (priv->line != NULL)
g_string_free (priv->line, TRUE);
if (priv->loop != NULL)
g_main_loop_unref (priv->loop);
/* Chain up to the parent class */
G_OBJECT_CLASS (totem_gallery_progress_parent_class)->finalize (object);
}
TotemGalleryProgress *
totem_gallery_progress_new (GPid child_pid, const gchar *output_filename)
{
TotemGalleryProgress *self;
GtkWidget *container;
gchar *label_text;
/* Create the gallery */
self = g_object_new (TOTEM_TYPE_GALLERY_PROGRESS, NULL);
/* Create the widget and initialise class variables */
self->priv->progress_bar = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
self->priv->child_pid = child_pid;
self->priv->output_filename = g_strdup (output_filename);
/* Set up the window */
gtk_window_set_title (GTK_WINDOW (self), _("Creating Gallery..."));
gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_CANCEL);
/* Set the progress label */
label_text = g_strdup_printf (_("Saving gallery as \"%s\""), output_filename);
gtk_progress_bar_set_text (self->priv->progress_bar, label_text);
g_free (label_text);
g_signal_connect (G_OBJECT (self), "response",
G_CALLBACK (dialog_response_callback), self);
/* Assemble the window */
container = gtk_dialog_get_content_area (GTK_DIALOG (self));
gtk_box_pack_start (GTK_BOX (container), GTK_WIDGET (self->priv->progress_bar), TRUE, TRUE, 5);
return self;
}
static void
dialog_response_callback (GtkDialog *dialog, gint response_id, TotemGalleryProgress *self)
{
/* Cancel the operation by killing the process */
kill (self->priv->child_pid, SIGINT);
/* Unlink the output file, just in case (race condition) it's already been created */
g_unlink (self->priv->output_filename);
/* Quit the main loop */
if (self->priv->loop != NULL && g_main_loop_is_running (self->priv->loop))
g_main_loop_quit (self->priv->loop);
}
static gboolean
process_line (TotemGalleryProgress *self, const gchar *line)
{
gfloat percent_complete;
if (sscanf (line, "%f%% complete", &percent_complete) == 1) {
gtk_progress_bar_set_fraction (self->priv->progress_bar, percent_complete / 100.0);
return TRUE;
}
/* Error! */
return FALSE;
}
static gboolean
stdout_watch_cb (GIOChannel *source, GIOCondition condition, TotemGalleryProgress *self)
{
/* Code pilfered from nautilus-burn-process.c (nautilus-cd-burner) under GPLv2+
* Copyright (C) 2006 William Jon McCann <mccann@jhu.edu> */
TotemGalleryProgressPrivate *priv = self->priv;
gboolean retval = TRUE;
if (condition & G_IO_IN || condition & G_IO_PRI) {
gchar *line;
gchar buf[1];
GIOStatus status;
status = g_io_channel_read_line (source, &line, NULL, NULL, NULL);
if (status == G_IO_STATUS_NORMAL) {
if (priv->line != NULL) {
g_string_append (priv->line, line);
g_free (line);
line = g_string_free (priv->line, FALSE);
priv->line = NULL;
}
retval = process_line (self, line);
g_free (line);
} else if (status == G_IO_STATUS_AGAIN) {
/* A non-terminated line was read, read the data into the buffer. */
status = g_io_channel_read_chars (source, buf, 1, NULL, NULL);
if (status == G_IO_STATUS_NORMAL) {
gchar *line2;
if (priv->line == NULL)
priv->line = g_string_new (NULL);
g_string_append_c (priv->line, buf[0]);
switch (buf[0]) {
case '\n':
case '\r':
case '\xe2':
case '\0':
line2 = g_string_free (priv->line, FALSE);
priv->line = NULL;
retval = process_line (self, line2);
g_free (line2);
break;
default:
break;
}
}
} else if (status == G_IO_STATUS_EOF) {
/* Show as complete and stop processing */
gtk_progress_bar_set_fraction (self->priv->progress_bar, 1.0);
retval = FALSE;
}
} else if (condition & G_IO_HUP) {
retval = FALSE;
}
if (retval == FALSE) {
/* Exit the main loop; we're done processing input */
if (self->priv->loop != NULL && g_main_loop_is_running (self->priv->loop))
g_main_loop_quit (self->priv->loop);
}
return retval;
}
void
totem_gallery_progress_run (TotemGalleryProgress *self, gint stdout_fd)
{
TotemGalleryProgressPrivate *priv = self->priv;
GIOChannel *channel;
guint stdout_watch_id;
/* Watch the output from totem-video-thumbnailer */
channel = g_io_channel_unix_new (stdout_fd);
g_io_channel_set_flags (channel, g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK, NULL);
g_io_channel_set_encoding (channel, NULL, NULL);
g_io_channel_set_buffered (channel, FALSE);
stdout_watch_id = g_io_add_watch (channel, G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_ERR | G_IO_NVAL, (GIOFunc) stdout_watch_cb, self);
g_io_channel_unref (channel);
/* Listen in a recursive main loop so this function is synchronous */
priv->loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (priv->loop);
g_source_remove (stdout_watch_id);
g_main_loop_unref (priv->loop);
priv->loop = NULL;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Philip Withnall <philip@tecnocode.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* The Totem project hereby grant permission for non-gpl compatible GStreamer
* plugins to be used and distributed together with GStreamer and Totem. This
* permission are above and beyond the permissions granted by the GPL license
* Totem is covered by.
*
* Monday 7th February 2005: Christian Schaller: Add exception clause.
* See license_change file for details.
*/
#ifndef TOTEM_GALLERY_PROGRESS_H
#define TOTEM_GALLERY_PROGRESS_H
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define TOTEM_TYPE_GALLERY_PROGRESS (totem_gallery_progress_get_type ())
#define TOTEM_GALLERY_PROGRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TOTEM_TYPE_GALLERY_PROGRESS, TotemGalleryProgress))
#define TOTEM_GALLERY_PROGRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TOTEM_TYPE_GALLERY_PROGRESS, TotemGalleryProgressClass))
#define TOTEM_IS_GALLERY_PROGRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TOTEM_TYPE_GALLERY_PROGRESS))
#define TOTEM_IS_GALLERY_PROGRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TOTEM_TYPE_GALLERY_PROGRESS))
#define TOTEM_GALLERY_PROGRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TOTEM_TYPE_GALLERY_PROGRESS, TotemGalleryProgressClass))
typedef struct _TotemGalleryProgressPrivate TotemGalleryProgressPrivate;
typedef struct {
GtkDialog parent;
TotemGalleryProgressPrivate *priv;
} TotemGalleryProgress;
typedef struct {
GtkDialogClass parent;
} TotemGalleryProgressClass;
GType totem_gallery_progress_get_type (void);
TotemGalleryProgress *totem_gallery_progress_new (GPid child_pid, const gchar *output_filename);
void totem_gallery_progress_run (TotemGalleryProgress *self, gint stdout_fd);
G_END_DECLS
#endif /* !TOTEM_GALLERY_PROGRESS_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Philip Withnall <philip@tecnocode.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* The Totem project hereby grant permission for non-gpl compatible GStreamer
* plugins to be used and distributed together with GStreamer and Totem. This
* permission are above and beyond the permissions granted by the GPL license
* Totem is covered by.
*
* Monday 7th February 2005: Christian Schaller: Add exception clause.
* See license_change file for details.
*/
#include "config.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "totem-gallery.h"
#include "totem-gallery-progress.h"
#include "totem-screenshot-plugin.h"
static void totem_gallery_init (TotemGallery *self);
static void dialog_response_callback (GtkDialog *dialog, gint response_id, TotemGallery *self);
/* GtkBuilder callbacks */
void default_screenshot_count_toggled_callback (GtkToggleButton *toggle_button, TotemGallery *self);
struct _TotemGalleryPrivate {
Totem *totem;
GtkCheckButton *default_screenshot_count;
GtkSpinButton *screenshot_count;
GtkSpinButton *screenshot_width;
};
G_DEFINE_TYPE (TotemGallery, totem_gallery, GTK_TYPE_FILE_CHOOSER_DIALOG)
#define TOTEM_GALLERY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOTEM_TYPE_GALLERY, TotemGalleryPrivate))
static void
totem_gallery_class_init (TotemGalleryClass *klass)
{
g_type_class_add_private (klass, sizeof (TotemGalleryPrivate));
}
static void
totem_gallery_init (TotemGallery *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TOTEM_TYPE_GALLERY, TotemGalleryPrivate);
}
TotemGallery *
totem_gallery_new (Totem *totem, TotemPlugin *plugin)
{
TotemGallery *gallery;
GtkWidget *container;
GtkBuilder *builder;
/* Create the gallery and its interface */
gallery = g_object_new (TOTEM_TYPE_GALLERY, NULL);
builder = totem_plugin_load_interface (plugin, "gallery.ui", TRUE, NULL, gallery);
if (builder == NULL) {
g_object_unref (gallery);
return NULL;
}
/* Grab the widgets */
gallery->priv->default_screenshot_count = GTK_CHECK_BUTTON (gtk_builder_get_object (builder, "default_screenshot_count"));
gallery->priv->screenshot_count = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "screenshot_count"));
gallery->priv->screenshot_width = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "screenshot_width"));
gallery->priv->totem = totem;
gtk_window_set_title (GTK_WINDOW (gallery), _("Save Gallery"));
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (gallery), GTK_FILE_CHOOSER_ACTION_SAVE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (gallery), TRUE);
/*gtk_window_set_resizable (GTK_WINDOW (gallery), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (gallery), TRUE);*/
gtk_dialog_add_buttons (GTK_DIALOG (gallery),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (gallery), GTK_RESPONSE_OK);
g_signal_connect (G_OBJECT (gallery), "response",
G_CALLBACK (dialog_response_callback), gallery);
container = GTK_WIDGET (gtk_builder_get_object (builder,
"gallery_dialog_content"));
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (gallery), container);
totem_screenshot_plugin_setup_file_chooser (GTK_FILE_CHOOSER (gallery), N_("Screenshot%d.jpg"));
gtk_widget_show_all (GTK_WIDGET (gallery));
g_object_unref (builder);