toys: remove

The didn't work for quite some time, and would need quite a few updates to even
compile with the latest.

So remove.
This commit is contained in:
Dirk-Jan C. Binnema 2022-05-19 07:36:21 +03:00
parent 9af9d0fa94
commit 559296a3a7
29 changed files with 5 additions and 3942 deletions

View File

@ -28,7 +28,7 @@ else
mu4e=
endif
SUBDIRS=m4 man lib $(guile) mu $(mu4e) contrib toys
SUBDIRS=m4 man lib $(guile) mu $(mu4e) contrib
ACLOCAL_AMFLAGS=-I m4

View File

@ -172,8 +172,8 @@
*** toys
- the ~mug~ toys is deprecated and to be removed after 1.8
- the ~toys~ (~mug~) has been removed, as they no longer worked with the rest of
the code.
* 1.6 (released, as of July 27 2021)

View File

@ -16,7 +16,7 @@
AC_PREREQ([2.68])
AC_INIT([mu],[1.7.21],[https://github.com/djcb/mu/issues],[mu])
AC_COPYRIGHT([Copyright (C) 2008-2021 Dirk-Jan C. Binnema])
AC_COPYRIGHT([Copyright (C) 2008-2022 Dirk-Jan C. Binnema])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([mu/mu.cc])
# libtoolize wants to put some stuff in here; if you have an old
@ -193,30 +193,6 @@ PKG_CHECK_MODULES(XAPIAN,xapian-core >= 1.4,[
AC_DEFINE(MU_STORE_SCHEMA_VERSION,["462"],['Schema' version of the database])
###############################################################################
###############################################################################
# we need GTK+3 for some of the graphical tools
# use --without-gtk to disable it
AC_ARG_ENABLE([gtk],AS_HELP_STRING([--disable-gtk],[Disable GTK+]))
AS_IF([test "x$enable_gtk" != "xno"],[
PKG_CHECK_MODULES(GTK,gtk+-3.0,[have_gtk=yes],[have_gtk=no])
gtk_version="$($PKG_CONFIG --modversion gtk+-3.0)"
])
AM_CONDITIONAL(HAVE_GTK,[test "x$have_gtk" = "xyes"])
# webkit? needed for the fancy web widget
# use --disable-webkit to disable it, even if you have it
#
# and note this is just a toy, not for distribution.
AC_ARG_ENABLE([webkit],AS_HELP_STRING([--disable-webkit],[Disable webkit]))
AS_IF([test "x$enable_webkit" != "xno"],[
PKG_CHECK_MODULES(WEBKIT,webkit2gtk-4.0 >= 2.0, [have_webkit=yes],[have_webkit=no])
AS_IF([test "x$have_webkit" = "xyes"],[
webkit_version="$($PKG_CONFIG --modversion webkit2gtk-4.0)"])
])
AM_CONDITIONAL(HAVE_WEBKIT, [test "x$have_webkit" = "xyes"])
AM_CONDITIONAL(BUILD_GUI,[test "x$have_webkit" = "xyes" -a "x$have_gtk" = "xyes"])
###############################################################################
################################################################################
# should we try to build an emacs dynamic module?
#AC_CHECK_HEADER([emacs-module.h],[
@ -285,8 +261,6 @@ guile/Makefile
guile/mu/Makefile
guile/examples/Makefile
guile/scripts/Makefile
toys/Makefile
toys/mug/Makefile
man/Makefile
m4/Makefile
contrib/Makefile
@ -307,30 +281,10 @@ echo "Xapian version : $xapian_version"
echo "GLib version : $glib_version"
echo "GMime version : $gmime_version"
AM_COND_IF([BUILD_GUI],[
echo "GTK+ version : $gtk_version"
echo "Webkit2/GTK+ version : $webkit_version"
])
AM_COND_IF([BUILD_GUILE],[
echo "Guile version : $guile_version"
])
AS_IF([test "x$build_mu4e" = "xyes"],[
echo "Build mu4e : yes"
echo "Emacs version : $emacs_version"
#AM_COND_IF([BUILD_EMACS_MODULE],[
#echo "Build emacs module : yes"],[
#echo "Build emacs module : no"
#])])
AM_COND_IF([BUILD_GUI],[
echo "Build 'mug' toy-ui (gtk+/webkit) : yes"],[
echo "Build 'mug' toy-ui (gtk+/webkit) : no"
])
echo
echo "Have direntry->d_ino : $use_dirent_d_ino"
echo "Have direntry->d_type : $use_dirent_d_type"
echo "------------------------------------------------"
@ -348,12 +302,6 @@ if test "x$have_makeinfo" != "xyes"; then
echo
fi
# gui
AS_IF([test "x$buildgui" = "xyes"],[
echo "* The demo UI will be built in toys/mug"
echo
])
# wordexp
AS_IF([test "x$ac_cv_header_wordexp_h" != "xyes"],[
echo "* Your system does not seem to have the 'wordexp' function."

View File

@ -121,11 +121,6 @@ thread_dep = dependency('threads')
# soft dependencies
guile_dep = dependency('guile-3.0', required: get_option('guile'))
if get_option('toys').enabled()
gtk_dep = dependency('gtk+-3.0')
webkit_dep = dependency('webkit2gtk-4.0')
endif
awk=find_program(['gawk', 'awk'])
# soft dependencies
@ -190,12 +185,6 @@ if not get_option('guile').disabled() and guile_dep.found()
endif
config_h_data.set_quoted('MU_PROGRAM', mu.full_path())
if get_option('toys').enabled()
message('toys are disabled for now')
#subdir('toys/mug')
endif
################################################################################
################################################################################

View File

@ -1,4 +1,4 @@
## Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2022 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
@ -20,11 +20,6 @@ option('guile',
value: 'auto',
description: 'build the guile scripting support (requires guile-3.x)')
option('toys',
type : 'feature',
value: 'auto',
description: 'build various toy programs (requires gtk3/gtk-webkit)')
option('readline',
type: 'feature',
value: 'auto',

View File

@ -1,24 +0,0 @@
## Copyright (C) 2008-2020 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
## (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 $(top_srcdir)/gtest.mk
SUBDIRS=
# for mug2 and msg2pdf, we need webkit
if BUILD_GUI
#SUBDIRS += mug # msg2pdf
endif

View File

@ -1,53 +0,0 @@
## Copyright (C) 2012-2013 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
## (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 $(top_srcdir)/gtest.mk
# enforce compiling this dir first before descending into tests/
SUBDIRS= .
AM_CPPFLAGS=-I${top_srcdir}/lib $(GTK_CFLAGS) $(WEBKIT_CFLAGS)
# don't use -Werror, as it might break on other compilers
# use -Wno-unused-parameters, because some callbacks may not
# really need all the params they get
AM_CFLAGS=$(ASAN_CFLAGS) -Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement
noinst_PROGRAMS= \
msg2pdf
# note, mug.cc is '.cc' only because libmu must explicitly
# be linked as c++, not c.
msg2pdf_SOURCES= \
msg2pdf.c \
dummy.cc
# we need to use dummy.cc to enforce c++ linking...
BUILT_SOURCES= \
dummy.cc
dummy.cc:
touch dummy.cc
DISTCLEANFILES= \
$(BUILT_SOURCES)
msg2pdf_LDADD= \
$(ASAN_LDFLAGS) \
${top_builddir}/lib/libmu.la \
$(GTK_LIBS) \
${WEBKIT_LIBS}

View File

@ -1,315 +0,0 @@
/*
** Copyright (C) 2012-2020 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.h>
#include <utils/mu-date.h>
#include <mu-msg-part.h>
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
typedef enum { UNKNOWN, OK, FAILED } Result;
static void
on_failed (WebKitPrintOperation *print_operation,
GError *error,
Result *result)
{
if (error)
g_warning ("%s", error->message);
*result = FAILED;
}
static void
on_finished (WebKitPrintOperation *print_operation,
Result *result)
{
if (*result == UNKNOWN)
*result = OK;
}
static gboolean
print_to_pdf (GtkWidget *webview, GError **err)
{
GtkWidget *win;
WebKitPrintOperation *op;
GtkPrintSettings *settings;
char *path, *uri;
Result res;
time_t started;
const int max_time = 3; /* max 3 seconds to download stuff */
path = g_strdup_printf ("%s%c%x.pdf", mu_util_cache_dir(),
G_DIR_SEPARATOR, (unsigned)random());
if (!mu_util_create_dir_maybe (mu_util_cache_dir(), 0700, FALSE)) {
g_warning ("Couldn't create tempdir");
g_free (path);
return FALSE;
}
uri = g_filename_to_uri (path, NULL, NULL);
g_print ("%s\n", path);
g_free(path);
if (!uri) {
g_warning ("failed to create uri");
return FALSE;
}
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(win), webview);
gtk_widget_show_all(win);
op = webkit_print_operation_new (WEBKIT_WEB_VIEW(webview));
settings = gtk_print_settings_new();
gtk_print_settings_set(settings,
GTK_PRINT_SETTINGS_OUTPUT_URI, uri);
gtk_print_settings_set(settings,
GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "PDF");
g_free(uri);
webkit_print_operation_set_print_settings(op, settings);
webkit_print_operation_run_dialog(op, NULL);
res = UNKNOWN;
g_signal_connect(op, "failed", G_CALLBACK(on_failed), &res);
g_signal_connect(op, "finished", G_CALLBACK(on_finished), &res);
webkit_print_operation_print(op);
started = time (NULL);
do {
gtk_main_iteration_do (FALSE);
} while (res == UNKNOWN /*&& (time(NULL) - started) <= max_time*/);
g_object_unref (op);
return res == OK;
}
static char*
save_file_for_cid (MuMsg *msg, const char* cid)
{
gint idx;
gchar *filepath;
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", __func__, cid);
return NULL;
}
err = NULL;
filepath = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE, idx, NULL);
if (!filepath)
goto errexit;
if (!mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING, filepath, idx,
&err))
goto errexit;
return filepath;
errexit:
g_warning ("%s: failed to save %s: %s", __func__,
filepath,
err&&err->message?err->message:"error");
g_clear_error (&err);
g_free (filepath);
return NULL;
}
static void
on_resource_load_started (WebKitWebView *self,
WebKitWebResource *resource,
WebKitURIRequest *request,
MuMsg *msg)
{
const char* uri;
uri = webkit_uri_request_get_uri (request);
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_uri_request_set_uri (request, fileuri);
g_debug("printing %s", fileuri);
g_free (fileuri);
g_free (filepath);
}
}
}
/* return the path to the output file, or NULL in case of error */
static gboolean
generate_pdf (MuMsg *msg, const char *str, GError **err)
{
GtkWidget *view;
WebKitSettings *settings;
time_t started;
gboolean loading;
const int max_time = 3; /* max 3 seconds to download stuff */
settings = webkit_settings_new ();
g_object_set (G_OBJECT(settings),
"enable-javascript", FALSE,
"auto-load-images", TRUE,
"enable-plugins", FALSE,
NULL);
view = webkit_web_view_new ();
/* to support cid: */
g_signal_connect (G_OBJECT(view), "resource-load-started",
G_CALLBACK (on_resource_load_started), msg);
webkit_web_view_set_settings (WEBKIT_WEB_VIEW(view), settings);
webkit_web_view_load_html (WEBKIT_WEB_VIEW(view), str, NULL);
g_object_unref (settings);
started = time (NULL);
do {
loading = webkit_web_view_is_loading (WEBKIT_WEB_VIEW(view));
gtk_main_iteration_do (FALSE);
} while (loading && (time(NULL) - started) <= max_time);
return print_to_pdf (view, err);
}
static void
add_header (GString *gstr, const char* header, const char *val)
{
char *esc;
if (!val)
return;
esc = g_markup_escape_text (val, -1);
g_string_append_printf (gstr, "<b>%s</b>: %s<br>", header, esc);
g_free (esc);
}
/* return the path to the output file, or NULL in case of error */
static gboolean
convert_to_pdf (MuMsg *msg, GError **err)
{
GString *gstr;
const char *body;
gchar *data;
gboolean rv;
gstr = g_string_sized_new (4096);
add_header (gstr, "From", mu_msg_get_from (msg));
add_header (gstr, "To", mu_msg_get_to (msg));
add_header (gstr, "Cc", mu_msg_get_cc (msg));
add_header (gstr, "Subject", mu_msg_get_subject (msg));
add_header (gstr, "Date", mu_date_str_s
("%c", mu_msg_get_date(msg)));
gstr = g_string_append (gstr, "<hr>\n");
body = mu_msg_get_body_html (msg, MU_MSG_OPTION_NONE);
if (body)
g_string_append_printf (gstr, "%s", body);
else {
body = mu_msg_get_body_text (msg, MU_MSG_OPTION_NONE);
if (body) {
gchar *esc;
esc = g_markup_escape_text (body, -1);
g_string_append_printf (gstr, "<pre>\n%s\n</pre>",
esc);
g_free (esc);
} else
gstr = g_string_append
(gstr, "<i>No body</i>\n");
}
data = g_string_free (gstr, FALSE);
rv = generate_pdf (msg, data, err);
g_free (data);
return rv;
}
int
main(int argc, char *argv[])
{
MuMsg *msg;
GError *err;
if (argc != 2) {
g_print ("msg2pdf: generate pdf files from e-mail messages\n"
"usage: msg2pdf <msgfile>\n");
return 1;
}
gtk_init (&argc, &argv);
if (access (argv[1], R_OK) != 0) {
g_printerr ("%s is not a readable file\n", argv[1]);
return 1;
}
err = NULL;
msg = mu_msg_new_from_file (argv[1], NULL, &err);
if (!msg) {
g_printerr ("failed to create msg for %s\n", argv[1]);
goto err;
}
if (!convert_to_pdf (msg, &err)) {
g_printerr ("failed to create pdf from %s\n", argv[1]);
goto err;
}
/* it worked! */
mu_msg_unref (msg);
return 0;
err:
/* some error occurred */
mu_msg_unref (msg);
if (err)
g_printerr ("error: %s", err->message);
g_clear_error (&err);
return 1;
}

View File

@ -1,93 +0,0 @@
## Copyright (C) 2008-2020 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
## 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,
## 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 $(top_srcdir)/gtest.mk
# enforce compiling this dir first before descending into tests/
SUBDIRS= .
AM_CPPFLAGS=-I${top_srcdir} -I${top_srcdir}/lib $(GTK_CFLAGS) $(WEBKIT_CFLAGS) \
-DICONDIR='"$(icondir)"' -DMUGDIR='"$(abs_srcdir)"' \
-DGSEAL_ENABLE
# remove -DGTK_DISABLE_DEPRECATED for now, since it breaks 3.10+ compilation
# don't use -Werror, as it might break on other compilers
# use -Wno-unused-parameters, because some callbacks may not
# really need all the params they get
AM_CFLAGS= \
$(WARN_CFLAGS) \
$(ASAN_CFLAGS) \
-Wno-redundant-decls \
-Wno-deprecated-declarations \
-Wno-switch-enum
AM_CXXFLAGS= \
$(WARN_CXXFLAGS) \
$(ASAN_CFLAGS) \
-Wno-redundant-decls \
-Wno-deprecated-declarations \
-Wno-switch-enum
#
# Distributors: this is a _toy_, not for distribution. the "noinst_" says enough
#
noinst_PROGRAMS= \
mug
mug_SOURCES= \
mug.cc \
mug-msg-list-view.cc \
mug-msg-list-view.h \
mug-msg-view.h \
mug-msg-view.cc \
mug-query-bar.h \
mug-query-bar.c \
mug-shortcuts.cc \
mug-shortcuts.h
DISTCLEANFILES= \
$(BUILT_SOURCES)
mug_LDADD= \
$(ASAN_LDFLAGS) \
${top_builddir}/lib/libmu.la \
${top_builddir}/lib/utils/libmu-utils.la \
libmuwidgets.la \
${GTK_LIBS}
noinst_LTLIBRARIES= \
libmuwidgets.la
libmuwidgets_la_SOURCES= \
mu-widget-util.h \
mu-widget-util.c \
mu-msg-attach-view.cc \
mu-msg-attach-view.hh \
mu-msg-body-view.cc \
mu-msg-body-view.hh \
mu-msg-header-view.cc \
mu-msg-header-view.hh \
mu-msg-view.hh \
mu-msg-view.cc
libmuwidgets_la_LIBADD= \
${top_builddir}/lib/libmu.la \
${GTK_LIBS} \
${WEBKIT_LIBS} \
${GIO_LIBS}
EXTRA_DIST= \
mug.svg

View File

@ -1,291 +0,0 @@
/*
** Copyright (C) 2011-2021 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.hh"
#include "mu-widget-util.h"
#include <mu-msg.hh>
#include <mu-msg-part.hh>
using namespace Mu;
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 = (GtkIconViewClass*)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_free_full(lst, g_free);
}
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),
(GdkModifierType)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_maybe_attachment(part))
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_debug("%s: could not get icon pixbuf for '%s'", __func__, 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

@ -1,69 +0,0 @@
/*
** Copyright (C) 2011-2021 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_HH__
#define MU_MSG_ATTACH_VIEW_HH__
#include <gtk/gtk.h>
#include <mu-msg.hh>
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, Mu::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, Mu::MuMsg* msg);
G_END_DECLS
#endif /*MU_MSG_ATTACH_VIEW_HH__*/

View File

@ -1,334 +0,0 @@
/*
** Copyright (C) 2011-2020 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-body-view.hh"
#include <mu-msg-part.hh>
using namespace Mu;
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 {
WebKitSettings* _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 = (WebKitWebViewClass*)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", __func__, 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",
__func__,
filepath,
err && err->message ? err->message : "error");
g_clear_error(&err);
g_free(filepath);
filepath = NULL;
}
return filepath;
}
static void
on_resource_load_started(MuMsgBodyView* self,
WebKitWebResource* resource,
WebKitURIRequest* request,
gpointer data)
{
const char* uri;
MuMsg* msg;
msg = self->_priv->_msg;
uri = webkit_uri_request_get_uri(request);
/* g_warning ("%s: %s", __func__, 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_uri_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_settings_new();
g_object_set(G_OBJECT(obj->_priv->_settings),
"enable-javascript",
FALSE,
"auto-load-images",
TRUE,
"enable-plugins",
FALSE,
NULL);
webkit_web_view_set_settings(WEBKIT_WEB_VIEW(obj), obj->_priv->_settings);
/* to support cid: */
g_signal_connect(obj, "resource-load-started", G_CALLBACK(on_resource_load_started), NULL);
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));
}
static void
set_html(MuMsgBodyView* self, const char* html)
{
g_return_if_fail(MU_IS_MSG_BODY_VIEW(self));
webkit_web_view_load_html(WEBKIT_WEB_VIEW(self), html ? html : "", NULL);
}
static void
set_text(MuMsgBodyView* self, const char* txt)
{
g_return_if_fail(MU_IS_MSG_BODY_VIEW(self));
webkit_web_view_load_plain_text(WEBKIT_WEB_VIEW(self), txt ? txt : "");
}
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, MU_MSG_OPTION_NONE) : "";
if (data)
set_html(self, data);
else
set_text(self, mu_msg_get_body_text(msg, MU_MSG_OPTION_NONE));
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

