* move widgets/ -> toys/mug2; remove toys/mug; rename toys/mug2 -> toys/mug

This commit is contained in:
djcb
2012-08-03 09:47:09 +03:00
parent b71a27b7c0
commit 2fcdcafe59
34 changed files with 240 additions and 2083 deletions

View File

@ -1,8 +1,8 @@
## Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## 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 3 of the License, or
## t he Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
@ -19,8 +19,9 @@ include $(top_srcdir)/gtest.mk
# enforce compiling this dir first before decending into tests/
SUBDIRS= .
INCLUDES=-I${top_srcdir}/lib $(GTK_CFLAGS) -DICONDIR='"$(icondir)"'
INCLUDES=-I${top_srcdir} -I${top_srcdir}/lib $(GTK_CFLAGS) $(WEBKIT_CFLAGS) \
-DICONDIR='"$(icondir)"' -DMUGDIR='"$(abs_srcdir)"' \
-DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE
# don't use -Werror, as it might break on other compilers
# use -Wno-unused-parameters, because some callbacks may not
@ -28,35 +29,60 @@ INCLUDES=-I${top_srcdir}/lib $(GTK_CFLAGS) -DICONDIR='"$(icondir)"'
AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement
AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
noinst_PROGRAMS= \
noinst_PROGRAMS= \
mug
# note, mug.cc is '.cc' only because libmu must explicitly
# be linked as c++, not c.
mug_SOURCES= \
mug.c \
mug-msg-list-view.c \
mug-msg-list-view.h \
mug-msg-view.h \
mug-msg-view.c \
mug-query-bar.h \
mug-query-bar.c \
mug-shortcuts.c \
mug-shortcuts.h \
mug_SOURCES= \
mug.c \
mug-msg-list-view.c \
mug-msg-list-view.h \
mug-msg-view.h \
mug-msg-view.c \
mug-query-bar.h \
mug-query-bar.c \
mug-shortcuts.c \
mug-shortcuts.h \
dummy.cc
# we need to use dummy.cc to enforce c++ linking...
BUILT_SOURCES= \
BUILT_SOURCES= \
dummy.cc
dummy.cc:
touch dummy.cc
DISTCLEANFILES= \
DISTCLEANFILES= \
$(BUILT_SOURCES)
mug_LDADD= \
${top_builddir}/lib/libmu.la \
mug_LDADD= \
${top_builddir}/lib/libmu.la \
libmuwidgets.la \
${GTK_LIBS}
noinst_LTLIBRARIES= \
libmuwidgets.la
libmuwidgets_la_SOURCES= \
mu-widget-util.h \
mu-widget-util.c \
mu-msg-attach-view.c \
mu-msg-attach-view.h \
mu-msg-body-view.c \
mu-msg-body-view.h \
mu-msg-header-view.c \
mu-msg-header-view.h \
mu-msg-view.h \
mu-msg-view.c
libmuwidgets_la_LIBADD= \
${top_builddir}/lib/libmu.la \
${GTK_LIBS} \
${WEBKIT_LIBS} \
${GIO_LIBS}
EXTRA_DIST= \
mug.svg

View File

