[eog-plugins] Add new plugin: Send By Mail
- From: Felix Riemann <friemann src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [eog-plugins] Add new plugin: Send By Mail
- Date: Sun, 25 Oct 2009 18:38:07 +0000 (UTC)
commit a240c89eaa32a6ddd5a23c527017b397619a9ee3
Author: Felix Riemann <friemann gnome org>
Date: Sun Oct 25 17:59:25 2009 +0100
Add new plugin: Send By Mail
Add plugin that attaches the opened image to a new email. Fixes bgo#568854.
configure.ac | 7 +-
plugins/send-by-mail/Makefile.am | 32 ++++
plugins/send-by-mail/eog-send-by-mail-plugin.c | 177 ++++++++++++++++++++
plugins/send-by-mail/eog-send-by-mail-plugin.h | 74 ++++++++
.../send-by-mail.eog-plugin.desktop.in | 9 +
5 files changed, 296 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 24c5864..0c0511f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,9 +60,9 @@ EOG_HAS_PYTHON=1
AC_MSG_CHECKING([which plugins to build])
-ALL_PLUGINS="postr champlain fit-to-width exif-display"
-USEFUL_PLUGINS="postr champlain fit-to-width exif-display"
-DEFAULT_PLUGINS="postr champlain fit-to-width exif-display"
+ALL_PLUGINS="postr champlain fit-to-width exif-display send-by-mail"
+USEFUL_PLUGINS="postr champlain fit-to-width exif-display send-by-mail"
+DEFAULT_PLUGINS="postr champlain fit-to-width exif-display send-by-mail"
PYTHON_ALL_PLUGINS="slideshowshuffle pythonconsole"
PYTHON_USEFUL_PLUGINS="slideshowshuffle pythonconsole"
@@ -353,6 +353,7 @@ plugins/Makefile
plugins/champlain/Makefile
plugins/fit-to-width/Makefile
plugins/exif-display/Makefile
+plugins/send-by-mail/Makefile
plugins/slideshowshuffle/Makefile
plugins/postr/Makefile
plugins/pythonconsole/Makefile
diff --git a/plugins/send-by-mail/Makefile.am b/plugins/send-by-mail/Makefile.am
new file mode 100644
index 0000000..181e7bd
--- /dev/null
+++ b/plugins/send-by-mail/Makefile.am
@@ -0,0 +1,32 @@
+# SendByMail plugin
+plugindir = $(libdir)/eog/plugins
+
+INCLUDES = \
+ -I$(top_srcdir)/src \
+ $(EOG_CFLAGS) \
+ $(WARN_CFLAGS) \
+ -DEOG_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = libsend-by-mail.la
+
+libsend_by_mail_la_SOURCES = \
+ eog-send-by-mail-plugin.h \
+ eog-send-by-mail-plugin.c
+
+libsend_by_mail_la_LDFLAGS = \
+ -avoid-version -module
+
+libsend_by_mail_la_LIBADD = $(EOG_LIBS)
+
+# Plugin Info
+
+plugin_in_files = send-by-mail.eog-plugin.desktop.in
+
+%.eog-plugin: %.eog-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:.eog-plugin.desktop.in=.eog-plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
diff --git a/plugins/send-by-mail/eog-send-by-mail-plugin.c b/plugins/send-by-mail/eog-send-by-mail-plugin.c
new file mode 100644
index 0000000..f5a38a7
--- /dev/null
+++ b/plugins/send-by-mail/eog-send-by-mail-plugin.c
@@ -0,0 +1,177 @@
+/* SendByMail -- Send images per email
+ *
+ * Copyright (C) 2009 The Free Software Foundation
+ *
+ * Author: Felix Riemann <friemann gnome org>
+ *
+ * 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
+ */
+
+#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-send-by-mail-plugin.h"
+
+
+#define WINDOW_DATA_KEY "EogSendByMailWindowData"
+
+EOG_PLUGIN_REGISTER_TYPE(EogSendByMailPlugin, eog_send_by_mail_plugin)
+
+typedef struct
+{
+ GtkActionGroup *ui_action_group;
+ guint ui_menuitem_id;
+} WindowData;
+
+static void free_window_data (WindowData *data);
+static void send_by_mail_cb (GtkAction *action, EogWindow *window);
+
+static const gchar * const ui_definition =
+ "<ui><menubar name=\"MainMenu\">"
+ "<menu name=\"ToolsMenu\" action=\"Tools\">"
+ "<menuitem action=\"EogPluginSendByMail\"/>"
+ "</menu></menubar>"
+ "<popup name=\"ViewPopup\"><separator/>"
+ "<menuitem action=\"EogPluginSendByMail\"/><separator/>"
+ "</popup></ui>";;
+
+static const GtkActionEntry action_entries[] =
+{
+ { "EogPluginSendByMail",
+ "mail-message-new",
+ N_("Send by Mail"),
+ NULL,
+ N_("Send the current image attached to a new mail"),
+ G_CALLBACK (send_by_mail_cb) }
+};
+
+static void
+eog_send_by_mail_plugin_init (EogSendByMailPlugin *plugin)
+{
+}
+
+static void
+impl_activate (EogPlugin *plugin,
+ EogWindow *window)
+{
+ GtkUIManager *manager;
+ WindowData *data;
+
+ manager = eog_window_get_ui_manager (window);
+ data = g_slice_new (WindowData);
+
+ data->ui_action_group = gtk_action_group_new ("EogSendByMailPluginActions");
+
+ 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
+eog_send_by_mail_plugin_class_init (EogSendByMailPluginClass *klass)
+{
+ EogPluginClass *plugin_class = EOG_PLUGIN_CLASS (klass);
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+}
+
+static void
+free_window_data (WindowData *data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_object_unref (data->ui_action_group);
+
+ g_slice_free (WindowData, data);
+}
+
+static void
+send_by_mail_cb (GtkAction *action, EogWindow *window)
+{
+ GdkScreen *screen = NULL;
+ EogImage *img = NULL;
+ GFile *file = NULL;
+ gchar *path = NULL, *uri = NULL;
+
+ g_return_if_fail (EOG_IS_WINDOW (window));
+
+ if (gtk_widget_has_screen (GTK_WIDGET (window)))
+ screen = gtk_widget_get_screen (GTK_WIDGET (window));
+
+ /* Doesn't add a reference to the image! */
+ img = eog_window_get_image (window);
+ g_return_if_fail (img != NULL);
+
+ file = eog_image_get_file (img);
+ if (!file)
+ return;
+
+ path = g_file_get_path (file);
+ uri = g_strdup_printf ("mailto:?attach=%s", path);
+
+ /* TODO: Error handling/reporting? */
+ gtk_show_uri (screen, uri, gtk_get_current_event_time (), NULL);
+
+ g_free (uri);
+ g_free (path);
+ g_object_unref (file);
+}
diff --git a/plugins/send-by-mail/eog-send-by-mail-plugin.h b/plugins/send-by-mail/eog-send-by-mail-plugin.h
new file mode 100644
index 0000000..1f473fb
--- /dev/null
+++ b/plugins/send-by-mail/eog-send-by-mail-plugin.h
@@ -0,0 +1,74 @@
+/* SendByMail -- Send images per email
+ *
+ * Copyright (C) 2009 The Free Software Foundation
+ *
+ * Author: Felix Riemann <friemann gnome org>
+ *
+ * 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
+ */
+
+#ifndef __EOG_SEND_BY_MAIL_PLUGIN_H__
+#define __EOG_SEND_BY_MAIL_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_SEND_BY_MAIL_PLUGIN (eog_send_by_mail_plugin_get_type ())
+#define EOG_SEND_BY_MAIL_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EOG_TYPE_SEND_BY_MAIL_PLUGIN, EogStatusbarDatePlugin))
+#define EOG_SEND_BY_MAIL_PLUGIN_CLASS(k) G_TYPE_CHECK_CLASS_CAST((k), EOG_TYPE_SEND_BY_MAIL_PLUGIN, EogStatusbarDatePluginClass))
+#define EOG_IS_SEND_BY_MAIL_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EOG_TYPE_SEND_BY_MAIL_PLUGIN))
+#define EOG_IS_SEND_BY_MAIL_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EOG_TYPE_SEND_BY_MAIL_PLUGIN))
+#define EOG_SEND_BY_MAIL_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EOG_TYPE_SEND_BY_MAIL_PLUGIN, EogStatusbarDatePluginClass))
+
+/* Private structure type */
+typedef struct _EogSendByMailPluginPrivate EogSendByMailPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _EogSendByMailPlugin EogSendByMailPlugin;
+
+struct _EogSendByMailPlugin
+{
+ EogPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _EogSendByMailPluginClass EogSendByMailPluginClass;
+
+struct _EogSendByMailPluginClass
+{
+ EogPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType eog_send_by_mail_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_SEND_BY_MAIL_PLUGIN_H__ */
diff --git a/plugins/send-by-mail/send-by-mail.eog-plugin.desktop.in b/plugins/send-by-mail/send-by-mail.eog-plugin.desktop.in
new file mode 100644
index 0000000..ed0c454
--- /dev/null
+++ b/plugins/send-by-mail/send-by-mail.eog-plugin.desktop.in
@@ -0,0 +1,9 @@
+[Eog Plugin]
+Module=send-by-mail
+IAge=2
+_Name=Send By Mail
+Icon=mail-send
+_Description=Sends an image attached to a new mail
+Authors=Felix Riemann <friemann gnome org>
+Copyright=Copyright © 2009 Felix Riemann
+Website=http://www.gnome.org/projects/eog
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]