@ -1,71 +0,0 @@
/*
** Copyright (C) 2011-2021 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_HH__
#define MU_MSG_BODY_VIEW_HH__
#include <webkit2/webkit2.h>
#include <mu-msg.hh>
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, Mu::MuMsg* msg);
void mu_msg_body_view_set_note(MuMsgBodyView* self, const gchar* html);
void mu_msg_body_view_set_message_source(MuMsgBodyView* self, Mu::MuMsg* msg);
G_END_DECLS
#endif /* MU_MSG_BODY_VIEW_HH__ */

View File

@ -1,180 +0,0 @@
/*
** Copyright (C) 2011-2020 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 <config.h>
#include "mu-msg-header-view.hh"
#include "mu-msg.hh"
#include <utils/mu-str.h>
#include <utils/mu-utils.hh>
using namespace Mu;
/* '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* _grid;
};
#define MU_MSG_HEADER_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), MU_TYPE_MSG_HEADER_VIEW, MuMsgHeaderViewPrivate))
/* globals */
static GtkBoxClass* parent_class = NULL;
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
G_DEFINE_TYPE(MuMsgHeaderView, mu_msg_header_view, GTK_TYPE_BOX);
static void
mu_msg_header_view_class_init(MuMsgHeaderViewClass* klass)
{
GObjectClass* gobject_class;
gobject_class = (GObjectClass*)klass;
parent_class = (GtkBoxClass*)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)
{
/* static GtkBoxClass *parent_class = NULL; */
obj->_priv = MU_MSG_HEADER_VIEW_GET_PRIVATE(obj);
obj->_priv->_grid = 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;
}
G_GNUC_UNUSED static gboolean
add_row(GtkWidget* grid, guint row, const char* fieldname, const char* value, gboolean showempty)
{
GtkWidget *label, *al;
if (!value && !showempty)
return FALSE;
gtk_grid_insert_row(GTK_GRID(grid), row);
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_grid_attach(GTK_GRID(grid), al, 0, row, 1, 1);
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_grid_attach(GTK_GRID(grid), al, 1, row, 1, 1);
return TRUE;
}
static GtkWidget*
get_grid(Mu::MuMsg* msg)
{
GtkWidget* grid;
int row;
row = 0;
grid = gtk_grid_new(); /* 5 2 */
gtk_grid_insert_column(GTK_GRID(grid), 0);
gtk_grid_insert_column(GTK_GRID(grid), 1);
if (add_row(grid, row, "From", mu_msg_get_from(msg), TRUE))
++row;
if (add_row(grid, row, "To", mu_msg_get_to(msg), FALSE))
++row;
if (add_row(grid, row, "Cc", mu_msg_get_cc(msg), FALSE))
++row;
if (add_row(grid, row, "Subject", mu_msg_get_subject(msg), TRUE))
++row;
if (add_row(grid, row, "Date",
time_to_string("%c", mu_msg_get_date(msg)).c_str(), TRUE))
++row;
return grid;
}
void
mu_msg_header_view_set_message(MuMsgHeaderView* self, Mu::MuMsg* msg)
{
g_return_if_fail(MU_IS_MSG_HEADER_VIEW(self));
if (self->_priv->_grid) {
gtk_container_remove(GTK_CONTAINER(self), self->_priv->_grid);
self->_priv->_grid = NULL;
}
if (msg) {
self->_priv->_grid = get_grid(msg);
gtk_box_pack_start(GTK_BOX(self), self->_priv->_grid, TRUE, TRUE, 0);
gtk_widget_show_all(self->_priv->_grid);
}
}