@ -0,0 +1,297 @@
/*
** Copyright (C) 2011-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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.
**
*/
#include "mu-msg-attach-view.h"
#include "mu-widget-util.h"
#include <mu-msg-part.h>
enum {
ICON_COL,
NAME_COL,
PARTNUM_COL,
NUM_COL
};
/* 'private'/'protected' functions */
static void mu_msg_attach_view_class_init (MuMsgAttachViewClass *klass);
static void mu_msg_attach_view_init (MuMsgAttachView *obj);
static void mu_msg_attach_view_finalize (GObject *obj);
/* list my signals */
enum {
ATTACH_ACTIVATED,
/* MY_SIGNAL_2, */
LAST_SIGNAL
};
struct _MuMsgAttachViewPrivate {
MuMsg *_msg;
};
#define MU_MSG_ATTACH_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MU_TYPE_MSG_ATTACH_VIEW, \
MuMsgAttachViewPrivate))
/* globals */
static GtkIconViewClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = {0};
G_DEFINE_TYPE (MuMsgAttachView, mu_msg_attach_view, GTK_TYPE_ICON_VIEW);
static void
set_message (MuMsgAttachView *self, MuMsg *msg)
{
if (self->_priv->_msg == msg)
return; /* nothing to todo */
if (self->_priv->_msg) {
mu_msg_unref (self->_priv->_msg);
self->_priv->_msg = NULL;
}
if (msg)
self->_priv->_msg = mu_msg_ref (msg);
}
static void
mu_msg_attach_view_class_init (MuMsgAttachViewClass *klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass*) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = mu_msg_attach_view_finalize;
g_type_class_add_private (gobject_class, sizeof(MuMsgAttachViewPrivate));
signals[ATTACH_ACTIVATED] =
g_signal_new ("attach-activated",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MuMsgAttachViewClass,
attach_activated),
NULL, NULL,
g_cclosure_marshal_VOID__UINT_POINTER,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
}
static void
item_activated (MuMsgAttachView *self, GtkTreePath *tpath)
{
GtkTreeModel *model;
GtkTreeIter iter;
guint partnum;
model = gtk_icon_view_get_model (GTK_ICON_VIEW(self));
if (!gtk_tree_model_get_iter (model, &iter, tpath)) {
g_warning ("could not find path");
}
gtk_tree_model_get (model, &iter,
PARTNUM_COL, &partnum,
-1);
g_signal_emit (G_OBJECT (self),
signals[ATTACH_ACTIVATED], 0,
partnum, self->_priv->_msg);
}
static void
accumulate_parts (MuMsgAttachView *self, GtkTreePath *path, GSList **lst)
{
GtkTreeIter iter;
GtkTreeModel *model;
/* don't unref */
model = gtk_icon_view_get_model (GTK_ICON_VIEW(self));
if (gtk_tree_model_get_iter (model, &iter, path)) {
gchar *filepath;
gint idx;
gtk_tree_model_get (model, &iter, PARTNUM_COL, &idx, -1);
filepath = mu_msg_part_get_cache_path (self->_priv->_msg,
MU_MSG_OPTION_NONE,
idx, NULL);
if (filepath) {
if (mu_msg_part_save (self->_priv->_msg,
MU_MSG_OPTION_USE_EXISTING,
filepath,
idx, NULL)) {
GFile *file;
file = g_file_new_for_path (filepath);
*lst = g_slist_prepend (*lst, g_file_get_uri(file));
g_object_unref (file);
} else
g_warning ("error saving msg part");
g_free (filepath);
}
}
}
static void
on_drag_data_get (MuMsgAttachView *self, GdkDragContext *drag_context,
GtkSelectionData *data, guint info, guint time, gpointer user_data)
{
GSList *lst, *cur;
char **uris;
int i;
lst = NULL;
gtk_icon_view_selected_foreach (GTK_ICON_VIEW(self),
(GtkIconViewForeachFunc)accumulate_parts,
&lst);
uris = g_new(char*, g_slist_length(lst) + 1);
for (cur = lst, i = 0; cur; cur = g_slist_next(cur))
uris[i++] = (gchar*)cur->data;
uris[i] = NULL;
gtk_selection_data_set_uris (data, uris);
g_free (uris);
g_slist_foreach (lst, (GFunc)g_free, NULL);
g_slist_free (lst);
}
static void
mu_msg_attach_view_init (MuMsgAttachView *obj)
{
GtkListStore *store;
obj->_priv = MU_MSG_ATTACH_VIEW_GET_PRIVATE(obj);
obj->_priv->_msg = NULL;
store = gtk_list_store_new (NUM_COL,GDK_TYPE_PIXBUF,
G_TYPE_STRING, G_TYPE_UINT);
gtk_icon_view_set_model (GTK_ICON_VIEW(obj), GTK_TREE_MODEL(store));
g_object_unref (store);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW(obj), ICON_COL);
gtk_icon_view_set_text_column (GTK_ICON_VIEW(obj), NAME_COL);
gtk_icon_view_set_margin (GTK_ICON_VIEW(obj), 0);
gtk_icon_view_set_spacing (GTK_ICON_VIEW(obj), 0);
gtk_icon_view_set_item_padding (GTK_ICON_VIEW(obj), 0);
/* note: only since GTK+ 2.22 */
/* gtk_icon_view_set_item_orientation (GTK_ICON_VIEW(obj), */
/* GTK_ORIENTATION_HORIZONTAL); */
g_signal_connect (G_OBJECT(obj), "item-activated",
G_CALLBACK(item_activated), NULL);
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW(obj),
GTK_SELECTION_MULTIPLE);
/* drag & drop */
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW(obj), 0, NULL, 0,
GDK_ACTION_COPY);
gtk_drag_source_add_uri_targets(GTK_WIDGET(obj));
g_signal_connect (obj, "drag-data-get", G_CALLBACK(on_drag_data_get), NULL);
}
static void
mu_msg_attach_view_finalize (GObject *obj)
{
set_message (MU_MSG_ATTACH_VIEW(obj), NULL);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GtkWidget*
mu_msg_attach_view_new (void)
{
return GTK_WIDGET(g_object_new(MU_TYPE_MSG_ATTACH_VIEW, NULL));
}
struct _CBData {
GtkListStore *store;
guint count;
};
typedef struct _CBData CBData;
static void
each_part (MuMsg *msg, MuMsgPart *part, CBData *cbdata)
{
GtkTreeIter treeiter;
GdkPixbuf *pixbuf;
char ctype[128];
if (!mu_msg_part_looks_like_attachment(part, FALSE))
return;
if (!part->type || !part->subtype)
snprintf (ctype, sizeof(ctype), "%s",
"application/octet-stream");
else
snprintf (ctype, sizeof(ctype), "%s/%s",
part->type, part->subtype);
pixbuf = mu_widget_util_get_icon_pixbuf_for_content_type (ctype, 16);
if (!pixbuf) {
g_warning ("%s: could not get icon pixbuf for '%s'",
__FUNCTION__, ctype);
pixbuf = mu_widget_util_get_icon_pixbuf_for_content_type
("application/octet-stream", 16);
}
gtk_list_store_append (cbdata->store, &treeiter);
gtk_list_store_set (cbdata->store, &treeiter,
NAME_COL, mu_msg_part_get_filename (part, TRUE),
ICON_COL, pixbuf,
PARTNUM_COL, part->index,
-1);
if (pixbuf)
g_object_unref (pixbuf);
++cbdata->count;
}
gint
mu_msg_attach_view_set_message (MuMsgAttachView *self, MuMsg *msg)
{
GtkListStore *store;
CBData cbdata;
g_return_val_if_fail (MU_IS_MSG_ATTACH_VIEW(self), -1);
store = GTK_LIST_STORE (gtk_icon_view_get_model (GTK_ICON_VIEW(self)));
gtk_list_store_clear (store);
set_message (self, msg);
if (!msg)
return 0;
cbdata.store = store;
cbdata.count = 0;
mu_msg_part_foreach (msg, MU_MSG_OPTION_NONE,
(MuMsgPartForeachFunc)each_part, &cbdata);
return cbdata.count;
}

View File

@ -0,0 +1,67 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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 __MU_MSG_ATTACH_VIEW_H__
#define __MU_MSG_ATTACH_VIEW_H__
#include <gtk/gtk.h>
#include <mu-msg.h>
G_BEGIN_DECLS
/* convenience macros */
#define MU_TYPE_MSG_ATTACH_VIEW (mu_msg_attach_view_get_type())
#define MU_MSG_ATTACH_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MU_TYPE_MSG_ATTACH_VIEW,MuMsgAttachView))
#define MU_MSG_ATTACH_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MU_TYPE_MSG_ATTACH_VIEW,MuMsgAttachViewClass))
#define MU_IS_MSG_ATTACH_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MU_TYPE_MSG_ATTACH_VIEW))
#define MU_IS_MSG_ATTACH_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MU_TYPE_MSG_ATTACH_VIEW))
#define MU_MSG_ATTACH_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MU_TYPE_MSG_ATTACH_VIEW,MuMsgAttachViewClass))
typedef struct _MuMsgAttachView MuMsgAttachView;
typedef struct _MuMsgAttachViewClass MuMsgAttachViewClass;
typedef struct _MuMsgAttachViewPrivate MuMsgAttachViewPrivate;
struct _MuMsgAttachView {
GtkIconView parent;
/* insert public members, if any */
/* private */
MuMsgAttachViewPrivate *_priv;
};
struct _MuMsgAttachViewClass {
GtkIconViewClass parent_class;
void (* attach_activated) (MuMsgAttachView* obj, guint partnum,
MuMsg *msg);
};
/* member functions */
GType mu_msg_attach_view_get_type (void) G_GNUC_CONST;
/* parameter-less _new function (constructor) */
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
GtkWidget* mu_msg_attach_view_new (void);
/* returns # of attachments */
int mu_msg_attach_view_set_message (MuMsgAttachView *self, MuMsg *msg);
G_END_DECLS
#endif /* __MU_MSG_ATTACH_VIEW_H__ */

400
toys/mug/mu-msg-body-view.c Normal file
View File

@ -0,0 +1,400 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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.
**
*/
#include <webkit/webkitwebview.h>
#include <webkit/webkitnetworkresponse.h>
#include <webkit/webkitwebnavigationaction.h>
#include <webkit/webkitwebpolicydecision.h>
#include "mu-msg-body-view.h"
#include <mu-msg-part.h>
enum _ViewMode {
VIEW_MODE_MSG,
VIEW_MODE_SOURCE,
VIEW_MODE_NOTE,
VIEW_MODE_NONE
};
typedef enum _ViewMode ViewMode;
/* 'private'/'protected' functions */
static void mu_msg_body_view_class_init (MuMsgBodyViewClass *klass);
static void mu_msg_body_view_init (MuMsgBodyView *obj);
static void mu_msg_body_view_finalize (GObject *obj);
/* list my signals */
enum {
ACTION_REQUESTED,
/* MY_SIGNAL_2, */
LAST_SIGNAL
};
struct _MuMsgBodyViewPrivate {
WebKitWebSettings *_settings;
MuMsg *_msg;
ViewMode _view_mode;
};
#define MU_MSG_BODY_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MU_TYPE_MSG_BODY_VIEW, \
MuMsgBodyViewPrivate))
/* globals */
static WebKitWebViewClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = {0};
G_DEFINE_TYPE (MuMsgBodyView, mu_msg_body_view, WEBKIT_TYPE_WEB_VIEW);
static void
set_message (MuMsgBodyView *self, MuMsg *msg)
{
if (self->_priv->_msg == msg)
return; /* nothing to todo */
if (self->_priv->_msg) {
mu_msg_unref (self->_priv->_msg);
self->_priv->_msg = NULL;
}
if (msg)
self->_priv->_msg = mu_msg_ref (msg);
}
static void
mu_msg_body_view_class_init (MuMsgBodyViewClass *klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass*) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = mu_msg_body_view_finalize;
g_type_class_add_private (gobject_class, sizeof(MuMsgBodyViewPrivate));
signals[ACTION_REQUESTED] =
g_signal_new ("action-requested",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MuMsgBodyViewClass,
action_requested),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
}
static char*
save_file_for_cid (MuMsg *msg, const char* cid)
{
gint idx;
gchar *filepath;
gboolean rv;
GError *err;
g_return_val_if_fail (msg, NULL);
g_return_val_if_fail (cid, NULL);
idx = mu_msg_find_index_for_cid (msg, MU_MSG_OPTION_NONE, cid);
if (idx < 0) {
g_warning ("%s: cannot find %s", __FUNCTION__, cid);
return NULL;
}
filepath = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE, idx, NULL);
if (!filepath) {
g_warning ("%s: cannot create filepath", filepath);
return NULL;
}
err = NULL;
rv = mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING,
filepath, idx, &err);
if (!rv) {
g_warning ("%s: failed to save %s: %s", __FUNCTION__, filepath,
err&&err->message?err->message:"error");
g_clear_error (&err);
g_free (filepath);
filepath = NULL;
}
return filepath;
}
static gboolean
on_navigation_policy_decision_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
WebKitNetworkRequest *request,
WebKitWebNavigationAction *nav_action,
WebKitWebPolicyDecision *policy_decision,
gpointer data)
{
const char* uri;
WebKitWebNavigationReason reason;
uri = webkit_network_request_get_uri (request);
reason = webkit_web_navigation_action_get_reason (nav_action);
/* if it wasn't a user click, don't the navigation */
if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
webkit_web_policy_decision_ignore (policy_decision);
return TRUE;
}
/* we handle links clicked ourselves, no need for navigation */
webkit_web_policy_decision_ignore (policy_decision);
/* if there are 'cmd:<action>" links in the body text of
* mu-internal messages (ie., notification from mu, not real
* e-mail messages), we emit the 'action requested'
* signal. this allows e.g triggering a database refresh from
* a <a href="cmd:refresh">Refresh</a> link
*/
if (g_ascii_strncasecmp (uri, "cmd:", 4) == 0) {
if (self->_priv->_view_mode == VIEW_MODE_NOTE) {
g_signal_emit (G_OBJECT(self),
signals[ACTION_REQUESTED], 0,
uri + 4);
}
return TRUE;
}
/* don't try to play files on our local file system, this is not something
* external content should do.*/
if (!mu_util_is_local_file(uri))
mu_util_play (uri, FALSE, TRUE, NULL);
return TRUE;
}
static void
on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame,
WebKitWebResource *resource, WebKitNetworkRequest *request,
WebKitNetworkResponse *response, gpointer data)
{
const char* uri;
MuMsg *msg;
msg = self->_priv->_msg;
uri = webkit_network_request_get_uri (request);
/* g_warning ("%s: %s", __FUNCTION__, uri); */
if (g_ascii_strncasecmp (uri, "cid:", 4) == 0) {
gchar *filepath;
filepath = save_file_for_cid (msg, uri);
if (filepath) {
gchar *fileuri;
fileuri = g_strdup_printf ("file://%s", filepath);
webkit_network_request_set_uri (request, fileuri);
g_free (fileuri);
g_free (filepath);
}
}
}
static void
on_menu_item_activate (GtkMenuItem *item, MuMsgBodyView *self)
{
g_signal_emit (G_OBJECT(self),
signals[ACTION_REQUESTED], 0,
g_object_get_data (G_OBJECT(item), "action"));
}
static void
popup_menu (MuMsgBodyView *self, guint button, guint32 activate_time)
{
GtkWidget *menu;
int i;
struct {
const char* title;
const char* action;
ViewMode mode;
} actions[] = {
{ "View source...", "view-source", VIEW_MODE_MSG },
{ "View message...", "view-message", VIEW_MODE_SOURCE },
};
menu = gtk_menu_new ();
for (i = 0; i != G_N_ELEMENTS(actions); ++i) {
GtkWidget *item;
if (self->_priv->_view_mode != actions[i].mode)
continue;
item = gtk_menu_item_new_with_label(actions[i].title);
g_object_set_data (G_OBJECT(item), "action", (gpointer)actions[i].action);
g_signal_connect (item, "activate", G_CALLBACK(on_menu_item_activate),
self);
gtk_menu_attach (GTK_MENU(menu), item, 0, 1, i, i+1);
gtk_widget_show (item);
}
gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, 0);
}
static gboolean
on_button_press_event (MuMsgBodyView *self, GdkEventButton *event, gpointer data)
{
/* ignore all but the first (typically, left) mouse button */
switch (event->button) {
case 1: return FALSE; /* propagate, let widget handle it */
case 3:
/* no popup menus for notes */
if (self->_priv->_view_mode != VIEW_MODE_NOTE)
popup_menu (self, event->button, event->time);
break;
default: return TRUE; /* ignore */
}
return (event->button > 1) ? TRUE : FALSE;
}
static void
mu_msg_body_view_init (MuMsgBodyView *obj)
{
obj->_priv = MU_MSG_BODY_VIEW_GET_PRIVATE(obj);
obj->_priv->_msg = NULL;
obj->_priv->_view_mode = VIEW_MODE_NONE;
obj->_priv->_settings = webkit_web_settings_new ();
g_object_set (G_OBJECT(obj->_priv->_settings),
"enable-scripts", FALSE,
"auto-load-images", TRUE,
"enable-plugins", FALSE,
NULL);
webkit_web_view_set_settings (WEBKIT_WEB_VIEW(obj),
obj->_priv->_settings);
webkit_web_view_set_editable (WEBKIT_WEB_VIEW(obj), FALSE);
/* to support cid: */
g_signal_connect (obj, "resource-request-starting",
G_CALLBACK (on_resource_request_starting), NULL);
/* handle navigation requests */
g_signal_connect (obj, "navigation-policy-decision-requested",
G_CALLBACK (on_navigation_policy_decision_requested), NULL);
/* handle right-button clicks */
g_signal_connect (obj, "button-press-event",
G_CALLBACK(on_button_press_event), NULL);
}
static void
mu_msg_body_view_finalize (GObject *obj)
{
MuMsgBodyViewPrivate *priv;
priv = MU_MSG_BODY_VIEW_GET_PRIVATE(obj);
if (priv && priv->_settings)
g_object_unref (priv->_settings);
set_message (MU_MSG_BODY_VIEW(obj), NULL);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GtkWidget*
mu_msg_body_view_new (void)
{
return GTK_WIDGET(g_object_new(MU_TYPE_MSG_BODY_VIEW, NULL));
}
void
set_html (MuMsgBodyView *self, const char* html)
{
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
webkit_web_view_load_string (WEBKIT_WEB_VIEW(self),
html ? html : "",
"text/html",
"utf-8",
"");
}
static void
set_text (MuMsgBodyView *self, const char* txt)
{
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
webkit_web_view_load_string (WEBKIT_WEB_VIEW(self),
txt ? txt : "",
"text/plain",
"utf-8",
"");
}
void
mu_msg_body_view_set_message (MuMsgBodyView *self, MuMsg *msg)
{
const char* data;
g_return_if_fail (self);
set_message (self, msg);
data = msg ? mu_msg_get_body_html (msg) : "";
if (data)
set_html (self, data);
else
set_text (self, mu_msg_get_body_text (msg));
self->_priv->_view_mode = VIEW_MODE_MSG;
}
void
mu_msg_body_view_set_message_source (MuMsgBodyView *self, MuMsg *msg)
{
const gchar *path;
gchar *data;
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
g_return_if_fail (msg);
set_message (self, NULL);
path = msg ? mu_msg_get_path (msg) : NULL;
if (path && g_file_get_contents (path, &data, NULL, NULL)) {
set_text (self, data);
g_free (data);
} else
set_text (self, "");
self->_priv->_view_mode = VIEW_MODE_SOURCE;
}
void
mu_msg_body_view_set_note (MuMsgBodyView *self, const gchar *html)
{
g_return_if_fail (self);
g_return_if_fail (html);
set_message (self, NULL);
set_html (self, html);
self->_priv->_view_mode = VIEW_MODE_NOTE;
}

View File

@ -0,0 +1,70 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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 __MU_MSG_BODY_VIEW_H__
#define __MU_MSG_BODY_VIEW_H__
#include <webkit/webkitwebview.h>
#include <mu-msg.h>
G_BEGIN_DECLS
/* convenience macros */
#define MU_TYPE_MSG_BODY_VIEW (mu_msg_body_view_get_type())
#define MU_MSG_BODY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MU_TYPE_MSG_BODY_VIEW,MuMsgBodyView))
#define MU_MSG_BODY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MU_TYPE_MSG_BODY_VIEW,MuMsgBodyViewClass))
#define MU_IS_MSG_BODY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MU_TYPE_MSG_BODY_VIEW))
#define MU_IS_MSG_BODY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MU_TYPE_MSG_BODY_VIEW))
#define MU_MSG_BODY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MU_TYPE_MSG_BODY_VIEW,MuMsgBodyViewClass))
typedef struct _MuMsgBodyView MuMsgBodyView;
typedef struct _MuMsgBodyViewClass MuMsgBodyViewClass;
typedef struct _MuMsgBodyViewPrivate MuMsgBodyViewPrivate;
struct _MuMsgBodyView {
WebKitWebView parent;
/* insert public members, if any */
/* private */
MuMsgBodyViewPrivate *_priv;
};
struct _MuMsgBodyViewClass {
WebKitWebViewClass parent_class;
/* supported actions: "reindex", "view-source" */
void (* action_requested) (MuMsgBodyView* self, const char* action);
};
/* member functions */
GType mu_msg_body_view_get_type (void) G_GNUC_CONST;
/* parameter-less _new function (constructor) */
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
GtkWidget* mu_msg_body_view_new (void);
void mu_msg_body_view_set_message (MuMsgBodyView *self, MuMsg *msg);
void mu_msg_body_view_set_note (MuMsgBodyView *self, const gchar *html);
void mu_msg_body_view_set_message_source (MuMsgBodyView *self, MuMsg *msg);
G_END_DECLS
#endif /* __MU_MSG_BODY_VIEW_H__ */

View File

@ -0,0 +1,204 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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.
**
*/
#include "mu-msg-header-view.h"
#include <mu-str.h>
#include <mu-date.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
/* 'private'/'protected' functions */
static void mu_msg_header_view_class_init (MuMsgHeaderViewClass *klass);
static void mu_msg_header_view_init (MuMsgHeaderView *obj);
static void mu_msg_header_view_finalize (GObject *obj);
/* list my signals */
enum {
/* MY_SIGNAL_1, */
/* MY_SIGNAL_2, */
LAST_SIGNAL
};
struct _MuMsgHeaderViewPrivate {
GtkWidget *_table;
};
#define MU_MSG_HEADER_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MU_TYPE_MSG_HEADER_VIEW, \
MuMsgHeaderViewPrivate))
/* globals */
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
#else
static GtkVBoxClass *parent_class = NULL;
#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
#ifdef HAVE_GTK3
G_DEFINE_TYPE (MuMsgHeaderView, mu_msg_header_view, GTK_TYPE_BOX);
#else
G_DEFINE_TYPE (MuMsgHeaderView, mu_msg_header_view, GTK_TYPE_VBOX);
#endif /*!HAVE_GTK3*/
static void
mu_msg_header_view_class_init (MuMsgHeaderViewClass *klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass*) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = mu_msg_header_view_finalize;
g_type_class_add_private (gobject_class, sizeof(MuMsgHeaderViewPrivate));
/* signal definitions go here, e.g.: */
/* signals[MY_SIGNAL_1] = */
/* g_signal_new ("my_signal_1",....); */
/* signals[MY_SIGNAL_2] = */
/* g_signal_new ("my_signal_2",....); */
/* etc. */
}
static void
mu_msg_header_view_init (MuMsgHeaderView *obj)
{
/* #ifdef HAVE_GTK3 */
/* static GtkBoxClass *parent_class = NULL; */
/* #endif /\*!HAVE_GTK3*\/ */
obj->_priv = MU_MSG_HEADER_VIEW_GET_PRIVATE(obj);
obj->_priv->_table = NULL;
}
static void
mu_msg_header_view_finalize (GObject *obj)
{
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GtkWidget*
mu_msg_header_view_new (void)
{
return GTK_WIDGET(g_object_new(MU_TYPE_MSG_HEADER_VIEW, NULL));
}
static GtkWidget*
get_label (const gchar *txt, gboolean istitle)
{
GtkWidget *label;
label = gtk_label_new (NULL);
if (istitle) {
char* markup;
markup = g_strdup_printf ("<b>%s</b>: ", txt);
gtk_label_set_markup (GTK_LABEL(label), markup);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
g_free (markup);
} else {
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
gtk_label_set_text (GTK_LABEL(label), txt ? txt : "");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
}
return label;
}
static gboolean
add_row (GtkWidget *table, guint row, const char* fieldname, const char *value,
gboolean showempty)
{
GtkWidget *label, *al;
if (!value && !showempty)
return FALSE;
label = get_label (fieldname, TRUE);
al = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (al), label);
gtk_table_attach (
GTK_TABLE(table), al,
0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
al = gtk_alignment_new (0.0, 1.0, 0.0, 0.0);
label = get_label (value, FALSE);
gtk_container_add (GTK_CONTAINER (al), label);
gtk_table_attach (
GTK_TABLE(table), al, 1, 2, row, row + 1, GTK_FILL,
0, 0, 0);
return TRUE;
}
GtkWidget *
get_table (MuMsg *msg)
{
GtkWidget *table;
int row;
row = 0;
table = gtk_table_new (5, 2, FALSE);
if (add_row (table, row, "From", mu_msg_get_from (msg), TRUE))
++row;
if (add_row (table, row, "To", mu_msg_get_to (msg), FALSE))
++row;
if (add_row (table, row, "Cc", mu_msg_get_cc (msg), FALSE))
++row;
if (add_row (table, row, "Subject", mu_msg_get_subject (msg), TRUE))
++row;
if (add_row (table, row, "Date", mu_date_str_s
("%c", mu_msg_get_date (msg)),TRUE))
++row;
gtk_table_resize (GTK_TABLE(table), row, 2);
return table;
}
void
mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg)
{
g_return_if_fail (MU_IS_MSG_HEADER_VIEW(self));
if (self->_priv->_table) {
gtk_container_remove (GTK_CONTAINER(self), self->_priv->_table);
self->_priv->_table = NULL;
}
if (msg) {
self->_priv->_table = get_table (msg);
gtk_box_pack_start (GTK_BOX(self), self->_priv->_table,
TRUE, TRUE, 0);
gtk_widget_show_all (self->_priv->_table);
}
}

