[eog-plugins] New plugin: Export to Folder
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog-plugins] New plugin: Export to Folder
- Date: Mon, 20 Aug 2012 20:28:09 +0000 (UTC)
commit 95a2bed928780cd55aa08d2f7b0a84335f78ef7f
Author: Jendrik Seipp <jendrikseipp web de>
Date: Mon Aug 20 21:14:14 2012 +0200
New plugin: Export to Folder
configure.ac | 7 +-
plugins/export-to-folder/Makefile.am | 21 ++++
.../export-to-folder.plugin.desktop.in | 10 ++
plugins/export-to-folder/export-to-folder.py | 101 ++++++++++++++++++++
plugins/export-to-folder/preferences_dialog.ui | 41 ++++++++
5 files changed, 177 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 57053b7..2754ff0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,9 +65,9 @@ ALL_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa hide-title
USEFUL_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa hide-titlebar light-theme"
DEFAULT_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa hide-titlebar light-theme"
-PYTHON_ALL_PLUGINS="slideshowshuffle pythonconsole fullscreenbg"
-PYTHON_USEFUL_PLUGINS="slideshowshuffle pythonconsole fullscreenbg"
-PYTHON_DEFAULT_PLUGINS="slideshowshuffle pythonconsole fullscreenbg"
+PYTHON_ALL_PLUGINS="slideshowshuffle pythonconsole fullscreenbg export-to-folder"
+PYTHON_USEFUL_PLUGINS="slideshowshuffle pythonconsole fullscreenbg export-to-folder"
+PYTHON_DEFAULT_PLUGINS="slideshowshuffle pythonconsole fullscreenbg export-to-folder"
DIST_PLUGINS="$ALL_PLUGINS $PYTHON_ALL_PLUGINS"
@@ -338,6 +338,7 @@ plugins/map/Makefile
plugins/fit-to-width/Makefile
plugins/exif-display/Makefile
plugins/exif-display/org.gnome.eog.plugins.exif-display.gschema.xml.in
+plugins/export-to-folder/Makefile
plugins/fullscreenbg/Makefile
plugins/fullscreenbg/org.gnome.eog.plugins.fullscreenbg.gschema.xml.in
plugins/hide-titlebar/Makefile
diff --git a/plugins/export-to-folder/Makefile.am b/plugins/export-to-folder/Makefile.am
new file mode 100644
index 0000000..db72e55
--- /dev/null
+++ b/plugins/export-to-folder/Makefile.am
@@ -0,0 +1,21 @@
+# Export-to-Folder plugin
+plugindir = $(EOG_PLUGINS_LIBS_DIR)
+uidir = $(EOG_PLUGINS_DATA_DIR)/export-to-folder
+plugin_in_files = export-to-folder.plugin.desktop.in
+
+UI_FILES = preferences_dialog.ui
+ui_DATA = $(UI_FILES)
+
+plugin_PYTHON = \
+ export-to-folder.py
+
+%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(AM_V_GEN)$(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/export-to-folder/export-to-folder.plugin.desktop.in b/plugins/export-to-folder/export-to-folder.plugin.desktop.in
new file mode 100644
index 0000000..7fe2dfb
--- /dev/null
+++ b/plugins/export-to-folder/export-to-folder.plugin.desktop.in
@@ -0,0 +1,10 @@
+[Plugin]
+Loader=python
+Module=export-to-folder
+IAge=2
+_Name=Export to Folder
+Icon=eog
+_Description=Export the current image to a separate directory
+Authors=Jendrik Seipp <jendrikseipp web de>
+Copyright=Copyright  2012 Jendrik Seipp
+Website=https://bitbucket.org/jendrikseipp/eog-export
diff --git a/plugins/export-to-folder/export-to-folder.py b/plugins/export-to-folder/export-to-folder.py
new file mode 100644
index 0000000..10fd754
--- /dev/null
+++ b/plugins/export-to-folder/export-to-folder.py
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+#
+# export.py -- export plugin for eog
+#
+# Copyright (c) 2012 Jendrik Seipp (jendrikseipp web de)
+#
+# 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, 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.
+
+import os
+import shutil
+
+from gi.repository import GObject, Eog, Gio, Gtk, PeasGtk
+
+
+ui_str = """
+<ui>
+ <menubar name="MainMenu">
+ <menu name="ToolsMenu" action="Tools">
+ <separator/>
+ <menuitem name="Export" action="Export"/>
+ <separator/>
+ </menu>
+ </menubar>
+</ui>
+"""
+
+EXPORT_DIR = os.path.join(os.path.expanduser('~'), 'exported-images')
+
+
+class ExportPlugin(GObject.Object, Eog.WindowActivatable):
+ window = GObject.property(type=Eog.Window)
+
+ def __init__(self):
+ GObject.Object.__init__(self)
+
+ @property
+ def export_dir(self):
+ return EXPORT_DIR
+
+ def do_activate(self):
+ print 'Activating export plugin'
+ ui_manager = self.window.get_ui_manager()
+ self.action_group = Gtk.ActionGroup('Export')
+ self.action_group.add_actions([('Export', None,
+ _('_Export'), "E", None, self.export_cb)], self.window)
+ ui_manager.insert_action_group(self.action_group, 0)
+ self.ui_id = ui_manager.add_ui_from_string(ui_str)
+
+ def do_deactivate(self):
+ print 'Export plugin deactivated'
+
+ def export_cb(self, action, window):
+ # Get path to current image.
+ image = window.get_image()
+ if not image:
+ print 'No image can be exported'
+ return
+ src = image.get_file().get_path()
+ name = os.path.basename(src)
+ dest = os.path.join(self.export_dir, name)
+ # Create directory if it doesn't exist.
+ try:
+ os.makedirs(self.export_dir)
+ except OSError:
+ pass
+ shutil.copy2(src, dest)
+ print 'Copied %s into %s' % (name, self.export_dir)
+
+
+class ExportConfigurable(GObject.Object, PeasGtk.Configurable):
+ def do_create_configure_widget(self):
+ # Create preference dialog
+ signals = {'current_folder_changed_cb': self.current_folder_changed_cb}
+ builder = Gtk.Builder()
+ builder.set_translation_domain('eog-plugins')
+ builder.add_from_file(os.path.join(self.plugin_info.get_data_dir(),
+ 'preferences_dialog.ui'))
+ builder.connect_signals(signals)
+
+ self.export_dir_button = builder.get_object('export_dir_button')
+ self.preferences_dialog = builder.get_object('preferences_box')
+ self.export_dir_button.set_current_folder(EXPORT_DIR)
+
+ return self.preferences_dialog
+
+ def current_folder_changed_cb(self, button):
+ global EXPORT_DIR
+ EXPORT_DIR = button.get_current_folder()
+ print 'Exporting to %s' % EXPORT_DIR
diff --git a/plugins/export-to-folder/preferences_dialog.ui b/plugins/export-to-folder/preferences_dialog.ui
new file mode 100644
index 0000000..58e8525
--- /dev/null
+++ b/plugins/export-to-folder/preferences_dialog.ui
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkBox" id="preferences_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="margin_left">10</property>
+ <property name="margin_right">10</property>
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">10</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="export_dir_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Export directory:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="export_dir_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="action">select-folder</property>
+ <signal name="current-folder-changed" handler="current_folder_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]