View File

@ -1,69 +0,0 @@
/*
** Copyright (C) 2011-2020 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.hh>
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 {
GtkBox parent;
/* insert public members, if any */
/* private */
MuMsgHeaderViewPrivate* _priv;
};
struct _MuMsgHeaderViewClass {
GtkBoxClass parent_class;
/* 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);
struct MuMsg;
void mu_msg_header_view_set_message(MuMsgHeaderView* self, Mu::MuMsg* msg);
G_END_DECLS
#endif /* __MU_MSG_HEADER_VIEW_H__ */

View File

@ -1,224 +0,0 @@
/*
** Copyright (C) 2011-2020 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 <config.h>
#include "mu-msg-view.hh"
#include "mu-msg-body-view.hh"
#include "mu-msg-header-view.hh"
#include "mu-msg-attach-view.hh"
#include <utils/mu-util.h>
#include <mu-msg.hh>
#include <mu-msg-part.hh>
using namespace Mu;
/* '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;
Mu::MuMsg* _msg;
};
#define MU_MSG_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), MU_TYPE_MSG_VIEW, MuMsgViewPrivate))
/* globals */
static GtkBoxClass* parent_class = NULL;
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
G_DEFINE_TYPE(MuMsgView, mu_msg_view, GTK_TYPE_BOX);
static void
set_message(MuMsgView* self, Mu::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 = (GtkBoxClass*)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, Mu::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)
{
gtk_orientable_set_orientation(GTK_ORIENTABLE(self), GTK_ORIENTATION_VERTICAL);
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, Mu::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, Mu::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);
}