View File

@ -0,0 +1,79 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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 __MU_MSG_HEADER_VIEW_H__
#define __MU_MSG_HEADER_VIEW_H__
#include <gtk/gtk.h>
#include <mu-msg.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
G_BEGIN_DECLS
/* convenience macros */
#define MU_TYPE_MSG_HEADER_VIEW (mu_msg_header_view_get_type())
#define MU_MSG_HEADER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MU_TYPE_MSG_HEADER_VIEW,MuMsgHeaderView))
#define MU_MSG_HEADER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MU_TYPE_MSG_HEADER_VIEW,MuMsgHeaderViewClass))
#define MU_IS_MSG_HEADER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MU_TYPE_MSG_HEADER_VIEW))
#define MU_IS_MSG_HEADER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MU_TYPE_MSG_HEADER_VIEW))
#define MU_MSG_HEADER_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MU_TYPE_MSG_HEADER_VIEW,MuMsgHeaderViewClass))
typedef struct _MuMsgHeaderView MuMsgHeaderView;
typedef struct _MuMsgHeaderViewClass MuMsgHeaderViewClass;
typedef struct _MuMsgHeaderViewPrivate MuMsgHeaderViewPrivate;
struct _MuMsgHeaderView {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
#endif /*!HAVE_GTK3*/
/* insert public members, if any */
/* private */
MuMsgHeaderViewPrivate *_priv;
};
struct _MuMsgHeaderViewClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* insert signal callback declarations, e.g. */
/* void (* my_event) (MuMsgHeaderView* obj); */
};
/* member functions */
GType mu_msg_header_view_get_type (void) G_GNUC_CONST;
/* parameter-less _new function (constructor) */
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
GtkWidget* mu_msg_header_view_new (void);
void mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg);
G_END_DECLS
#endif /* __MU_MSG_HEADER_VIEW_H__ */

