[eog-plugins] Bug 438642 - EOG should have a "fit to image width" zoom mode
- From: Felix Riemann <friemann src gnome org>
- To: svn-commits-list gnome org
- Subject: [eog-plugins] Bug 438642 - EOG should have a "fit to image width" zoom mode
- Date: Mon, 27 Apr 2009 10:47:42 -0400 (EDT)
commit 0578eb4d437a67647f4bcb2a9ce58be5b242b2b9
Author: Javier Sánchez <jsanchez deskblue com>
Date: Mon Apr 27 16:45:44 2009 +0200
Bug 438642 - EOG should have a "fit to image width" zoom mode
Add the fit-to-width plugin by Javier Sánchez. It tries to set the zoom
so that the image width fits the window.
---
ChangeLog | 10 +
configure.ac | 7 +-
plugins/fit-to-width/Makefile.am | 32 ++++
plugins/fit-to-width/eog-fit-to-width-plugin.c | 183 ++++++++++++++++++++
plugins/fit-to-width/eog-fit-to-width-plugin.h | 74 ++++++++
.../fit-to-width.eog-plugin.desktop.in | 9 +
po/ChangeLog | 4 +
po/POTFILES.in | 2 +
8 files changed, 318 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 545a464..6918e52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-27 Felix Riemann <friemann svn gnome org>
+
+ * configure.ac:
+ * plugins/fit-to-width/Makefile.am:
+ * plugins/fit-to-width/eog-fit-to-width-plugin.c:
+ * plugins/fit-to-width/eog-fit-to-width-plugin.h:
+ * plugins/fit-to-width/fit-to-width.eog-plugin.desktop.in:
+ Add fit-to-width plugin which tries to make the image width fit the
+ window. Fixes bug #438642 (Javier Sánchez).
+
2009-04-12 Felix Riemann <friemann svn gnome org>
* configure.ac:
diff --git a/configure.ac b/configure.ac
index 815caee..4469f1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,9 +58,9 @@ EOG_HAS_PYTHON=1
AC_MSG_CHECKING([which plugins to build])
-ALL_PLUGINS="postr champlain"
-USEFUL_PLUGINS="postr champlain"
-DEFAULT_PLUGINS="postr champlain"
+ALL_PLUGINS="postr champlain fit-to-width"
+USEFUL_PLUGINS="postr champlain fit-to-width"
+DEFAULT_PLUGINS="postr champlain fit-to-width"
PYTHON_ALL_PLUGINS="slideshowshuffle pythonconsole"
PYTHON_USEFUL_PLUGINS="slideshowshuffle pythonconsole"
@@ -327,6 +327,7 @@ AC_CONFIG_FILES([
Makefile
plugins/Makefile
plugins/champlain/Makefile
+plugins/fit-to-width/Makefile
plugins/slideshowshuffle/Makefile
plugins/postr/Makefile
plugins/pythonconsole/Makefile
diff --git a/plugins/fit-to-width/Makefile.am b/plugins/fit-to-width/Makefile.am
new file mode 100644
index 0000000..d3c6e64
--- /dev/null
+++ b/plugins/fit-to-width/Makefile.am
@@ -0,0 +1,32 @@
+# Fit-to-width plugin
+plugindir = $(libdir)/eog/plugins
+
+INCLUDES = \
+ -I$(top_srcdir)/src \
+ $(EOG_CFLAGS) \
+ $(WARN_CFLAGS) \
+ -DEOG_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = libfit-to-width.la
+
+libfit_to_width_la_SOURCES = \
+ eog-fit-to-width-plugin.h \
+ eog-fit-to-width-plugin.c
+
+libfit_to_width_la_LDFLAGS = \
+ -avoid-version -module
+
+libfit_to_width_la_LIBADD = $(EOG_LIBS)
+
+# Plugin Info
+
+plugin_in_files = fit-to-width.eog-plugin.desktop.in
+
+%.eog-plugin: %.eog-plugin.desktop.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:.eog-plugin.desktop.in=.eog-plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
diff --git a/plugins/fit-to-width/eog-fit-to-width-plugin.c b/plugins/fit-to-width/eog-fit-to-width-plugin.c
new file mode 100644
index 0000000..ff1af27
--- /dev/null
+++ b/plugins/fit-to-width/eog-fit-to-width-plugin.c
@@ -0,0 +1,183 @@
+/* Fit-to-width -- Fit zoom to the image width
+ *
+ * Copyright (C) 2009 The Free Software Foundation
+ *
+ * Author: Javier Sánchez <jsanchez deskblue com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+#include <eog/eog-scroll-view.h>
+#include <eog/eog-image.h>
+
+#include "eog-fit-to-width-plugin.h"
+
+
+#define WINDOW_DATA_KEY "EogFitToWidthWindowData"
+
+EOG_PLUGIN_REGISTER_TYPE(EogFitToWidthPlugin, eog_fit_to_width_plugin)
+
+typedef struct
+{
+ GtkActionGroup *ui_action_group;
+ guint ui_menuitem_id;
+} WindowData;
+
+static void
+fit_to_width_cb (GtkAction *action,
+ EogWindow *window)
+{
+ GtkWidget *view;
+ EogImage *image;
+ gint image_width;
+ gint image_height;
+ gint view_width;
+ double zoom;
+
+ g_return_if_fail (EOG_IS_WINDOW (window));
+
+ view = eog_window_get_view (window);
+ image = eog_window_get_image (window);
+
+ g_return_if_fail (EOG_IS_SCROLL_VIEW (view));
+ g_return_if_fail (EOG_IS_IMAGE (image));
+
+ eog_image_get_size (image, &image_width, &image_height);
+ view_width = view->allocation.width;
+
+ // HACK: It's necessary subtract the width size (15) of vscrollbar
+ // to scrollview for obtain the display area.
+ zoom = (double) (view_width - 15) / image_width;
+
+ eog_scroll_view_set_zoom (EOG_SCROLL_VIEW (view), zoom);
+}
+
+static const gchar * const ui_definition =
+ "<ui><menubar name=\"MainMenu\">"
+ "<menu action=\"View\">"
+ "<menuitem action=\"EogPluginFitToWidth\"/>"
+ "</menu></menubar></ui>";
+
+static const GtkActionEntry action_entries[] =
+{
+ { "EogPluginFitToWidth",
+ GTK_STOCK_ZOOM_FIT,
+ N_("Fit to width"),
+ NULL,
+ N_("Zoom to fit image width"),
+ G_CALLBACK (fit_to_width_cb) }
+};
+
+static void
+free_window_data (WindowData *data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_object_unref (data->ui_action_group);
+
+ g_free (data);
+}
+
+
+static void
+eog_fit_to_width_plugin_init (EogFitToWidthPlugin *plugin)
+{
+}
+
+static void
+eog_fit_to_width_plugin_finalize (GObject *object)
+{
+}
+
+static void
+impl_activate (EogPlugin *plugin,
+ EogWindow *window)
+{
+ GtkUIManager *manager;
+ GList *action_groups;
+ WindowData *data;
+
+ manager = eog_window_get_ui_manager (window);
+ action_groups = gtk_ui_manager_get_action_groups (manager);
+ data = g_new (WindowData, 1);
+
+ data->ui_action_group = gtk_action_group_new ("EogFitToWidthPluginActions");
+
+ gtk_action_group_set_translation_domain (data->ui_action_group,
+ GETTEXT_PACKAGE);
+
+ gtk_action_group_add_actions (data->ui_action_group,
+ action_entries,
+ G_N_ELEMENTS (action_entries),
+ window);
+
+ gtk_ui_manager_insert_action_group (manager,
+ data->ui_action_group,
+ -1);
+
+ data->ui_menuitem_id = gtk_ui_manager_add_ui_from_string (manager,
+ ui_definition,
+ -1, NULL);
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data,
+ (GDestroyNotify) free_window_data);
+}
+
+static void
+impl_deactivate (EogPlugin *plugin,
+ EogWindow *window)
+{
+ GtkUIManager *manager;
+ WindowData *data;
+
+ manager = eog_window_get_ui_manager (window);
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ gtk_ui_manager_remove_ui (manager,
+ data->ui_menuitem_id);
+
+ gtk_ui_manager_remove_action_group (manager,
+ data->ui_action_group);
+
+ g_object_set_data (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ NULL);
+}
+
+static void
+impl_update_ui (EogPlugin *plugin,
+ EogWindow *window)
+{
+}
+
+static void
+eog_fit_to_width_plugin_class_init (EogFitToWidthPluginClass *klass)
+{
+ EogPluginClass *plugin_class = EOG_PLUGIN_CLASS (klass);
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
+}
diff --git a/plugins/fit-to-width/eog-fit-to-width-plugin.h b/plugins/fit-to-width/eog-fit-to-width-plugin.h
new file mode 100644
index 0000000..ef2210c
--- /dev/null
+++ b/plugins/fit-to-width/eog-fit-to-width-plugin.h
@@ -0,0 +1,74 @@
+/* Fit-to-width -- Fit zoom to the image width
+ *
+ * Copyright (C) 2009 The Free Software Foundation
+ *
+ * Author: Javier Sánchez <jsanchez deskblue com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __EOG_FIT_TO_WIDTH_PLUGIN_H__
+#define __EOG_FIT_TO_WIDTH_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <eog/eog-plugin.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define EOG_TYPE_FIT_TO_WIDTH_PLUGIN (eog_fit_to_width_plugin_get_type ())
+#define EOG_FIT_TO_WIDTH_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EOG_TYPE_FIT_TO_WIDTH_PLUGIN, EogStatusbarDatePlugin))
+#define EOG_FIT_TO_WIDTH_PLUGIN_CLASS(k) G_TYPE_CHECK_CLASS_CAST((k), EOG_TYPE_FIT_TO_WIDTH_PLUGIN, EogStatusbarDatePluginClass))
+#define EOG_IS_FIT_TO_WIDTH_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EOG_TYPE_FIT_TO_WIDTH_PLUGIN))
+#define EOG_IS_FIT_TO_WIDTH_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EOG_TYPE_FIT_TO_WIDTH_PLUGIN))
+#define EOG_FIT_TO_WIDTH_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EOG_TYPE_FIT_TO_WIDTH_PLUGIN, EogStatusbarDatePluginClass))
+
+/* Private structure type */
+typedef struct _EogFitToWidthPluginPrivate EogFitToWidthPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _EogFitToWidthPlugin EogFitToWidthPlugin;
+
+struct _EogFitToWidthPlugin
+{
+ EogPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _EogFitToWidthPluginClass EogFitToWidthPluginClass;
+
+struct _EogFitToWidthPluginClass
+{
+ EogPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType eog_fit_to_width_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_eog_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __EOG_FIT_TO_WIDTH_PLUGIN_H__ */
diff --git a/plugins/fit-to-width/fit-to-width.eog-plugin.desktop.in b/plugins/fit-to-width/fit-to-width.eog-plugin.desktop.in
new file mode 100644
index 0000000..d60aa91
--- /dev/null
+++ b/plugins/fit-to-width/fit-to-width.eog-plugin.desktop.in
@@ -0,0 +1,9 @@
+[Eog Plugin]
+Module=fit-to-width
+IAge=2
+_Name=Zoom to fit image width
+Icon=gtk-zoom-fit
+_Description=Zoom to fit image width
+Authors=Javier Sánchez <jsanchez deskblue com>
+Copyright=Copyright © 2009 Javier Sánchez
+Website=http://www.gnome.org/projects/eog
diff --git a/po/ChangeLog b/po/ChangeLog
index 24253cd..e695669 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-27 Felix Riemann <friemann svn gnome org>
+
+ * POTFILES.in: Add entries for fit-to-width plugin.
+
2009-04-20 Daniel Nylander <po danielnylander se>
* sv.po: Updated Swedish translation.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 35cf751..9fc9bd8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,6 @@
plugins/champlain/champlain.eog-plugin.desktop.in
+plugins/fit-to-width/eog-fit-to-width-plugin.c
+plugins/fit-to-width/fit-to-width.eog-plugin.desktop.in
plugins/slideshowshuffle/slideshowshuffle.eog-plugin.desktop.in
plugins/postr/postr.eog-plugin.desktop.in
plugins/postr/eog-postr-plugin.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]