View File

@ -1,68 +0,0 @@
/*
** Copyright (C) 2011-2020Dirk-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.hh"
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 {
GtkBox parent;
/* private */
MuMsgViewPrivate* _priv;
};
struct _MuMsgViewClass {
GtkBoxClass parent_class;
/* 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);
struct MuMsg;
void mu_msg_view_set_message(MuMsgView* self, Mu::MuMsg* msg);
void mu_msg_view_set_note(MuMsgView* self, const gchar* html);
void mu_msg_view_set_message_source(MuMsgView* self, Mu::MuMsg* msg);
G_END_DECLS
#endif /* __MU_MSG_VIEW_H__ */

View File

@ -1,94 +0,0 @@
/*
** Copyright (C) 2011-2013 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;
GError *err;
icon = g_content_type_get_icon (ctype);
pixbuf = NULL;
err = 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, &err);
} 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, &err);
g_free (path);
g_object_unref(icon_file);
}
g_object_unref(icon);
if (err) {
g_warning ("error: %s\n", err->message);
g_clear_error (&err);
}
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;
}

View File

@ -1,42 +0,0 @@
/*
** Copyright (C) 2011-2013 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>
G_BEGIN_DECLS
/**
* 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;
G_END_DECLS
#endif /*__MU_WIDGET_UTIL_H__*/

View File

@ -1,430 +0,0 @@
/*
** Copyright (C) 2008-2022 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 "mug-msg-list-view.h"
#include "message/mu-message.hh"
#include "mu-query.hh"
#include "utils/mu-str.h"
using namespace Mu;
/* 'private'/'protected' functions */
static void mug_msg_list_view_finalize(GObject* obj);
/* list my signals */
enum { MUG_MSG_SELECTED, MUG_ERROR_OCCURED, LAST_SIGNAL };
enum {
MUG_COL_DATESTR,
MUG_COL_MAILDIR,
MUG_COL_FLAGSSTR,
MUG_COL_FROM,
MUG_COL_TO,
MUG_COL_SUBJECT,
MUG_COL_PATH,
MUG_COL_PRIO,
MUG_COL_FLAGS,
MUG_COL_TIME,
MUG_N_COLS
};
typedef struct _MugMsgListViewPrivate MugMsgListViewPrivate;
struct _MugMsgListViewPrivate {
GtkTreeStore* _store;
char* _xpath;
char* _query;
};
#define MUG_MSG_LIST_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), MUG_TYPE_MSG_LIST_VIEW, MugMsgListViewPrivate))
/* globals */
static GtkTreeViewClass* parent_class = NULL;
/* uncomment the following if you have defined any signals */
static guint signals[LAST_SIGNAL] = {0};
G_DEFINE_TYPE(MugMsgListView, mug_msg_list_view, GTK_TYPE_TREE_VIEW);
static void
mug_msg_list_view_class_init(MugMsgListViewClass* klass)
{
GObjectClass* gobject_class;
gobject_class = (GObjectClass*)klass;
parent_class = (GtkTreeViewClass*)g_type_class_peek_parent(klass);
gobject_class->finalize = mug_msg_list_view_finalize;
g_type_class_add_private(gobject_class, sizeof(MugMsgListViewPrivate));
signals[MUG_MSG_SELECTED] = g_signal_new("msg-selected",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(MugMsgListViewClass, msg_selected),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
1,
G_TYPE_STRING);
signals[MUG_ERROR_OCCURED] =
g_signal_new("error-occured",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(MugMsgListViewClass, error_occured),
NULL,
NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE,
1,
G_TYPE_UINT);
}
static void
on_cursor_changed(GtkTreeView* tview, MugMsgListView* lst)
{
GtkTreeSelection* sel;
GtkTreeIter iter;
MugMsgListViewPrivate* priv;
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(tview);
sel = gtk_tree_view_get_selection(tview);
if (!sel)
return; /* hmmm */
if (gtk_tree_selection_get_selected(sel, NULL, &iter)) {
char* path;
gtk_tree_model_get(GTK_TREE_MODEL(priv->_store), &iter, MUG_COL_PATH, &path, -1);
g_signal_emit(G_OBJECT(lst), signals[MUG_MSG_SELECTED], 0, path);
g_free(path);
}
}
static void
treecell_func(GtkTreeViewColumn* tree_column,
GtkCellRenderer* renderer,
GtkTreeModel* tree_model,
GtkTreeIter* iter,
gpointer data)
{
Flags flags;
Priority prio;
gtk_tree_model_get(tree_model, iter, MUG_COL_FLAGS, &flags, MUG_COL_PRIO, &prio, -1);
g_object_set(G_OBJECT(renderer),
"weight",
any_of(flags & Flags::New) ? 800 : 400,
"weight",
any_of(flags & Flags::Seen) ? 400 : 800,
"foreground",
prio == Priority::High ? "red" : NULL,
NULL);
}
/* sortcolidx == -1 means 'sortcolidx = colidx' */
static void
append_col(GtkTreeView* treeview, const char* label, int colidx, int sortcolidx, gint maxwidth)
{
GtkTreeViewColumn* col;
GtkCellRenderer* renderer;
renderer = gtk_cell_renderer_text_new();
g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
col = gtk_tree_view_column_new_with_attributes(label, renderer, "text", colidx, NULL);
g_object_set(G_OBJECT(col), "resizable", TRUE, NULL);
gtk_tree_view_column_set_sort_indicator(col, TRUE);
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_fixed_width(col, maxwidth);
gtk_tree_view_column_set_expand(col, FALSE);
} else
gtk_tree_view_column_set_expand(col, TRUE);
gtk_tree_view_column_set_cell_data_func(col,
renderer,
(GtkTreeCellDataFunc)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
mug_msg_list_view_init(MugMsgListView* obj)
{
MugMsgListViewPrivate* priv;
GtkTreeView* tview;
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(obj);
priv->_xpath = priv->_query = NULL;
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 */
tview = GTK_TREE_VIEW(obj);
gtk_tree_view_set_model(tview, GTK_TREE_MODEL(priv->_store));
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(obj), TRUE);
gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(obj), GTK_TREE_VIEW_GRID_LINES_VERTICAL);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(obj), TRUE);
append_col(tview, "Date", MUG_COL_DATESTR, MUG_COL_TIME, 80);
append_col(tview, "Folder", MUG_COL_MAILDIR, -1, 60);
append_col(tview, "F", MUG_COL_FLAGSSTR, -1, 25);
append_col(tview, "From", MUG_COL_FROM, -1, 0);
append_col(tview, "To", MUG_COL_TO, -1, 0);
append_col(tview, "Subject", MUG_COL_SUBJECT, -1, 0);
g_signal_connect(G_OBJECT(obj), "cursor-changed", G_CALLBACK(on_cursor_changed), obj);
}
static void
mug_msg_list_view_finalize(GObject* obj)
{
MugMsgListViewPrivate* priv;
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(obj);
if (priv->_store)
g_object_unref(priv->_store);
g_free(priv->_xpath);
g_free(priv->_query);
G_OBJECT_CLASS(parent_class)->finalize(obj);
}
void
mug_msg_list_view_move_first(MugMsgListView* self)
{
GtkTreePath* path;
g_return_if_fail(MUG_IS_MSG_LIST_VIEW(self));
path = gtk_tree_path_new_first();
gtk_tree_view_set_cursor(GTK_TREE_VIEW(self), path, NULL, FALSE);
gtk_tree_path_free(path);
}
static gboolean
msg_list_view_move(MugMsgListView* self, gboolean next)
{
GtkTreePath* path;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(self), &path, NULL);
if (!path)
return FALSE;
if (next)
gtk_tree_path_next(path);
else
gtk_tree_path_prev(path);
gtk_tree_view_set_cursor(GTK_TREE_VIEW(self), path, NULL, FALSE);
gtk_tree_path_free(path);
return TRUE;
}
gboolean
mug_msg_list_view_move_next(MugMsgListView* self)
{
g_return_val_if_fail(MUG_IS_MSG_LIST_VIEW(self), FALSE);
return msg_list_view_move(self, TRUE);
}
gboolean
mug_msg_list_view_move_prev(MugMsgListView* self)
{
g_return_val_if_fail(MUG_IS_MSG_LIST_VIEW(self), FALSE);
return msg_list_view_move(self, FALSE);
}
GtkWidget*
mug_msg_list_view_new(const char* xpath)
{
GtkWidget* w;
MugMsgListViewPrivate* priv;
g_return_val_if_fail(xpath, NULL);
w = GTK_WIDGET(g_object_new(MUG_TYPE_MSG_LIST_VIEW, NULL));
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(w);
priv->_xpath = g_strdup(xpath);
return w;
}
static gchar*
empty_or_display_contact(const gchar* str)
{
if (!str || *str == '\0')
return g_strdup("-");
else
return mu_str_display_contact(str);
}
static Mu::Option<Mu::QueryResults>
run_query(const char* xpath, const char* expr, MugMsgListView* self)
{
Mu::Store store{xpath};
return store.run_query(expr,
Field::Id::Date,
Mu::QueryFlags::Descending | Mu::QueryFlags::SkipUnreadable |
Mu::QueryFlags::SkipDuplicates | Mu::QueryFlags::IncludeRelated |
Mu::QueryFlags::Threading);
}
static void
add_row(GtkTreeStore* store, MuMsg* msg, GtkTreeIter* treeiter)
{
gchar * from, *to;
time_t timeval;
std::string flag_str;
timeval = mu_msg_get_date(msg);
const auto datestr{timeval == 0 ?
std::string{"-"} : time_to_string("%c", timeval)};
from = empty_or_display_contact(mu_msg_get_from(msg));
to = empty_or_display_contact(mu_msg_get_to(msg));
flag_str = to_string(mu_msg_get_flags(msg));
/* 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",
* __func__, path); */
/* } */
gtk_tree_store_set(store,
treeiter,
MUG_COL_DATESTR,
datestr,
MUG_COL_MAILDIR,
mu_msg_get_maildir(msg),
MUG_COL_FLAGSSTR,
flag_str.c_str(),
MUG_COL_FROM,
from,
MUG_COL_TO,
to,
MUG_COL_SUBJECT,
mu_msg_get_subject(msg),
MUG_COL_PATH,
mu_msg_get_path(msg),
MUG_COL_PRIO,
mu_msg_get_prio(msg),
MUG_COL_FLAGS,
mu_msg_get_flags(msg),
MUG_COL_TIME,
datestr.c_str(),
-1);
g_free(from);
g_free(to);
}
static int
update_model(GtkTreeStore* store, const char* xpath, const char* query, MugMsgListView* self)
{
const auto res{run_query(xpath, query, self)};
if (!res) {
g_warning("error: running query failed");
return -1;
}
auto count{0};
std::string prev_thread_path;
for (auto&& it : *res) {
GtkTreeIter treeiter, prev_treeiter;
const auto thread_path{it.query_match().thread_path};
if (prev_thread_path.find(thread_path) == 0)
gtk_tree_store_append(store, &treeiter, &prev_treeiter);
else
gtk_tree_store_append(store, &treeiter, NULL);
/* don't unref msg */
add_row(store, it.floating_msg(), &treeiter);
// prev_ti = ti;
prev_treeiter = treeiter;
prev_thread_path = thread_path;
++count;
}
return count;
}
int
mug_msg_list_view_query(MugMsgListView* self, const char* query)
{
MugMsgListViewPrivate* priv;
gboolean rv;
g_return_val_if_fail(MUG_IS_MSG_LIST_VIEW(self), FALSE);
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(self);
gtk_tree_store_clear(priv->_store);
g_free(priv->_query);
priv->_query = query ? g_strdup(query) : NULL;
if (!query)
return TRUE;
rv = update_model(priv->_store, priv->_xpath, query, self);
gtk_tree_view_expand_all(GTK_TREE_VIEW(self));
return rv;
}
const gchar*
mug_msg_list_view_get_query(MugMsgListView* self)
{
g_return_val_if_fail(MUG_IS_MSG_LIST_VIEW(self), NULL);
return MUG_MSG_LIST_VIEW_GET_PRIVATE(self)->_query;
}