251
toys/mug/mu-msg-view.c Normal file
View File

@ -0,0 +1,251 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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 /*HAVE_CONFIG_H*/
#include "mu-msg-view.h"
#include "mu-msg-body-view.h"
#include "mu-msg-header-view.h"
#include "mu-msg-attach-view.h"
#include <mu-msg-part.h>
/* 'private'/'protected' functions */
static void mu_msg_view_class_init (MuMsgViewClass *klass);
static void mu_msg_view_init (MuMsgView *obj);
static void mu_msg_view_finalize (GObject *obj);
/* list my signals */
enum {
/* MY_SIGNAL_1, */
/* MY_SIGNAL_2, */
LAST_SIGNAL
};
struct _MuMsgViewPrivate {
GtkWidget *_headers, *_attach, *_attachexpander, *_body;
MuMsg *_msg;
};
#define MU_MSG_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MU_TYPE_MSG_VIEW, \
MuMsgViewPrivate))
/* globals */
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
#else
static GtkVBoxClass *parent_class = NULL;
#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
#ifdef HAVE_GTK3
G_DEFINE_TYPE (MuMsgView, mu_msg_view, GTK_TYPE_BOX);
#else
G_DEFINE_TYPE (MuMsgView, mu_msg_view, GTK_TYPE_VBOX);
#endif /*HAVE_GTK3*/
static void
set_message (MuMsgView *self, MuMsg *msg)
{
if (self->_priv->_msg == msg)
return; /* nothing to todo */
if (self->_priv->_msg) {
mu_msg_unref (self->_priv->_msg);
self->_priv->_msg = NULL;
}
if (msg)
self->_priv->_msg = mu_msg_ref (msg);
}
static void
mu_msg_view_class_init (MuMsgViewClass *klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass*) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = mu_msg_view_finalize;
g_type_class_add_private (gobject_class, sizeof(MuMsgViewPrivate));
/* signal definitions go here, e.g.: */
/* signals[MY_SIGNAL_1] = */
/* g_signal_new ("my_signal_1",....); */
/* signals[MY_SIGNAL_2] = */
/* g_signal_new ("my_signal_2",....); */
/* etc. */
}
static void
on_body_action_requested (GtkWidget *w, const char* action,
MuMsgView *self)
{
if (g_strcmp0 (action, "view-source") == 0) {
if (self->_priv->_msg)
mu_msg_view_set_message_source (self, self->_priv->_msg);
} else if (g_strcmp0 (action, "view-message") == 0) {
if (self->_priv->_msg)
mu_msg_view_set_message (self, self->_priv->_msg);
} else if (g_strcmp0 (action, "reindex") == 0)
g_warning ("reindex");
else
g_warning ("unknown action '%s'", action);
}
static void
on_attach_activated (GtkWidget *w, guint partnum, MuMsg *msg)
{
gchar *filepath;
GError *err;
err = NULL;
filepath = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE, partnum,
&err);
if (!filepath) {
g_warning ("failed to get cache path: %s",
err&&err->message?err->message:"error");
g_clear_error (&err);
return;
}
if (!mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING,
filepath, partnum, &err)) {
g_warning ("failed to save %s: %s", filepath,
err&&err->message?err->message:"error");
g_clear_error (&err);
return;
} else
mu_util_play (filepath, TRUE, FALSE, NULL);
g_free (filepath);
}
static void
mu_msg_view_init (MuMsgView *self)
{
self->_priv = MU_MSG_VIEW_GET_PRIVATE(self);
self->_priv->_msg = NULL;
self->_priv->_headers = mu_msg_header_view_new ();
self->_priv->_attach = mu_msg_attach_view_new ();
self->_priv->_attachexpander = gtk_expander_new_with_mnemonic
("_Attachments");
gtk_container_add (GTK_CONTAINER(self->_priv->_attachexpander),
self->_priv->_attach);
g_signal_connect (self->_priv->_attach, "attach-activated",
G_CALLBACK(on_attach_activated),
self);
self->_priv->_body = mu_msg_body_view_new ();
g_signal_connect (self->_priv->_body,
"action-requested",
G_CALLBACK(on_body_action_requested),
self);
gtk_box_pack_start (GTK_BOX(self), self->_priv->_headers,
FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX(self), self->_priv->_attachexpander,
FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX(self), self->_priv->_body,
TRUE, TRUE, 2);
}
static void
mu_msg_view_finalize (GObject *obj)
{
set_message (MU_MSG_VIEW (obj), NULL);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GtkWidget*
mu_msg_view_new (void)
{
return GTK_WIDGET(g_object_new(MU_TYPE_MSG_VIEW, NULL));
}
void
mu_msg_view_set_message (MuMsgView *self, MuMsg *msg)
{
gint attachnum;
g_return_if_fail (MU_IS_MSG_VIEW(self));
set_message (self, msg);
mu_msg_header_view_set_message (MU_MSG_HEADER_VIEW(self->_priv->_headers),
msg);
attachnum = mu_msg_attach_view_set_message (MU_MSG_ATTACH_VIEW(self->_priv->_attach),
msg);
mu_msg_body_view_set_message (MU_MSG_BODY_VIEW(self->_priv->_body),
msg);
gtk_widget_set_visible (self->_priv->_headers, TRUE);
gtk_widget_set_visible (self->_priv->_attachexpander, attachnum > 0);
gtk_widget_set_visible (self->_priv->_body, TRUE);
}
void
mu_msg_view_set_message_source (MuMsgView *self, MuMsg *msg)
{
g_return_if_fail (MU_IS_MSG_VIEW(self));
set_message (self, msg);
mu_msg_body_view_set_message_source (MU_MSG_BODY_VIEW(self->_priv->_body),
msg);
gtk_widget_set_visible (self->_priv->_headers, FALSE);
gtk_widget_set_visible (self->_priv->_attachexpander, FALSE);
gtk_widget_set_visible (self->_priv->_body, TRUE);
}
void
mu_msg_view_set_note (MuMsgView *self, const gchar* html)
{
g_return_if_fail (MU_IS_MSG_VIEW(self));
gtk_widget_set_visible (self->_priv->_headers, FALSE);
gtk_widget_set_visible (self->_priv->_attachexpander, FALSE);
gtk_widget_set_visible (self->_priv->_body, TRUE);
mu_msg_body_view_set_note (MU_MSG_BODY_VIEW(self->_priv->_body),
html);
}

77
toys/mug/mu-msg-view.h Normal file
View File

@ -0,0 +1,77 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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 __MU_MSG_VIEW_H__
#define __MU_MSG_VIEW_H__
#include <gtk/gtk.h>
#include <mu-msg.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
G_BEGIN_DECLS
/* convenience macros */
#define MU_TYPE_MSG_VIEW (mu_msg_view_get_type())
#define MU_MSG_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MU_TYPE_MSG_VIEW,MuMsgView))
#define MU_MSG_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MU_TYPE_MSG_VIEW,MuMsgViewClass))
#define MU_IS_MSG_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MU_TYPE_MSG_VIEW))
#define MU_IS_MSG_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MU_TYPE_MSG_VIEW))
#define MU_MSG_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MU_TYPE_MSG_VIEW,MuMsgViewClass))
typedef struct _MuMsgView MuMsgView;
typedef struct _MuMsgViewClass MuMsgViewClass;
typedef struct _MuMsgViewPrivate MuMsgViewPrivate;
struct _MuMsgView {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
#endif /*!HAVE_GTK3*/
/* private */
MuMsgViewPrivate *_priv;
};
struct _MuMsgViewClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* void (* my_event) (MuMsgView* obj); */
};
/* member functions */
GType mu_msg_view_get_type (void) G_GNUC_CONST;
/* parameter-less _new function (constructor) */
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
GtkWidget* mu_msg_view_new (void);
void mu_msg_view_set_message (MuMsgView *self, MuMsg *msg);
void mu_msg_view_set_note (MuMsgView *self, const gchar* html);
void mu_msg_view_set_message_source (MuMsgView *self, MuMsg *msg);
G_END_DECLS
#endif /* __MU_MSG_VIEW_H__ */

89
toys/mug/mu-widget-util.c Normal file
View File

@ -0,0 +1,89 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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.
**
*/
#include <gtk/gtk.h>
#include <gio/gio.h>
#include "mu-widget-util.h"
static const char*
second_guess_content_type (const char *ctype)
{
int i;
struct {
const char *orig, *subst;
} substtable [] = {
{"text", "text/plain"},
{"image/pjpeg", "image/jpeg" }
};
for (i = 0; i != G_N_ELEMENTS(substtable); ++i)
if (g_str_has_prefix (ctype, substtable[i].orig))
return substtable[i].subst;
return "application/octet-stream";
}
static GdkPixbuf*
get_icon_pixbuf_for_content_type (const char *ctype, size_t size)
{
GIcon *icon;
GdkPixbuf *pixbuf;
icon = g_content_type_get_icon (ctype);
pixbuf = NULL;
/* based on a snippet from http://www.gtkforums.com/about4721.html */
if (G_IS_THEMED_ICON(icon)) {
gchar const * const *names;
names = g_themed_icon_get_names (G_THEMED_ICON(icon));
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
*names, size, 0, NULL);
} else if (G_IS_FILE_ICON(icon)) {
GFile *icon_file;
gchar *path;
icon_file = g_file_icon_get_file (G_FILE_ICON(icon));
path = g_file_get_path (icon_file);
pixbuf = gdk_pixbuf_new_from_file_at_size (path, size, size, NULL);
g_free (path);
g_object_unref(icon_file);
}
g_object_unref(icon);
return pixbuf;
}
GdkPixbuf*
mu_widget_util_get_icon_pixbuf_for_content_type (const char *ctype, size_t size)
{
GdkPixbuf *pixbuf;
g_return_val_if_fail (ctype, NULL);
g_return_val_if_fail (size > 0, NULL);
pixbuf = get_icon_pixbuf_for_content_type (ctype, size);
if (!pixbuf)
pixbuf = get_icon_pixbuf_for_content_type
(second_guess_content_type (ctype), size);
return pixbuf;
}