View File

@ -1,82 +0,0 @@
/*
** Copyright (C) 2008-2013 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 __MUG_MSG_LIST_VIEW_H__
#define __MUG_MSG_LIST_VIEW_H__
#include <gtk/gtk.h>
#include <utils/mu-util.h>
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_MSG_LIST_VIEW (mug_msg_list_view_get_type())
#define MUG_MSG_LIST_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MUG_TYPE_MSG_LIST_VIEW,MugMsgListView))
#define MUG_MSG_LIST_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MUG_TYPE_MSG_LIST_VIEW,MugMsgListViewClass))
#define MUG_IS_MSG_LIST_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MUG_TYPE_MSG_LIST_VIEW))
#define MUG_IS_MSG_LIST_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MUG_TYPE_MSG_LIST_VIEW))
#define MUG_MSG_LIST_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MUG_TYPE_MSG_LIST_VIEW,MugMsgListViewClass))
typedef struct _MugMsgListView MugMsgListView;
typedef struct _MugMsgListViewClass MugMsgListViewClass;
struct _MugMsgListView {
GtkTreeView parent;
/* insert public members, if any */
};
enum _MugError {
MUG_ERROR_XAPIAN_NOT_UPTODATE,
MUG_ERROR_XAPIAN_DIR,
MUG_ERROR_QUERY,
MUG_ERROR_OTHER
};
typedef enum _MugError MugError;
struct _MugMsgListViewClass {
GtkTreeViewClass parent_class;
/* insert signal callback declarations, e.g. */
void (*msg_selected) (MugMsgListView * obj, const char *msgpath);
void (*error_occured) (MugMsgListView * obj, MugError err);
};
/* member functions */
GType
mug_msg_list_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_list_view_new (const char *xpath);
int
mug_msg_list_view_query (MugMsgListView * self, const char *query);
void
mug_msg_list_view_move_first (MugMsgListView * self);
gboolean
mug_msg_list_view_move_prev (MugMsgListView * self);
gboolean
mug_msg_list_view_move_next (MugMsgListView * self);
const gchar *
mug_msg_list_view_get_query (MugMsgListView * self);
G_END_DECLS
#endif /* __MUG_MSG_LIST_VIEW_H__ */

View File