39
toys/mug/mu-widget-util.h Normal file
View File

@ -0,0 +1,39 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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 __MU_WIDGET_UTIL_H__
#define __MU_WIDGET_UTIL_H__
#include <gdk-pixbuf/gdk-pixbuf.h>
/**
* get a pixbuf (icon) for a certain content-type (ie., 'image/jpeg')
*
* @param ctype the content-type (MIME-type)
* @param size the size of the icon
*
* @return a new GdkPixbuf, or NULL in case of error. Use
* g_object_unref when the pixbuf is no longer needed.
*/
GdkPixbuf* mu_widget_util_get_icon_pixbuf_for_content_type (const char *ctype,
size_t size)
G_GNUC_WARN_UNUSED_RESULT;
#endif /*__MU_WIDGET_UTIL_H__*/

View File

@ -1,6 +1,6 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/*
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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
@ -22,6 +22,7 @@
#include "mu-query.h"
#include "mu-str.h"
#include "mu-date.h"
#include "mu-threader.h"
/* 'private'/'protected' functions */
static void mug_msg_list_view_class_init (MugMsgListViewClass * klass);
@ -51,7 +52,7 @@ enum {
typedef struct _MugMsgListViewPrivate MugMsgListViewPrivate;
struct _MugMsgListViewPrivate {
GtkListStore *_store;
GtkTreeStore *_store;
char *_xpath;
char *_query;
};
@ -158,10 +159,9 @@ append_col (GtkTreeView * treeview, const char *label, int colidx,
if (sortcolidx == -1)
sortcolidx = colidx;
gtk_tree_view_column_set_sort_column_id (col, sortcolidx);
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
if (maxwidth) {
gtk_tree_view_column_set_sizing (col,
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (col, maxwidth);
gtk_tree_view_column_set_expand (col, FALSE);
} else
@ -172,6 +172,9 @@ append_col (GtkTreeView * treeview, const char *label, int colidx,
treecell_func, NULL, NULL);
gtk_tree_view_append_column (treeview, col);
gtk_tree_view_columns_autosize (treeview);
gtk_tree_view_set_fixed_height_mode (treeview, TRUE);
}
static void
@ -183,13 +186,13 @@ mug_msg_list_view_init (MugMsgListView * obj)
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (obj);
priv->_xpath = priv->_query = NULL;
priv->_store = gtk_list_store_new (MUG_N_COLS, G_TYPE_STRING, /* date */
G_TYPE_STRING, /* folder */
G_TYPE_STRING, /* flagstr */
G_TYPE_STRING, /* from */
G_TYPE_STRING, /* to */
G_TYPE_STRING, /* subject */
G_TYPE_STRING, /* path */
priv->_store = gtk_tree_store_new (MUG_N_COLS, G_TYPE_STRING, /* date */
G_TYPE_STRING,/* folder */
G_TYPE_STRING,/* flagstr */
G_TYPE_STRING, /* from */
G_TYPE_STRING,/* to */
G_TYPE_STRING,/* subject */
G_TYPE_STRING, /* path */
G_TYPE_UINT, /* prio */
G_TYPE_UINT, /* flags */
G_TYPE_INT); /* timeval */
@ -326,7 +329,6 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
MuStore *store;
err = NULL;
if (! (store = mu_store_new_read_only (xpath, &err)) ||
! (xapian = mu_query_new (store, &err))) {
if (store)
@ -340,7 +342,7 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
}
mu_store_unref (store);
iter = mu_query_run (xapian, query, FALSE, MU_MSG_FIELD_ID_DATE,
iter = mu_query_run (xapian, query, TRUE, MU_MSG_FIELD_ID_DATE,
TRUE, -1, &err);
mu_query_destroy (xapian);
if (!iter) {
@ -356,9 +358,8 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
}
static void
add_row (GtkListStore * store, MuMsg *msg)
add_row (GtkTreeStore * store, MuMsg *msg, GtkTreeIter *treeiter)
{
GtkTreeIter treeiter;
const gchar *datestr, *flagstr;
gchar *from, *to;
time_t timeval;
@ -369,8 +370,15 @@ add_row (GtkListStore * store, MuMsg *msg)
to = empty_or_display_contact (mu_msg_get_to (msg));
flagstr = mu_flags_to_str_s (mu_msg_get_flags (msg), MU_FLAG_TYPE_ANY);
gtk_list_store_append (store, &treeiter);
gtk_list_store_set (store, &treeiter,
/* if (0) { */
/* GtkTreeIter myiter; */
/* if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(store), */
/* &myiter, path)) */
/* g_warning ("%s: cannot get iter for %s",
* __FUNCTION__, path); */
/* } */
gtk_tree_store_set (store, treeiter,
MUG_COL_DATESTR, datestr,
MUG_COL_MAILDIR, mu_msg_get_maildir (msg),
MUG_COL_FLAGSSTR, flagstr,
@ -386,11 +394,12 @@ add_row (GtkListStore * store, MuMsg *msg)
}
static int
update_model (GtkListStore * store, const char *xpath, const char *query,
MugMsgListView * self)
update_model (GtkTreeStore *store, const char *xpath, const char *query,
MugMsgListView *self)
{
MuMsgIter *iter;
int count;
const MuMsgIterThreadInfo *prev_ti = NULL;
iter = run_query (xpath, query, self);
if (!iter) {
@ -399,15 +408,31 @@ update_model (GtkListStore * store, const char *xpath, const char *query,
}
for (count = 0; !mu_msg_iter_is_done (iter);
mu_msg_iter_next (iter), ++count)
add_row (store, mu_msg_iter_get_msg_floating(iter)); /* don't unref */
mu_msg_iter_next (iter), ++count) {
GtkTreeIter treeiter, prev_treeiter;
const MuMsgIterThreadInfo *ti;
ti = mu_msg_iter_get_thread_info (iter);
if (!prev_ti || !g_str_has_prefix (ti->threadpath,
prev_ti->threadpath))
gtk_tree_store_append (store, &treeiter, NULL);
else
gtk_tree_store_append (store, &treeiter, &prev_treeiter);
/* don't unref msg */
add_row (store, mu_msg_iter_get_msg_floating (iter), &treeiter);
prev_ti = ti;
prev_treeiter = treeiter;
}
mu_msg_iter_destroy (iter);
return count;
}
int
mug_msg_list_view_query (MugMsgListView * self, const char *query)
{
@ -417,7 +442,7 @@ mug_msg_list_view_query (MugMsgListView * self, const char *query)
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (self);
gtk_list_store_clear (priv->_store);
gtk_tree_store_clear (priv->_store);
g_free (priv->_query);
priv->_query = query ? g_strdup (query) : NULL;
@ -427,7 +452,7 @@ mug_msg_list_view_query (MugMsgListView * self, const char *query)
rv = update_model (priv->_store, priv->_xpath, query, self);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (self));
gtk_tree_view_expand_all (GTK_TREE_VIEW(self));
return rv;
}

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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
@ -16,12 +16,15 @@
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
#include <config.h>
#ifdef HAVE_CONFIG
#include "config.h"
#endif /*HAVE_CONFIG*/
#include <unistd.h>
#include "mu-msg-view.h"
#include "mug-msg-view.h"
#include "mu-msg.h"
#include "mu-str.h"
#include "mu-date.h"
/* 'private'/'protected' functions */
static void mug_msg_view_class_init (MugMsgViewClass * klass);
@ -35,58 +38,25 @@ enum {
LAST_SIGNAL
};
enum _HeaderRow {
HEADER_ROW_FROM,
HEADER_ROW_TO,
HEADER_ROW_SUBJECT,
HEADER_ROW_CC,
HEADER_ROW_DATE,
HEADER_ROW_PATH,
HEADER_ROW_MSGID,
HEADER_ROW_SIZE,
HEADER_ROW_NUM
};
typedef enum _HeaderRow HeaderRow;
struct _HeaderInfo {
HeaderRow row;
const char *title;
};
typedef struct _HeaderInfo HeaderInfo;
static const HeaderInfo HEADER_INFO[] = {
{HEADER_ROW_CC, "Cc"},
{HEADER_ROW_SUBJECT, "Subject"},
{HEADER_ROW_DATE, "Date"}
};
static const HeaderInfo HEADER_INFO_EXPANDER[] = {
{HEADER_ROW_FROM, "From"},
{HEADER_ROW_TO, "To"},
{HEADER_ROW_PATH, "Path"},
{HEADER_ROW_MSGID, "Message-Id"},
{HEADER_ROW_SIZE, "Size"}
};
typedef struct _MugMsgViewPrivate MugMsgViewPrivate;
struct _MugMsgViewPrivate {
GtkWidget *_headers_area;
GtkWidget *_tablemain, *_tableexpander;
GtkWidget *_headervals[HEADER_ROW_NUM];
GtkWidget *_expander_header, *_expander;
GtkWidget *_view;
};
#define MUG_MSG_VIEW_GET_PRIVATE(o)(G_TYPE_INSTANCE_GET_PRIVATE((o),MUG_TYPE_MSG_VIEW, MugMsgViewPrivate))
/* globals */
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_BOX);
#else
static GtkVBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
static void
mug_msg_view_class_init (MugMsgViewClass * klass)
{
@ -106,82 +76,6 @@ mug_msg_view_class_init (MugMsgViewClass * klass)
/* etc. */
}
static GtkWidget *
create_table (MugMsgViewPrivate * priv, const HeaderInfo * hinfo, guint num)
{
guint i;
GtkWidget *table;
table = gtk_table_new (num, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
for (i = 0; i < num; ++i) {
char *str;
GtkWidget *l, *al;
l = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
gtk_label_set_justify (GTK_LABEL (l), GTK_JUSTIFY_LEFT);
str = g_strdup_printf ("<b>%s</b>:", hinfo[i].title);
gtk_label_set_markup (GTK_LABEL (l), str);
g_free (str);
al = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (al), l);
gtk_table_attach (GTK_TABLE (table), al, 0, 1, i, i + 1,
GTK_FILL, 0, 0, 0);
l = priv->_headervals[hinfo[i].row] = gtk_label_new (NULL);
al = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
gtk_label_set_selectable (GTK_LABEL (l), TRUE);
gtk_container_add (GTK_CONTAINER (al), l);
gtk_label_set_justify (GTK_LABEL (l), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap_mode (GTK_LABEL (l),
PANGO_WRAP_WORD_CHAR);
gtk_label_set_line_wrap (GTK_LABEL (l), FALSE);
gtk_table_attach (GTK_TABLE (table), al,
1, 2, i, i + 1, GTK_FILL, 0, 0, 0);
}
return table;
}
static GtkWidget *
headers_area (MugMsgViewPrivate * priv)
{
GtkWidget *scrolled, *vbox;
priv->_tablemain = create_table (priv, HEADER_INFO,
G_N_ELEMENTS (HEADER_INFO));
priv->_tableexpander = create_table
(priv, HEADER_INFO_EXPANDER, G_N_ELEMENTS (HEADER_INFO_EXPANDER));
priv->_expander = gtk_expander_new ("Details");
gtk_container_add (GTK_CONTAINER (priv->_expander),
priv->_tableexpander);
#ifdef HAVE_GTK3
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
#else
vbox = gtk_vbox_new (FALSE, 0);
#endif /*!HAVE_GTK3 */
gtk_box_pack_start (GTK_BOX (vbox), priv->_tablemain, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->_expander, FALSE, FALSE, 0);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
vbox);
return priv->_headers_area = scrolled;
}
static void
mug_msg_view_init (MugMsgView * obj)
{
@ -190,19 +84,15 @@ mug_msg_view_init (MugMsgView * obj)
priv = MUG_MSG_VIEW_GET_PRIVATE (obj);
priv->_view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->_view), FALSE);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->_view), 10);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (priv->_view), 10);
priv->_view = mu_msg_view_new ();
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scrolled), priv->_view);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
priv->_view);
gtk_box_pack_start (GTK_BOX (obj), headers_area (priv), FALSE, FALSE,
0);
gtk_box_pack_start (GTK_BOX (obj), scrolled, TRUE, TRUE, 0);
}
@ -219,98 +109,50 @@ mug_msg_view_new (void)
return GTK_WIDGET (g_object_new (MUG_TYPE_MSG_VIEW, NULL));
}
static void
empty_message (MugMsgView * self)
{
int i;
MugMsgViewPrivate *priv;
GtkTextBuffer *buf;
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
for (i = 0; i != HEADER_ROW_NUM; ++i)
gtk_label_set_markup (GTK_LABEL (priv->_headervals[i]), "");
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->_view));
gtk_text_buffer_set_text (buf, "", -1);
}
static gboolean
set_text (MugMsgView * self, const char *txt)
{
MugMsgViewPrivate *priv;
GtkTextBuffer *buf;
g_return_val_if_fail (MUG_IS_MSG_VIEW (self), FALSE);
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->_view));
gtk_text_buffer_set_text (buf, txt ? txt : "", -1);
return TRUE;
}
static void
fill_header (MugMsgViewPrivate * priv, MuMsg * msg)
{
int i;
for (i = 0; i != HEADER_ROW_NUM; ++i) {
const gchar *val;
switch (i) {
case HEADER_ROW_FROM: val = mu_msg_get_from (msg); break;
case HEADER_ROW_TO: val = mu_msg_get_to (msg); break;
case HEADER_ROW_SUBJECT: val = mu_msg_get_subject (msg); break;
case HEADER_ROW_MSGID: val = mu_msg_get_msgid (msg);break;
case HEADER_ROW_CC: val = mu_msg_get_cc (msg); break;
case HEADER_ROW_PATH: val = mu_msg_get_path (msg); break;
case HEADER_ROW_DATE:
val = mu_date_str_s ("%c", mu_msg_get_date (msg));
break;
case HEADER_ROW_SIZE:
val = mu_str_size_s (mu_msg_get_size (msg));
break;
default:
val = NULL;
}
{
gchar *str;
str = g_markup_escape_text (val ? val : "", -1);
gtk_label_set_markup
(GTK_LABEL (priv->_headervals[i]), str);
g_free (str);
}
}
}
gboolean
mug_msg_view_set_msg (MugMsgView * self, const char *msgpath)
{
MugMsgViewPrivate *priv;
MuMsg *msg;
gboolean rv;
g_return_val_if_fail (MUG_IS_MSG_VIEW (self), FALSE);
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
if (!msgpath) {
empty_message (self);
return TRUE;
if (!msgpath)
mu_msg_view_set_message (MU_MSG_VIEW(priv->_view), NULL);
else {
MuMsg *msg;
if (access (msgpath, R_OK) == 0) {
msg = mu_msg_new_from_file (msgpath, NULL, NULL);
mu_msg_view_set_message (MU_MSG_VIEW(priv->_view), msg);
if (msg)
mu_msg_unref (msg);
} else {
gchar *note;
note = g_strdup_printf (
"<h1>Note</h1><hr>"
"<p>Message <tt>%s</tt> does not seem to be present "
"on the file system."
"<p>Maybe you need to run <tt>mu index</tt>?",
msgpath);
mu_msg_view_set_note (MU_MSG_VIEW (priv->_view), note);
g_free (note);
}
}
msg = mu_msg_new_from_file (msgpath, NULL, NULL);
if (!msg) {
empty_message (self);
set_text (self, "Message not found; " "please run 'mu index'");
return FALSE;
}
rv = set_text (self, mu_msg_get_body_text (msg));
fill_header (priv, msg);
mu_msg_unref (msg);
return rv;
return TRUE;
}
void
mug_msg_view_set_note (MugMsgView * self, const char* html)
{
MugMsgViewPrivate *priv;
g_return_if_fail (MUG_IS_MSG_VIEW (self));
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
mu_msg_view_set_note (MU_MSG_VIEW (priv->_view), html);
}

View File

@ -23,6 +23,9 @@
#include <gtk/gtk.h>
/* other include files */
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_MSG_VIEW (mug_msg_view_get_type())
@ -35,27 +38,32 @@ typedef struct _MugMsgView MugMsgView;
typedef struct _MugMsgViewClass MugMsgViewClass;
struct _MugMsgView {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
/* insert public members, if any */
#endif /*!HAVE_GTK3*/
};
struct _MugMsgViewClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* insert signal callback declarations, e.g. */
/* void (* my_event) (MugMsg* obj); */
};
/* member functions */
GType
mug_msg_view_get_type (void)
G_GNUC_CONST;
GType mug_msg_view_get_type (void) G_GNUC_CONST;
/* parameter-less _new function (constructor) */
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
GtkWidget *
mug_msg_view_new (void);
gboolean
mug_msg_view_set_msg (MugMsgView * self, const char *msgpath);
GtkWidget* mug_msg_view_new (void);
gboolean mug_msg_view_set_msg (MugMsgView * self, const char *msgpath);
void mug_msg_view_set_note (MugMsgView * self, const char* html);
G_END_DECLS
#endif /* __MUG_MSG_VIEW_H__ */