@ -1,148 +0,0 @@
/*
** Copyright (C) 2008-2020 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 "config.h"
#include <unistd.h>
#include "mu-msg-view.hh"
#include "mug-msg-view.h"
#include "mu-msg.hh"
#include "utils/mu-str.h"
using namespace Mu;
/* 'private'/'protected' functions */
static void mug_msg_view_class_init(MugMsgViewClass* klass);
static void mug_msg_view_init(MugMsgView* obj);
static void mug_msg_view_finalize(GObject* obj);
/* list my signals */
enum {
/* MY_SIGNAL_1, */
/* MY_SIGNAL_2, */
LAST_SIGNAL
};
typedef struct _MugMsgViewPrivate MugMsgViewPrivate;
struct _MugMsgViewPrivate {
GtkWidget* _view;
};
#define MUG_MSG_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), MUG_TYPE_MSG_VIEW, MugMsgViewPrivate))
/* globals */
static GtkBoxClass* parent_class = NULL;
G_DEFINE_TYPE(MugMsgView, mug_msg_view, GTK_TYPE_BOX);
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
static void
mug_msg_view_class_init(MugMsgViewClass* klass)
{
GObjectClass* gobject_class;
gobject_class = (GObjectClass*)klass;
parent_class = (GtkBoxClass*)g_type_class_peek_parent(klass);
gobject_class->finalize = mug_msg_view_finalize;
g_type_class_add_private(gobject_class, sizeof(MugMsgViewPrivate));
/* 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
mug_msg_view_init(MugMsgView* obj)
{
MugMsgViewPrivate* priv;
GtkWidget* scrolled;
priv = MUG_MSG_VIEW_GET_PRIVATE(obj);
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_box_pack_start(GTK_BOX(obj), scrolled, TRUE, TRUE, 0);
}
static void
mug_msg_view_finalize(GObject* obj)
{
/* free/unref instance resources here */
G_OBJECT_CLASS(parent_class)->finalize(obj);
}
GtkWidget*
mug_msg_view_new(void)
{
return GTK_WIDGET(g_object_new(MUG_TYPE_MSG_VIEW, NULL));
}
gboolean
mug_msg_view_set_msg(MugMsgView* self, const char* msgpath)
{
MugMsgViewPrivate* priv;
g_return_val_if_fail(MUG_IS_MSG_VIEW(self), FALSE);
priv = MUG_MSG_VIEW_GET_PRIVATE(self);
if (!msgpath)
mu_msg_view_set_message(MU_MSG_VIEW(priv->_view), NULL);
else {
Mu::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);
}
}
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

@ -1,58 +0,0 @@
/*
** Copyright (C) 2010-2013 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 __MUG_MSG_VIEW_H__
#define __MUG_MSG_VIEW_H__
#include <gtk/gtk.h>
/* other include files */
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_MSG_VIEW (mug_msg_view_get_type())
#define MUG_MSG_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MUG_TYPE_MSG_VIEW,MugMsgView))
#define MUG_MSG_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MUG_TYPE_MSG_VIEW,MugMsgViewClass))
#define MUG_IS_MSG_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MUG_TYPE_MSG_VIEW))
#define MUG_IS_MSG_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MUG_TYPE_MSG_VIEW))
#define MUG_MSG_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MUG_TYPE_MSG_VIEW,MugMsgViewClass))
typedef struct _MugMsgView MugMsgView;
typedef struct _MugMsgViewClass MugMsgViewClass;
struct _MugMsgView {
GtkBox parent;
};
struct _MugMsgViewClass {
GtkBoxClass parent_class;
/* insert signal callback declarations, e.g. */
/* void (* my_event) (MugMsg* obj); */
};
/* member functions */
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);
void mug_msg_view_set_note (MugMsgView * self, const char* html);
G_END_DECLS
#endif /* __MUG_MSG_VIEW_H__ */

View File