View File

@ -1,22 +1,6 @@
/*
** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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.
**
*/
/* mug-query-bar.c */
/* insert (c)/licensing information) */
#include "mug-query-bar.h"
/* include other impl specific header files */
@ -42,30 +26,16 @@ struct _MugQueryBarPrivate {
/* globals */
static GtkContainerClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
GType
mug_query_bar_get_type (void)
{
static GType my_type = 0;
if (!my_type) {
static const GTypeInfo my_info = {
sizeof (MugQueryBarClass),
NULL, /* base init */
NULL, /* base finalize */
(GClassInitFunc) mug_query_bar_class_init,
NULL, /* class finalize */
NULL, /* class data */
sizeof (MugQueryBar),
0, /* n_preallocs, ignored since 2.10 */
(GInstanceInitFunc) mug_query_bar_init,
NULL
};
my_type = g_type_register_static (GTK_TYPE_HBOX,
"MugQueryBar", &my_info, 0);
}
return my_type;
}
#ifdef HAVE_GTK3
G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_BOX);
#else
G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_HBOX);
#endif /*!HAVE_GTK3*/
static void
mug_query_bar_class_init (MugQueryBarClass * klass)

View File

@ -4,8 +4,11 @@
#ifndef __MUG_QUERY_BAR_H__
#define __MUG_QUERY_BAR_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG*/
#include <gtk/gtk.h>
/* other include files */
G_BEGIN_DECLS
/* convenience macros */
@ -19,12 +22,22 @@ typedef struct _MugQueryBar MugQueryBar;
typedef struct _MugQueryBarClass MugQueryBarClass;
struct _MugQueryBar {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkHBox parent;
/* insert public members, if any */
#endif /*!HAVE_GTK3*/
};
struct _MugQueryBarClass {
#ifdef HAVE_GTK3
GtkBox parent;
GtkBoxClass parent_class;
#else
GtkHBox parent;
GtkHBoxClass parent_class;
#endif /*!HAVE_GTK3*/
/* insert signal callback declarations, e.g. */
void (*query_changed) (MugQueryBar * obj, const char *query);
};

View File

@ -16,7 +16,6 @@
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
#include <config.h>
#include "mug-shortcuts.h"
#include "mu-bookmarks.h"
@ -46,11 +45,17 @@ struct _MugShortcutsPrivate {
MUG_TYPE_SHORTCUTS, \
MugShortcutsPrivate))
/* globals */
static GtkVBoxClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
#ifdef HAVE_GTK3
static GtkBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_BOX);
#else
static GtkVBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_VBOX);
#endif /*!HAVE_GTK3*/
static void
mug_shortcuts_class_init (MugShortcutsClass * klass)
@ -87,8 +92,7 @@ mug_shortcuts_init (MugShortcuts * obj)
obj->_priv->_bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
#else
obj->_priv->_bbox = gtk_vbutton_box_new ();
#endif /*!HAVE_GTK3 */
#endif /*!HAVE_GTK3*/
gtk_button_box_set_layout (GTK_BUTTON_BOX (obj->_priv->_bbox),
GTK_BUTTONBOX_START);

View File

@ -20,6 +20,11 @@
#ifndef __MUG_SHORTCUTS_H__
#define __MUG_SHORTCUTS_H__
#if HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <gtk/gtk.h>
/* other include files */
@ -36,15 +41,23 @@ typedef struct _MugShortcutsClass MugShortcutsClass;
typedef struct _MugShortcutsPrivate MugShortcutsPrivate;
struct _MugShortcuts {
#ifdef HAVE_GTK3
GtkBox parent;
#else
GtkVBox parent;
/* insert public members, if any */
#endif /*!HAVE_GTK3*/
/* private */
MugShortcutsPrivate *_priv;
};
struct _MugShortcutsClass {
#ifdef HAVE_GTK3
GtkBoxClass parent_class;
#else
GtkVBoxClass parent_class;
#endif /*!HAVE_GTK3*/
void (*clicked) (MugShortcuts * obj, const char *query);
};

View File

@ -25,8 +25,10 @@
#include <gdk/gdkkeysyms.h>
#include <string.h> /* for memset */
#include "mu-util.h"
#include "mu-runtime.h"
#include <mu-util.h>
#include <mu-store.h>
#include <mu-runtime.h>
#include <mu-index.h>
#include "mug-msg-list-view.h"
#include "mug-query-bar.h"
@ -45,6 +47,7 @@ struct _MugData {
};
typedef struct _MugData MugData;
static void
about_mug (MugData * mugdata)
{
@ -64,6 +67,7 @@ about_mug (MugData * mugdata)
enum _ToolAction {
ACTION_PREV_MSG = 1,
ACTION_NEXT_MSG,
ACTION_REINDEX,
ACTION_DO_QUIT,
ACTION_ABOUT,
ACTION_SEPARATOR /* pseudo action */
@ -124,6 +128,8 @@ mug_toolbar (MugData * mugdata)
{GTK_STOCK_GO_UP, ACTION_PREV_MSG},
{GTK_STOCK_GO_DOWN, ACTION_NEXT_MSG},
{NULL, ACTION_SEPARATOR},
{GTK_STOCK_REFRESH, ACTION_REINDEX},
{NULL, ACTION_SEPARATOR},
{GTK_STOCK_ABOUT, ACTION_ABOUT},
{NULL, ACTION_SEPARATOR},
{GTK_STOCK_QUIT, ACTION_DO_QUIT}};
@ -178,7 +184,6 @@ on_query_changed (MugQueryBar * bar, const char *query, MugData * mugdata)
int count;
/* clear the old message */
//mug_msg_view_set_text (MUG_MSG_VIEW(mugdata->msgview), NULL);
mug_msg_view_set_msg (MUG_MSG_VIEW (mugdata->msgview), NULL);
count = mug_msg_list_view_query (MUG_MSG_LIST_VIEW (mugdata->mlist),
@ -205,7 +210,6 @@ on_query_changed (MugQueryBar * bar, const char *query, MugData * mugdata)
static void
on_msg_selected (MugMsgListView * mlist, const char *mpath, MugData * mugdata)
{
// g_warning ("msg selected: %s", mpath);
mug_msg_view_set_msg (MUG_MSG_VIEW (mugdata->msgview), mpath);
}
@ -240,9 +244,8 @@ on_list_view_error (MugMsgListView * mlist, MugError err, MugData * mugdata)
gtk_dialog_run (GTK_DIALOG (errdialog));
gtk_widget_destroy (errdialog);
if (err == MUG_ERROR_QUERY) {
if (err == MUG_ERROR_QUERY)
mug_query_bar_grab_focus (MUG_QUERY_BAR (mugdata->querybar));
}
}
static GtkWidget *
@ -258,9 +261,7 @@ mug_querybar (void)
static GtkWidget *
mug_query_area (MugData * mugdata)
{
GtkWidget *queryarea;
GtkWidget *paned;
GtkWidget *scrolled;
GtkWidget *queryarea, *paned, *scrolled;
#ifdef HAVE_GTK3
queryarea = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
@ -268,7 +269,7 @@ mug_query_area (MugData * mugdata)
#else
queryarea = gtk_vbox_new (FALSE, 2);
paned = gtk_vpaned_new ();
#endif /*!HAVE_GTK3 */
#endif /*!HAVE_GTK3*/
mugdata->mlist = mug_msg_list_view_new
@ -282,8 +283,10 @@ mug_query_area (MugData * mugdata)
gtk_paned_add1 (GTK_PANED (paned), scrolled);
mugdata->msgview = mug_msg_view_new ();
mug_msg_view_set_msg (MUG_MSG_VIEW (mugdata->msgview), NULL);
mug_msg_view_set_note (MUG_MSG_VIEW(mugdata->msgview),
"<h1>Welcome to <i>mug</i>!</h1><hr>"
"<tt>mug</tt> is an experimental UI for <tt>mu</tt>, which will "
"slowly evolve into something useful.<br><br>Enjoy the ride.");
g_signal_connect (G_OBJECT (mugdata->mlist), "msg-selected",
G_CALLBACK (on_msg_selected), mugdata);
g_signal_connect (G_OBJECT (mugdata->mlist), "error-occured",
@ -311,7 +314,7 @@ mug_main_area (MugData * mugdata)
mainarea = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
#else
mainarea = gtk_hbox_new (FALSE, 5);
#endif /*!HAVE_GTK3 */
#endif /*!HAVE_GTK3*/
w = mug_shortcuts_bar (mugdata);
gtk_box_pack_start (GTK_BOX (mainarea), w, FALSE, FALSE, 0);
@ -336,7 +339,7 @@ mug_shell (MugData * mugdata)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
#else
vbox = gtk_vbox_new (FALSE, 2);
#endif /*!HAVE_GTK3 */
#endif /*!HAVE_GTK3*/
mugdata->toolbar = mug_toolbar (mugdata);
gtk_box_pack_start (GTK_BOX (vbox), mugdata->toolbar, FALSE, FALSE, 2);
@ -353,12 +356,13 @@ mug_shell (MugData * mugdata)
gtk_window_set_default_size (GTK_WINDOW (mugdata->win), 700, 500);
gtk_window_set_resizable (GTK_WINDOW (mugdata->win), TRUE);
// {
// gchar *icon;
// icon = g_strdup_printf ("%s%cmug.svg", ICONDIR, G_DIR_SEPARATOR);
// gtk_window_set_icon_from_file (GTK_WINDOW (mugdata->win), icon, NULL);
// g_free (icon);
// }
{
gchar *icon;
icon = g_strdup_printf ("%s%cmug.svg",
MUGDIR, G_DIR_SEPARATOR);
gtk_window_set_icon_from_file (GTK_WINDOW (mugdata->win), icon, NULL);
g_free (icon);
}
return mugdata->win;
}
@ -392,10 +396,12 @@ main (int argc, char *argv[])
memset (&mugdata, 0, sizeof (MugData));
if (!g_option_context_parse (octx, &argc, &argv, NULL)) {
g_option_context_free (octx);
g_printerr ("mug: error in options\n");
return 1;
}
g_option_context_free (octx);
mu_runtime_init (mugdata.muhome, "mug");
mugshell = mug_shell (&mugdata);

443
toys/mug/mug.svg Normal file
View File

@ -0,0 +1,443 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg3060"
version="1.1"
inkscape:version="0.48.0 r9654"
sodipodi:docname="mug.svg">
<defs
id="defs3062">
<radialGradient
cx="488.89267"
cy="588.70575"
r="219.20311"
fx="488.89267"
fy="588.70575"
id="radialGradient4633"
xlink:href="#linearGradient4931"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.00800352,1.2096377,-1.5872404,-0.01050209,1429.2231,7.1996709)" />
<linearGradient
id="linearGradient4931">
<stop
id="stop4933"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop4935"
style="stop-color:#cccccc;stop-opacity:1"
offset="1" />
</linearGradient>
<radialGradient
cx="459.32651"
cy="604.53241"
r="218.49857"
fx="459.32651"
fy="604.53241"
id="radialGradient4635"
xlink:href="#linearGradient4909"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-2.4717924e-8,0.4792097,-0.761379,-2.2833566e-8,965.49485,426.4337)" />
<linearGradient
id="linearGradient4909">
<stop
id="stop4911"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop4913"
style="stop-color:#cccccc;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
x1="507.53687"
y1="695.01477"
x2="505.21655"
y2="435.03162"
id="linearGradient4637"
xlink:href="#linearGradient4893"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,-1,0,1171.1728)" />
<linearGradient
id="linearGradient4893">
<stop
id="stop4895"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop4897"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<radialGradient
cx="518.93054"
cy="498.96671"
r="218.49857"
fx="518.93054"
fy="498.96671"
id="radialGradient4639"
xlink:href="#linearGradient4917"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.00681824,0.7964116,-0.908528,0.00777809,968.71756,124.33984)" />
<linearGradient
id="linearGradient4917">
<stop
id="stop4919"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop4921"
style="stop-color:#f2f2f2;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
x1="507.53687"
y1="695.01477"
x2="505.21655"
y2="435.03162"
id="linearGradient4641"
xlink:href="#linearGradient4893"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,6)" />
<linearGradient
id="linearGradient3095">
<stop
id="stop3097"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop3099"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
x1="507.53687"
y1="695.01477"
x2="505.21655"
y2="435.03162"
id="linearGradient4643"
xlink:href="#linearGradient4893"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,-1,0,1175.1728)" />
<linearGradient
id="linearGradient3102">
<stop
id="stop3104"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop3106"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
x1="507.53687"
y1="695.01477"
x2="505.21655"
y2="435.03162"
id="linearGradient4645"
xlink:href="#linearGradient4893"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,4)" />
<linearGradient
id="linearGradient3109">
<stop
id="stop3111"
style="stop-color:#000000;stop-opacity:1"
offset="0" />
<stop
id="stop3113"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4145"
id="linearGradient4216"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-15.844294,-42.822415)"
x1="427.79593"
y1="418.59042"
x2="308.88391"
y2="339.36896" />
<linearGradient
inkscape:collect="always"
id="linearGradient4145">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4147" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4149" />
</linearGradient>
<filter
color-interpolation-filters="sRGB"
inkscape:collect="always"
id="filter4141">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="1.0889941"
id="feGaussianBlur4143" />
</filter>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1439"
id="radialGradient4218"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.1767241,-0.06570592,0.06229194,1.0081481,242.27164,193.29801)"
cx="61.56411"
cy="105.93911"
fx="69.98687"
fy="90.41909"
r="27.959114" />
<linearGradient
id="linearGradient1439">
<stop
id="stop1440"
offset="0"
style="stop-color:#ffffff;stop-opacity:0.5704698;" />
<stop
id="stop1441"
offset="1"
style="stop-color:#96b0c6;stop-opacity:0.89932889;" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1045"
id="linearGradient4220"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.1481635,-0.03408387,0.03066403,0.9334827,252.4323,191.06145)"
x1="57.667629"
y1="84.017433"
x2="60.490723"
y2="111.23763" />
<linearGradient
id="linearGradient1045">
<stop
id="stop1046"
offset="0.00000000"
style="stop-color:#ffffff;stop-opacity:0.74901962;" />
<stop
id="stop1047"
offset="1.0000000"
style="stop-color:#ffffff;stop-opacity:0.00000000;" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1045"
id="linearGradient4222"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.1879329,-0.03526444,0.02518942,0.7668232,265.95849,191.03645)"
x1="42.497837"
y1="103.57257"
x2="54.32185"
y2="167.94406" />
<linearGradient
id="linearGradient3225">
<stop
id="stop3227"
offset="0.00000000"
style="stop-color:#ffffff;stop-opacity:0.74901962;" />
<stop
id="stop3229"
offset="1.0000000"
style="stop-color:#ffffff;stop-opacity:0.00000000;" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1045"
id="linearGradient4224"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.0181639,-0.03179448,0.0306403,0.9812034,248.50031,191.28893)"
x1="110.05048"
y1="138.23856"
x2="103.6906"
y2="145.33636" />
<linearGradient
id="linearGradient3232">
<stop
id="stop3234"
offset="0.00000000"
style="stop-color:#ffffff;stop-opacity:0.74901962;" />
<stop
id="stop3236"
offset="1.0000000"
style="stop-color:#ffffff;stop-opacity:0.00000000;" />
</linearGradient>
<linearGradient
y2="327.80692"
x2="358.85184"
y1="336.3714"
x1="350.71558"
gradientUnits="userSpaceOnUse"
id="linearGradient3164"
xlink:href="#linearGradient4191"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
id="linearGradient4191">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4193" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4195" />
</linearGradient>
<linearGradient
y2="327.80692"
x2="358.85184"
y1="336.3714"
x1="350.71558"
gradientUnits="userSpaceOnUse"
id="linearGradient3251"
xlink:href="#linearGradient4191"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.3797387"
inkscape:cx="23.090914"
inkscape:cy="36.54545"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1426"
inkscape:window-height="943"
inkscape:window-x="0"
inkscape:window-y="26"
inkscape:window-maximized="0" />
<metadata
id="metadata3065">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
transform="matrix(0.13627872,0,0,0.13834282,-32.522534,-32.527783)"
id="layer1-0">
<g
transform="matrix(0.9262457,-0.1633221,0.1633221,0.9262457,-94.266784,-20.740432)"
id="g4939">
<rect
width="438.40622"
height="252.53813"
rx="12"
ry="12"
x="291.87317"
y="468.43307"
id="rect4929"
style="fill:url(#radialGradient4633);fill-opacity:1;stroke:none" />
<rect
width="438.40622"
height="252.53813"
rx="12"
ry="12"
x="285.87317"
y="462.43307"
id="rect4886"
style="fill:#f4eed7;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
<path
inkscape:connector-curvature="0"
d="m 287.46875,708.86033 c -1.4331,-5.96063 0.14236,-12.48611 4.8125,-17.15625 L 492.3125,491.67283 c 7.14709,-7.14709 18.66539,-7.14711 25.8125,0 l 200,200.03125 c 4.67014,4.67014 6.27685,11.19562 4.84375,17.15625 l -435.5,0 z"
id="path4901"
style="fill:url(#radialGradient4635);fill-opacity:1;stroke:url(#linearGradient4637);stroke-width:0.47990575;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
<path
inkscape:connector-curvature="0"
d="m 287.46875,468.3125 c -1.4331,5.96063 0.14236,12.48611 4.8125,17.15625 L 492.3125,685.5 c 7.14709,7.14709 18.66539,7.14711 25.8125,0 l 200,-200.03125 c 4.67014,-4.67014 6.27685,-11.19562 4.84375,-17.15625 l -435.5,0 z"
id="rect4888"
style="fill:url(#radialGradient4639);fill-opacity:1;stroke:url(#linearGradient4641);stroke-width:0.47990575;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
<path
inkscape:connector-curvature="0"
d="m 287.46875,712.86033 c -1.4331,-5.96063 0.14236,-12.48611 4.8125,-17.15625 L 492.3125,495.67283 c 7.14709,-7.14709 18.66539,-7.14711 25.8125,0 l 200,200.03125 c 4.67014,4.67014 6.27685,11.19562 4.84375,17.15625 l -435.5,0 z"
id="path4905"
style="fill:#f4eed7;fill-opacity:1;stroke:url(#linearGradient4643);stroke-width:0.47990575;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
<path
inkscape:connector-curvature="0"
d="m 287.46875,466.3125 c -1.4331,5.96063 0.14236,12.48611 4.8125,17.15625 L 492.3125,683.5 c 7.14709,7.14709 18.66539,7.14711 25.8125,0 l 200,-200.03125 c 4.67014,-4.67014 6.27685,-11.19562 4.84375,-17.15625 l -435.5,0 z"
id="path4925"
style="fill:#f4eed7;fill-opacity:1;stroke:url(#linearGradient4645);stroke-width:0.47990575;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
</g>
</g>
<g
id="g4206"
transform="matrix(0.66491655,0,0,0.77814599,-189.90991,-208.191)">
<path
sodipodi:nodetypes="cssscccccsccssssc"
id="path4039"
d="m 316.07229,281.98202 c -0.43848,0.0486 -0.86293,0.0963 -1.30329,0.16735 -14.09135,2.2736 -23.67275,15.31462 -21.39425,29.11832 2.2785,13.8037 15.55266,23.18673 29.64399,20.91314 5.32396,-0.85901 9.9974,-3.24509 13.63696,-6.64407 l 29.69403,21.53613 c 3.12107,-0.43375 5.32521,-2.54648 6.63691,-6.36414 l -31.28016,-21.37742 -0.60163,0.70667 c 2.99888,-4.94941 4.31388,-10.8985 3.30565,-17.00664 -2.20729,-13.37234 -14.74564,-22.55444 -28.33821,-21.04934 z m 0.11619,1.0566 c 13.01836,-1.44152 25.05638,7.3638 27.17043,20.17124 2.18223,13.22057 -8.30725,25.74182 -21.80333,27.91939 -13.49606,2.17754 -24.91335,-6.79082 -27.0956,-20.0114 -2.18223,-13.22055 6.99145,-25.73934 20.48752,-27.91689 0.42175,-0.0681 0.82103,-0.11586 1.24098,-0.16234 z"
style="fill:url(#linearGradient4216);fill-opacity:1;fill-rule:evenodd;stroke-width:0.5;filter:url(#filter4141)"
inkscape:connector-curvature="0" />
<path
style="fill:#807d74;fill-opacity:1;fill-rule:evenodd;stroke-width:0.5"
d="m 344.17328,310.53057 29.61718,27.04843 c -1.89242,3.87599 -4.50058,5.8091 -7.81004,5.83855 l -28.02027,-27.09828 6.21313,-5.7887 z"
id="path852"
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="ccc"
id="path4204"
d="m 344.98664,308.53682 c -25.57774,26.69357 -58.35719,-3.9253 -41.04008,-28.54056 -22.47432,26.70691 17.05217,59.23993 41.04008,28.54056 z"
style="fill:#273f57;fill-opacity:0.99607843;fill-rule:nonzero;stroke:none"
inkscape:connector-curvature="0" />
<path
style="fill:url(#radialGradient4218);fill-opacity:1;fill-rule:evenodd;stroke:#314e6c;stroke-width:1.13486826;stroke-miterlimit:4;stroke-opacity:0.99523806;stroke-dasharray:none"
d="m 349.29738,294.36408 c 0.43574,13.26512 -10.53563,24.36721 -24.48967,24.78145 -13.95405,0.41424 -25.63272,-10.01548 -26.06847,-23.2806 -0.43574,-13.26512 10.53563,-24.3672 24.48968,-24.78143 13.95404,-0.41424 25.6327,10.01546 26.06846,23.28058 z"
id="path853"
inkscape:connector-curvature="0" />
<path
style="fill:url(#linearGradient4220);fill-opacity:0.09090905;fill-rule:evenodd;stroke-width:1pt"
d="m 334.58464,277.67286 c 3.57111,4.2824 -0.18987,12.77638 -8.39505,18.9598 -8.2052,6.18342 -17.76278,7.72625 -21.33391,3.44384 -3.57111,-4.28239 0.18987,-12.77639 8.39506,-18.95979 8.20519,-6.18343 17.76278,-7.72627 21.3339,-3.44385 z"
id="path863"
inkscape:connector-curvature="0" />
<path
style="fill:url(#linearGradient4222);fill-opacity:0.55208333;fill-rule:evenodd;stroke-width:1pt"
d="m 310.11078,312.32383 c 14.49429,4.30904 31.85616,-4.46732 36.42449,-18.21714 4.41474,12.57528 -23.28046,39.53212 -36.42449,18.21714 z"
id="path885"
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="ccccc"
id="path1766"
d="m 339.59269,316.18967 4.6224,-4.38252 27.97152,25.69252 c 1.23309,3.32848 -0.44562,5.68159 -6.10065,4.88028 l -26.49327,-26.19028 z"
style="fill:url(#linearGradient4224);fill-opacity:0.75;fill-rule:evenodd;stroke:none"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="ccccc"
id="path4187"
d="m 338.93805,316.8243 4.6224,-4.38252 27.97152,25.69252 c 1.23309,3.32848 -0.44562,5.68159 -6.10065,4.88028 L 338.93805,316.8243 z"
style="fill:url(#linearGradient3251);fill-opacity:1;fill-rule:evenodd;stroke:none"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 17 KiB