@ -1,112 +0,0 @@
/* mug-query-bar.c */
/* insert (c)/licensing information) */
#include "mug-query-bar.h"
/* include other impl specific header files */
/* 'private'/'protected' functions */
static void mug_query_bar_class_init (MugQueryBarClass * klass);
static void mug_query_bar_init (MugQueryBar * obj);
static void mug_query_bar_finalize (GObject * obj);
/* list my signals */
enum {
MUG_QUERY_CHANGED,
LAST_SIGNAL
};
typedef struct _MugQueryBarPrivate MugQueryBarPrivate;
struct _MugQueryBarPrivate {
GtkWidget *_entry;
};
#define MUG_QUERY_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MUG_TYPE_QUERY_BAR, \
MugQueryBarPrivate))
/* globals */
static GtkContainerClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_BOX);
static void
mug_query_bar_class_init (MugQueryBarClass * klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = mug_query_bar_finalize;
g_type_class_add_private (gobject_class, sizeof (MugQueryBarPrivate));
/* signal definitions go here, e.g.: */
signals[MUG_QUERY_CHANGED] =
g_signal_new ("query_changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MugQueryBarClass, query_changed),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
on_entry_activated (GtkWidget * w, MugQueryBar * bar)
{
g_signal_emit (G_OBJECT (bar), signals[MUG_QUERY_CHANGED], 0,
gtk_entry_get_text (GTK_ENTRY (w)));
}
static void
mug_query_bar_init (MugQueryBar * obj)
{
MugQueryBarPrivate *priv;
priv = MUG_QUERY_BAR_GET_PRIVATE (obj);
priv->_entry = gtk_entry_new ();
g_signal_connect (priv->_entry, "activate",
G_CALLBACK (on_entry_activated), obj);
gtk_box_pack_start (GTK_BOX (obj), priv->_entry, TRUE, TRUE, 0);
}
static void
mug_query_bar_finalize (GObject * obj)
{
/* free/unref instance resources here */
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
GtkWidget *
mug_query_bar_new (void)
{
return GTK_WIDGET (g_object_new (MUG_TYPE_QUERY_BAR, NULL));
}
void
mug_query_bar_set_query (MugQueryBar * self, const char *query, gboolean run)
{
MugQueryBarPrivate *priv;
g_return_if_fail (MUG_IS_QUERY_BAR (self));
priv = MUG_QUERY_BAR_GET_PRIVATE (self);
gtk_entry_set_text (GTK_ENTRY (priv->_entry), query ? query : "");
if (run)
on_entry_activated (priv->_entry, self);
}
void
mug_query_bar_grab_focus (MugQueryBar * self)
{
g_return_if_fail (MUG_IS_QUERY_BAR (self));
gtk_widget_grab_focus
(GTK_WIDGET (MUG_QUERY_BAR_GET_PRIVATE (self)->_entry));
}

View File

@ -1,52 +0,0 @@
/* mug-query-bar.h */
/* insert (c)/licensing information) */
#ifndef __MUG_QUERY_BAR_H__
#define __MUG_QUERY_BAR_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG*/
#include <gtk/gtk.h>
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_QUERY_BAR (mug_query_bar_get_type())
#define MUG_QUERY_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MUG_TYPE_QUERY_BAR,MugQueryBar))
#define MUG_QUERY_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MUG_TYPE_QUERY_BAR,MugQueryBarClass))
#define MUG_IS_QUERY_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MUG_TYPE_QUERY_BAR))
#define MUG_IS_QUERY_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MUG_TYPE_QUERY_BAR))
#define MUG_QUERY_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MUG_TYPE_QUERY_BAR,MugQueryBarClass))
typedef struct _MugQueryBar MugQueryBar;
typedef struct _MugQueryBarClass MugQueryBarClass;
struct _MugQueryBar {
GtkBox parent;
};
struct _MugQueryBarClass {
GtkBox parent;
GtkBoxClass parent_class;
/* insert signal callback declarations, e.g. */
void (*query_changed) (MugQueryBar * obj, const char *query);
};
/* member functions */
GType
mug_query_bar_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_query_bar_new (void);
void
mug_query_bar_grab_focus (MugQueryBar * self);
void
mug_query_bar_set_query (MugQueryBar * self, const char *query, gboolean run);
G_END_DECLS
#endif /* __MUG_QUERY_BAR_H__ */

View File

@ -1,148 +0,0 @@
/*
** Copyright (C) 2010-2020 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 "mug-shortcuts.h"
#include "mu-bookmarks.hh"
/* include other impl specific header files */
/* 'private'/'protected' functions */
static void mug_shortcuts_class_init(MugShortcutsClass* klass);
static void mug_shortcuts_init(MugShortcuts* obj);
static void mug_shortcuts_finalize(GObject* obj);
#define MUG_SHORTCUT_BOOKMARK "bookmark"
/* list my signals */
enum {
SHORTCUT_CLICKED,
/* MY_SIGNAL_1, */
/* MY_SIGNAL_2, */
LAST_SIGNAL
};
struct _MugShortcutsPrivate {
GtkWidget* _bbox;
};
#define MUG_SHORTCUTS_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), MUG_TYPE_SHORTCUTS, MugShortcutsPrivate))
/* globals */
static guint signals[LAST_SIGNAL] = {0};
static GtkBoxClass* parent_class = NULL;
G_DEFINE_TYPE(MugShortcuts, mug_shortcuts, GTK_TYPE_BOX);
static void
mug_shortcuts_class_init(MugShortcutsClass* klass)
{
GObjectClass* gobject_class;
gobject_class = (GObjectClass*)klass;
parent_class = (GtkBoxClass*)g_type_class_peek_parent(klass);
gobject_class->finalize = mug_shortcuts_finalize;
g_type_class_add_private(gobject_class, sizeof(MugShortcutsPrivate));
/* signal definitions go here, e.g.: */
signals[SHORTCUT_CLICKED] = g_signal_new("clicked",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(MugShortcutsClass, clicked),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
1,
G_TYPE_STRING);
/* signals[MY_SIGNAL_2] = */
/* g_signal_new ("my_signal_2",....); */
/* etc. */
}
static void
mug_shortcuts_init(MugShortcuts* obj)
{
obj->_priv = MUG_SHORTCUTS_GET_PRIVATE(obj);
obj->_priv->_bbox = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
gtk_button_box_set_layout(GTK_BUTTON_BOX(obj->_priv->_bbox), GTK_BUTTONBOX_START);
gtk_box_pack_start(GTK_BOX(obj), obj->_priv->_bbox, TRUE, TRUE, 0);
}
static void
mug_shortcuts_finalize(GObject* obj)
{
/* free/unref instance resources here */
G_OBJECT_CLASS(parent_class)->finalize(obj);
}
static void
on_button_clicked(GtkWidget* button, MugShortcuts* self)
{
g_signal_emit(G_OBJECT(self),
signals[SHORTCUT_CLICKED],
0,
(const gchar*)g_object_get_data(G_OBJECT(button), MUG_SHORTCUT_BOOKMARK));
}
static void
each_bookmark(const char* key, const char* val, MugShortcuts* self)
{
GtkWidget* button;
button = gtk_button_new_with_label(key);
g_object_set_data_full(G_OBJECT(button), MUG_SHORTCUT_BOOKMARK, g_strdup(val), g_free);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_button_clicked), self);
gtk_container_add(GTK_CONTAINER(self->_priv->_bbox), button);
}
static gboolean
init_shortcuts(MugShortcuts* self, const char* bmpath)
{
MuBookmarks* bookmarks;
bookmarks = mu_bookmarks_new(bmpath);
if (!bookmarks)
return TRUE;
mu_bookmarks_foreach(bookmarks, (MuBookmarksForeachFunc)each_bookmark, self);
mu_bookmarks_destroy(bookmarks);
return TRUE;
}
GtkWidget*
mug_shortcuts_new(const char* bmpath)
{
MugShortcuts* self;
self = MUG_SHORTCUTS(g_object_new(MUG_TYPE_SHORTCUTS, NULL));
if (!init_shortcuts(self, bmpath)) {
g_object_unref(self);
return NULL;
}
return GTK_WIDGET(self);
}
/* following: other function implementations */
/* such as mug_shortcuts_do_something, or mug_shortcuts_has_foo */

View File

@ -1,68 +0,0 @@
/*
** Copyright (C) 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
** 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 __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 */
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_SHORTCUTS (mug_shortcuts_get_type())
#define MUG_SHORTCUTS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MUG_TYPE_SHORTCUTS,MugShortcuts))
#define MUG_SHORTCUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MUG_TYPE_SHORTCUTS,MugShortcutsClass))
#define MUG_IS_SHORTCUTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MUG_TYPE_SHORTCUTS))
#define MUG_IS_SHORTCUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MUG_TYPE_SHORTCUTS))
#define MUG_SHORTCUTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MUG_TYPE_SHORTCUTS,MugShortcutsClass))
typedef struct _MugShortcuts MugShortcuts;
typedef struct _MugShortcutsClass MugShortcutsClass;
typedef struct _MugShortcutsPrivate MugShortcutsPrivate;
struct _MugShortcuts {
GtkBox parent;
/* private */
MugShortcutsPrivate *_priv;
};
struct _MugShortcutsClass {
GtkBoxClass parent_class;
void (*clicked) (MugShortcuts * obj, const char *query);
};
/* member functions */
GType mug_shortcuts_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_shortcuts_new (const char *bmpath);
/* fill in other public functions, e.g.: */
/* void mug_shortcuts_do_something (MugShortcuts *self, const gchar* param); */
/* gboolean mug_shortcuts_has_foo (MugShortcuts *self, gint value); */
G_END_DECLS
#endif /* __MUG_SHORTCUTS_H__ */

View File

@ -1,401 +0,0 @@
/*
** Copyright (C) 2010-2020 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 "config.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h> /* for memset */
#include <utils/mu-util.h>
#include <mu-store.hh>
#include <mu-runtime.hh>
#include "mug-msg-list-view.h"
#include "mug-query-bar.h"
#include "mug-msg-view.h"
#include "mug-shortcuts.h"
struct _MugData {
GtkWidget* win;
GtkWidget* statusbar;
GtkWidget* mlist;
GtkWidget* toolbar;
GtkWidget* msgview;
GtkWidget* querybar;
GtkWidget* shortcuts;
gchar* muhome;
};
typedef struct _MugData MugData;
static void
about_mug(MugData* mugdata)
{
GtkWidget* about;
about = gtk_message_dialog_new(GTK_WINDOW(mugdata->win),
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Mug version %s\n"
"A graphical frontend to the 'mu' e-mail search engine\n\n"
"(c) 2010-2013 Dirk-Jan C. Binnema\n"
"Released under the terms of the GPLv3+",
VERSION);
gtk_dialog_run(GTK_DIALOG(about));
gtk_widget_destroy(about);
}
enum _ToolAction {
ACTION_PREV_MSG = 1,
ACTION_NEXT_MSG,
ACTION_REINDEX,
ACTION_DO_QUIT,
ACTION_ABOUT,
ACTION_SEPARATOR /* pseudo action */
};
typedef enum _ToolAction ToolAction;
static void
on_tool_button_clicked(GtkToolButton* btn, MugData* mugdata)
{
ToolAction action;
action = (ToolAction)GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(btn), "action"));
switch (action) {
case ACTION_DO_QUIT: gtk_main_quit(); break;
case ACTION_NEXT_MSG: mug_msg_list_view_move_next(MUG_MSG_LIST_VIEW(mugdata->mlist)); break;
case ACTION_PREV_MSG: mug_msg_list_view_move_prev(MUG_MSG_LIST_VIEW(mugdata->mlist)); break;
case ACTION_ABOUT: about_mug(mugdata); break;
default: g_print("%u\n", action);
}
}
static GtkToolItem*
tool_button(const char* name)
{
GtkWidget* icon;
icon = gtk_image_new_from_icon_name(name, GTK_ICON_SIZE_SMALL_TOOLBAR);
return gtk_menu_tool_button_new(icon, NULL);
}
static GtkToolItem*
get_connected_tool_button(const char* stock_id, ToolAction action, MugData* mugdata)
{
GtkToolItem* btn;
btn = tool_button(stock_id);
g_object_set_data(G_OBJECT(btn), "action", GUINT_TO_POINTER(action));
g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(on_tool_button_clicked), mugdata);
return btn;
}
static GtkWidget*
mug_toolbar(MugData* mugdata)
{
GtkWidget* toolbar;
int i;
struct {
const char* stock_id;
ToolAction action;
} tools[] = {{"go-up", ACTION_PREV_MSG},
{"go-down", ACTION_NEXT_MSG},
{NULL, ACTION_SEPARATOR},
{"view-refresh", ACTION_REINDEX},
{NULL, ACTION_SEPARATOR},
{"help-about", ACTION_ABOUT},
{NULL, ACTION_SEPARATOR},
{"application-exit", ACTION_DO_QUIT}};
toolbar = gtk_toolbar_new();
for (i = 0; i != G_N_ELEMENTS(tools); ++i) {
if (tools[i].action == ACTION_SEPARATOR) { /* separator? */
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), i);
continue;
} else /* nope: a real item */
gtk_toolbar_insert(
GTK_TOOLBAR(toolbar),
get_connected_tool_button(tools[i].stock_id, tools[i].action, mugdata),
i);
}
return toolbar;
}
static void
on_shortcut_clicked(GtkWidget* w, const gchar* query, MugData* mdata)
{
mug_query_bar_set_query(MUG_QUERY_BAR(mdata->querybar), query, TRUE);
}
static GtkWidget*
mug_shortcuts_bar(MugData* data)
{
data->shortcuts = mug_shortcuts_new(mu_runtime_path(MU_RUNTIME_PATH_BOOKMARKS));
g_signal_connect(G_OBJECT(data->shortcuts),
"clicked",
G_CALLBACK(on_shortcut_clicked),
data);
return data->shortcuts;
}
static GtkWidget*
mug_statusbar(void)
{
GtkWidget* statusbar;
statusbar = gtk_statusbar_new();
return statusbar;
}
static void
on_query_changed(MugQueryBar* bar, const char* query, MugData* mugdata)
{
int count;
/* clear the old message */
mug_msg_view_set_msg(MUG_MSG_VIEW(mugdata->msgview), NULL);
count = mug_msg_list_view_query(MUG_MSG_LIST_VIEW(mugdata->mlist), query);
if (count >= 0) {
gchar* msg =
g_strdup_printf("%d message%s found matching '%s'",
count,
count > 1 ? "s" : "",
mug_msg_list_view_get_query(MUG_MSG_LIST_VIEW(mugdata->mlist)));
gtk_statusbar_push(GTK_STATUSBAR(mugdata->statusbar), 0, msg);
g_free(msg);
mug_msg_list_view_move_first(MUG_MSG_LIST_VIEW(mugdata->mlist));
gtk_widget_grab_focus(GTK_WIDGET(mugdata->mlist));
}
if (count == 0) /* nothing found */
mug_query_bar_grab_focus(MUG_QUERY_BAR(bar));
}
static void
on_msg_selected(MugMsgListView* mlist, const char* mpath, MugData* mugdata)
{
mug_msg_view_set_msg(MUG_MSG_VIEW(mugdata->msgview), mpath);
}
static void
on_list_view_error(MugMsgListView* mlist, MugError err, MugData* mugdata)
{
GtkWidget* errdialog;
const char* msg;
switch (err) {
case MUG_ERROR_XAPIAN_NOT_UPTODATE:
msg = "The Xapian Database has the wrong version\n"
"Please run 'mu init'";
break;
case MUG_ERROR_XAPIAN_DIR:
msg = "Cannot find the Xapian database dir\n"
"Please restart mug with --muhome=... pointing\n"
"to your mu home directory";
break;
case MUG_ERROR_QUERY: msg = "Error in query"; break;
default: msg = "Some error occurred"; break;
}
errdialog = gtk_message_dialog_new(GTK_WINDOW(mugdata->win),
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
"%s",
msg);
gtk_dialog_run(GTK_DIALOG(errdialog));
gtk_widget_destroy(errdialog);
if (err == MUG_ERROR_QUERY)
mug_query_bar_grab_focus(MUG_QUERY_BAR(mugdata->querybar));
}
static GtkWidget*
mug_querybar(void)
{
GtkWidget* querybar;
querybar = mug_query_bar_new();
return querybar;
}
static GtkWidget*
mug_query_area(MugData* mugdata)
{
GtkWidget *queryarea, *paned, *scrolled;
queryarea = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
paned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
mugdata->mlist = mug_msg_list_view_new(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB));
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), mugdata->mlist);
gtk_paned_add1(GTK_PANED(paned), scrolled);
mugdata->msgview = mug_msg_view_new();
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",
G_CALLBACK(on_list_view_error),
mugdata);
gtk_paned_add2(GTK_PANED(paned), mugdata->msgview);
mugdata->querybar = mug_querybar();
g_signal_connect(G_OBJECT(mugdata->querybar),
"query-changed",
G_CALLBACK(on_query_changed),
mugdata);
gtk_box_pack_start(GTK_BOX(queryarea), mugdata->querybar, FALSE, FALSE, 2);
gtk_box_pack_start(GTK_BOX(queryarea), paned, TRUE, TRUE, 2);
gtk_widget_show_all(queryarea);
return queryarea;
}
static GtkWidget*
mug_main_area(MugData* mugdata)
{
GtkWidget *mainarea, *w;
mainarea = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
w = mug_shortcuts_bar(mugdata);
gtk_box_pack_start(GTK_BOX(mainarea), w, FALSE, FALSE, 0);
gtk_widget_show(w);
w = mug_query_area(mugdata);
gtk_box_pack_start(GTK_BOX(mainarea), w, TRUE, TRUE, 0);
gtk_widget_show(w);
return mainarea;
}
static GtkWidget*
mug_shell(MugData* mugdata)
{
GtkWidget* vbox;
mugdata->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(mugdata->win), "Mug Mail Search");
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
mugdata->toolbar = mug_toolbar(mugdata);
gtk_box_pack_start(GTK_BOX(vbox), mugdata->toolbar, FALSE, FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), mug_main_area(mugdata), TRUE, TRUE, 2);
mugdata->statusbar = mug_statusbar();
gtk_box_pack_start(GTK_BOX(vbox), mugdata->statusbar, FALSE, FALSE, 2);
gtk_container_add(GTK_CONTAINER(mugdata->win), vbox);
gtk_widget_show_all(vbox);
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", MUGDIR, G_DIR_SEPARATOR);
gtk_window_set_icon_from_file(GTK_WINDOW(mugdata->win), icon, NULL);
g_free(icon);
}
return mugdata->win;
}
static gint
on_focus_query_bar(GtkWidget* ignored, GdkEventKey* event, MugData* mugdata)
{
if (event->type == GDK_KEY_RELEASE && event->keyval == GDK_KEY_Escape) {
mug_query_bar_grab_focus(MUG_QUERY_BAR(mugdata->querybar));
return 1;
}
return 0;
}
int
main(int argc, char* argv[])
{
MugData mugdata;
GtkWidget* mugshell;
GOptionContext* octx;
GOptionEntry entries[] = {
{"muhome",
0,
0,
G_OPTION_ARG_FILENAME,
&mugdata.muhome,
"specify an alternative mu directory",
NULL},
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL} /* sentinel */
};
gtk_init(&argc, &argv);
octx = g_option_context_new("- mug options");
g_option_context_add_main_entries(octx, entries, "Mug");
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", FALSE);
mugshell = mug_shell(&mugdata);
g_signal_connect(G_OBJECT(mugshell), "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(mugshell),
"key_release_event",
G_CALLBACK(on_focus_query_bar),
(gpointer)&mugdata);
gtk_widget_show(mugshell);
mug_query_bar_grab_focus(MUG_QUERY_BAR(mugdata.querybar));
gtk_main();
g_free(mugdata.muhome);
mu_runtime_uninit();
return 0;
}

View File

@ -1,443 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 17 KiB