mirror of https://github.com/djcb/mu.git
parent
4daa7105d2
commit
90e35a9732
|
@ -30,13 +30,17 @@ AM_CPPFLAGS=-I${top_srcdir} -I${top_srcdir}/lib $(GTK_CFLAGS) $(WEBKIT_CFLAGS) \
|
||||||
# really need all the params they get
|
# really need all the params they get
|
||||||
AM_CFLAGS= \
|
AM_CFLAGS= \
|
||||||
$(WARN_CFLAGS) \
|
$(WARN_CFLAGS) \
|
||||||
$(ASAN_CFLAGS) \
|
$(ASAN_CFLAGS) \
|
||||||
-Wno-redundant-decls \
|
-Wno-redundant-decls \
|
||||||
-Wno-deprecated-declarations \
|
-Wno-deprecated-declarations \
|
||||||
-Wno-switch-enum
|
-Wno-switch-enum
|
||||||
|
|
||||||
AM_CXXFLAGS=$(WARN_CXXFLAGS)
|
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
|
# Distributors: this is a _toy_, not for distribution. the "noinst_" says enough
|
||||||
#
|
#
|
||||||
|
@ -48,7 +52,7 @@ mug_SOURCES= \
|
||||||
mug-msg-list-view.cc \
|
mug-msg-list-view.cc \
|
||||||
mug-msg-list-view.h \
|
mug-msg-list-view.h \
|
||||||
mug-msg-view.h \
|
mug-msg-view.h \
|
||||||
mug-msg-view.c \
|
mug-msg-view.cc \
|
||||||
mug-query-bar.h \
|
mug-query-bar.h \
|
||||||
mug-query-bar.c \
|
mug-query-bar.c \
|
||||||
mug-shortcuts.cc \
|
mug-shortcuts.cc \
|
||||||
|
@ -70,14 +74,14 @@ noinst_LTLIBRARIES= \
|
||||||
libmuwidgets_la_SOURCES= \
|
libmuwidgets_la_SOURCES= \
|
||||||
mu-widget-util.h \
|
mu-widget-util.h \
|
||||||
mu-widget-util.c \
|
mu-widget-util.c \
|
||||||
mu-msg-attach-view.c \
|
mu-msg-attach-view.cc \
|
||||||
mu-msg-attach-view.h \
|
mu-msg-attach-view.hh \
|
||||||
mu-msg-body-view.c \
|
mu-msg-body-view.cc \
|
||||||
mu-msg-body-view.h \
|
mu-msg-body-view.hh \
|
||||||
mu-msg-header-view.c \
|
mu-msg-header-view.cc \
|
||||||
mu-msg-header-view.h \
|
mu-msg-header-view.hh \
|
||||||
mu-msg-view.h \
|
mu-msg-view.hh \
|
||||||
mu-msg-view.c
|
mu-msg-view.cc
|
||||||
|
|
||||||
libmuwidgets_la_LIBADD= \
|
libmuwidgets_la_LIBADD= \
|
||||||
${top_builddir}/lib/libmu.la \
|
${top_builddir}/lib/libmu.la \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -17,9 +17,12 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mu-msg-attach-view.h"
|
#include "mu-msg-attach-view.hh"
|
||||||
#include "mu-widget-util.h"
|
#include "mu-widget-util.h"
|
||||||
#include <mu-msg-part.h>
|
#include <mu-msg.hh>
|
||||||
|
#include <mu-msg-part.hh>
|
||||||
|
|
||||||
|
using namespace Mu;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ICON_COL,
|
ICON_COL,
|
||||||
|
@ -78,7 +81,7 @@ mu_msg_attach_view_class_init (MuMsgAttachViewClass *klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
gobject_class = (GObjectClass*) klass;
|
gobject_class = (GObjectClass*) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = (GtkIconViewClass*)g_type_class_peek_parent (klass);
|
||||||
gobject_class->finalize = mu_msg_attach_view_finalize;
|
gobject_class->finalize = mu_msg_attach_view_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof(MuMsgAttachViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof(MuMsgAttachViewPrivate));
|
||||||
|
@ -204,7 +207,8 @@ mu_msg_attach_view_init (MuMsgAttachView *obj)
|
||||||
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW(obj),
|
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW(obj),
|
||||||
GTK_SELECTION_MULTIPLE);
|
GTK_SELECTION_MULTIPLE);
|
||||||
/* drag & drop */
|
/* drag & drop */
|
||||||
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW(obj), 0, NULL, 0,
|
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW(obj),
|
||||||
|
(GdkModifierType)0, NULL, 0,
|
||||||
GDK_ACTION_COPY);
|
GDK_ACTION_COPY);
|
||||||
gtk_drag_source_add_uri_targets(GTK_WIDGET(obj));
|
gtk_drag_source_add_uri_targets(GTK_WIDGET(obj));
|
||||||
g_signal_connect (obj, "drag-data-get", G_CALLBACK(on_drag_data_get), NULL);
|
g_signal_connect (obj, "drag-data-get", G_CALLBACK(on_drag_data_get), NULL);
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#define __MU_MSG_ATTACH_VIEW_H__
|
#define __MU_MSG_ATTACH_VIEW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <mu-msg.h>
|
#include <mu-msg.hh>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ struct _MuMsgAttachView {
|
||||||
struct _MuMsgAttachViewClass {
|
struct _MuMsgAttachViewClass {
|
||||||
GtkIconViewClass parent_class;
|
GtkIconViewClass parent_class;
|
||||||
void (* attach_activated) (MuMsgAttachView* obj, guint partnum,
|
void (* attach_activated) (MuMsgAttachView* obj, guint partnum,
|
||||||
MuMsg *msg);
|
Mu::MuMsg *msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* member functions */
|
/* member functions */
|
||||||
|
@ -60,7 +60,7 @@ GType mu_msg_attach_view_get_type (void) G_GNUC_CONST;
|
||||||
GtkWidget* mu_msg_attach_view_new (void);
|
GtkWidget* mu_msg_attach_view_new (void);
|
||||||
|
|
||||||
/* returns # of attachments */
|
/* returns # of attachments */
|
||||||
int mu_msg_attach_view_set_message (MuMsgAttachView *self, MuMsg *msg);
|
int mu_msg_attach_view_set_message (MuMsgAttachView *self, Mu::MuMsg *msg);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2017 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -17,8 +17,10 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mu-msg-body-view.h"
|
#include "mu-msg-body-view.hh"
|
||||||
#include <mu-msg-part.h>
|
#include <mu-msg-part.hh>
|
||||||
|
|
||||||
|
using namespace Mu;
|
||||||
|
|
||||||
enum _ViewMode {
|
enum _ViewMode {
|
||||||
VIEW_MODE_MSG,
|
VIEW_MODE_MSG,
|
||||||
|
@ -79,7 +81,7 @@ mu_msg_body_view_class_init (MuMsgBodyViewClass *klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
gobject_class = (GObjectClass*) klass;
|
gobject_class = (GObjectClass*) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = (WebKitWebViewClass*)g_type_class_peek_parent (klass);
|
||||||
gobject_class->finalize = mu_msg_body_view_finalize;
|
gobject_class->finalize = mu_msg_body_view_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof(MuMsgBodyViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof(MuMsgBodyViewPrivate));
|
|
@ -21,7 +21,7 @@
|
||||||
#define __MU_MSG_BODY_VIEW_H__
|
#define __MU_MSG_BODY_VIEW_H__
|
||||||
|
|
||||||
#include <webkit2/webkit2.h>
|
#include <webkit2/webkit2.h>
|
||||||
#include <mu-msg.h>
|
#include <mu-msg.hh>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ GType mu_msg_body_view_get_type (void) G_GNUC_CONST;
|
||||||
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
|
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
|
||||||
GtkWidget* mu_msg_body_view_new (void);
|
GtkWidget* mu_msg_body_view_new (void);
|
||||||
|
|
||||||
void mu_msg_body_view_set_message (MuMsgBodyView *self, MuMsg *msg);
|
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_note (MuMsgBodyView *self, const gchar *html);
|
||||||
void mu_msg_body_view_set_message_source (MuMsgBodyView *self, MuMsg *msg);
|
void mu_msg_body_view_set_message_source (MuMsgBodyView *self, Mu::MuMsg *msg);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -16,15 +16,14 @@
|
||||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
#include <config.h>
|
||||||
#include "mu-msg-header-view.h"
|
#include "mu-msg-header-view.hh"
|
||||||
|
#include "mu-msg.hh"
|
||||||
|
|
||||||
#include <utils/mu-str.h>
|
#include <utils/mu-str.h>
|
||||||
#include <utils/mu-date.h>
|
#include <utils/mu-date.h>
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
using namespace Mu;
|
||||||
#include <config.h>
|
|
||||||
#endif /*HAVE_CONFIG_H*/
|
|
||||||
|
|
||||||
/* 'private'/'protected' functions */
|
/* 'private'/'protected' functions */
|
||||||
static void mu_msg_header_view_class_init (MuMsgHeaderViewClass *klass);
|
static void mu_msg_header_view_class_init (MuMsgHeaderViewClass *klass);
|
||||||
|
@ -59,7 +58,7 @@ mu_msg_header_view_class_init (MuMsgHeaderViewClass *klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
gobject_class = (GObjectClass*) klass;
|
gobject_class = (GObjectClass*) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = (GtkBoxClass*)g_type_class_peek_parent (klass);
|
||||||
gobject_class->finalize = mu_msg_header_view_finalize;
|
gobject_class->finalize = mu_msg_header_view_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof(MuMsgHeaderViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof(MuMsgHeaderViewPrivate));
|
||||||
|
@ -115,7 +114,7 @@ get_label (const gchar *txt, gboolean istitle)
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
G_GNUC_UNUSED static gboolean
|
||||||
add_row (GtkWidget *grid, guint row, const char* fieldname, const char *value,
|
add_row (GtkWidget *grid, guint row, const char* fieldname, const char *value,
|
||||||
gboolean showempty)
|
gboolean showempty)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +142,7 @@ add_row (GtkWidget *grid, guint row, const char* fieldname, const char *value,
|
||||||
|
|
||||||
|
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
get_grid (MuMsg *msg)
|
get_grid (Mu::MuMsg *msg)
|
||||||
{
|
{
|
||||||
GtkWidget *grid;
|
GtkWidget *grid;
|
||||||
int row;
|
int row;
|
||||||
|
@ -170,7 +169,7 @@ get_grid (MuMsg *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg)
|
mu_msg_header_view_set_message (MuMsgHeaderView *self, Mu::MuMsg *msg)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MU_IS_MSG_HEADER_VIEW(self));
|
g_return_if_fail (MU_IS_MSG_HEADER_VIEW(self));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -21,11 +21,7 @@
|
||||||
#define __MU_MSG_HEADER_VIEW_H__
|
#define __MU_MSG_HEADER_VIEW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <mu-msg.h>
|
#include <mu-msg.hh>
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif /*HAVE_CONFIG_H*/
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -61,7 +57,8 @@ GType mu_msg_header_view_get_type (void) G_GNUC_CONST;
|
||||||
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
|
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
|
||||||
GtkWidget* mu_msg_header_view_new (void);
|
GtkWidget* mu_msg_header_view_new (void);
|
||||||
|
|
||||||
void mu_msg_header_view_set_message (MuMsgHeaderView *self, MuMsg *msg);
|
struct MuMsg;
|
||||||
|
void mu_msg_header_view_set_message (MuMsgHeaderView *self, Mu::MuMsg *msg);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -17,16 +17,18 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif /*HAVE_CONFIG_H*/
|
|
||||||
|
|
||||||
#include "mu-msg-view.h"
|
#include "mu-msg-view.hh"
|
||||||
#include "mu-msg-body-view.h"
|
#include "mu-msg-body-view.hh"
|
||||||
#include "mu-msg-header-view.h"
|
#include "mu-msg-header-view.hh"
|
||||||
#include "mu-msg-attach-view.h"
|
#include "mu-msg-attach-view.hh"
|
||||||
#include <mu-msg-part.h>
|
#include <utils/mu-util.h>
|
||||||
|
|
||||||
|
#include <mu-msg.hh>
|
||||||
|
#include <mu-msg-part.hh>
|
||||||
|
|
||||||
|
using namespace Mu;
|
||||||
|
|
||||||
/* 'private'/'protected' functions */
|
/* 'private'/'protected' functions */
|
||||||
static void mu_msg_view_class_init (MuMsgViewClass *klass);
|
static void mu_msg_view_class_init (MuMsgViewClass *klass);
|
||||||
|
@ -42,7 +44,7 @@ enum {
|
||||||
|
|
||||||
struct _MuMsgViewPrivate {
|
struct _MuMsgViewPrivate {
|
||||||
GtkWidget *_headers, *_attach, *_attachexpander, *_body;
|
GtkWidget *_headers, *_attach, *_attachexpander, *_body;
|
||||||
MuMsg *_msg;
|
Mu::MuMsg *_msg;
|
||||||
};
|
};
|
||||||
#define MU_MSG_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
#define MU_MSG_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
||||||
MU_TYPE_MSG_VIEW, \
|
MU_TYPE_MSG_VIEW, \
|
||||||
|
@ -56,7 +58,7 @@ static GtkBoxClass *parent_class = NULL;
|
||||||
G_DEFINE_TYPE (MuMsgView, mu_msg_view, GTK_TYPE_BOX);
|
G_DEFINE_TYPE (MuMsgView, mu_msg_view, GTK_TYPE_BOX);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_message (MuMsgView *self, MuMsg *msg)
|
set_message (MuMsgView *self, Mu::MuMsg *msg)
|
||||||
{
|
{
|
||||||
if (self->_priv->_msg == msg)
|
if (self->_priv->_msg == msg)
|
||||||
return; /* nothing to todo */
|
return; /* nothing to todo */
|
||||||
|
@ -77,7 +79,7 @@ mu_msg_view_class_init (MuMsgViewClass *klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
gobject_class = (GObjectClass*) klass;
|
gobject_class = (GObjectClass*) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = (GtkBoxClass*)g_type_class_peek_parent (klass);
|
||||||
gobject_class->finalize = mu_msg_view_finalize;
|
gobject_class->finalize = mu_msg_view_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof(MuMsgViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof(MuMsgViewPrivate));
|
||||||
|
@ -110,7 +112,7 @@ on_body_action_requested (GtkWidget *w, const char* action,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_attach_activated (GtkWidget *w, guint partnum, MuMsg *msg)
|
on_attach_activated (GtkWidget *w, guint partnum, Mu::MuMsg *msg)
|
||||||
{
|
{
|
||||||
gchar *filepath;
|
gchar *filepath;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
@ -188,7 +190,7 @@ mu_msg_view_new (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_msg_view_set_message (MuMsgView *self, MuMsg *msg)
|
mu_msg_view_set_message (MuMsgView *self, Mu::MuMsg *msg)
|
||||||
{
|
{
|
||||||
gint attachnum;
|
gint attachnum;
|
||||||
|
|
||||||
|
@ -212,7 +214,8 @@ mu_msg_view_set_message (MuMsgView *self, MuMsg *msg)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_msg_view_set_message_source (MuMsgView *self, MuMsg *msg)
|
mu_msg_view_set_message_source (MuMsgView *self,
|
||||||
|
Mu::MuMsg *msg)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MU_IS_MSG_VIEW(self));
|
g_return_if_fail (MU_IS_MSG_VIEW(self));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2011-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2011-2020Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -21,11 +21,7 @@
|
||||||
#define __MU_MSG_VIEW_H__
|
#define __MU_MSG_VIEW_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <mu-msg.h>
|
#include "mu-msg.hh"
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif /*HAVE_CONFIG_H*/
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -59,9 +55,11 @@ GType mu_msg_view_get_type (void) G_GNUC_CONST;
|
||||||
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
|
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
|
||||||
GtkWidget* mu_msg_view_new (void);
|
GtkWidget* mu_msg_view_new (void);
|
||||||
|
|
||||||
void mu_msg_view_set_message (MuMsgView *self, MuMsg *msg);
|
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_note (MuMsgView *self, const gchar* html);
|
||||||
void mu_msg_view_set_message_source (MuMsgView *self, MuMsg *msg);
|
void mu_msg_view_set_message_source (MuMsgView *self, Mu::MuMsg *msg);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
|
||||||
/**
|
G_BEGIN_DECLS
|
||||||
|
/**
|
||||||
* get a pixbuf (icon) for a certain content-type (ie., 'image/jpeg')
|
* get a pixbuf (icon) for a certain content-type (ie., 'image/jpeg')
|
||||||
*
|
*
|
||||||
* @param ctype the content-type (MIME-type)
|
* @param ctype the content-type (MIME-type)
|
||||||
* @param size the size of the icon
|
* @param size the size of the icon
|
||||||
*
|
*
|
||||||
* @return a new GdkPixbuf, or NULL in case of error. Use
|
* @return a new GdkPixbuf, or NULL in case of error. Use
|
||||||
* g_object_unref when the pixbuf is no longer needed.
|
* g_object_unref when the pixbuf is no longer needed.
|
||||||
*/
|
*/
|
||||||
|
@ -36,4 +37,6 @@ GdkPixbuf* mu_widget_util_get_icon_pixbuf_for_content_type (const char *ctype,
|
||||||
G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /*__MU_WIDGET_UTIL_H__*/
|
#endif /*__MU_WIDGET_UTIL_H__*/
|
||||||
|
|
|
@ -21,37 +21,38 @@
|
||||||
#include "mu-query.hh"
|
#include "mu-query.hh"
|
||||||
#include "utils/mu-str.h"
|
#include "utils/mu-str.h"
|
||||||
#include "utils/mu-date.h"
|
#include "utils/mu-date.h"
|
||||||
#include "mu-threader.hh"
|
|
||||||
|
using namespace Mu;
|
||||||
|
|
||||||
/* 'private'/'protected' functions */
|
/* 'private'/'protected' functions */
|
||||||
static void mug_msg_list_view_finalize (GObject * obj);
|
static void mug_msg_list_view_finalize (GObject * obj);
|
||||||
|
|
||||||
/* list my signals */
|
/* list my signals */
|
||||||
enum {
|
enum {
|
||||||
MUG_MSG_SELECTED,
|
MUG_MSG_SELECTED,
|
||||||
MUG_ERROR_OCCURED,
|
MUG_ERROR_OCCURED,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MUG_COL_DATESTR,
|
MUG_COL_DATESTR,
|
||||||
MUG_COL_MAILDIR,
|
MUG_COL_MAILDIR,
|
||||||
MUG_COL_FLAGSSTR,
|
MUG_COL_FLAGSSTR,
|
||||||
MUG_COL_FROM,
|
MUG_COL_FROM,
|
||||||
MUG_COL_TO,
|
MUG_COL_TO,
|
||||||
MUG_COL_SUBJECT,
|
MUG_COL_SUBJECT,
|
||||||
MUG_COL_PATH,
|
MUG_COL_PATH,
|
||||||
MUG_COL_PRIO,
|
MUG_COL_PRIO,
|
||||||
MUG_COL_FLAGS,
|
MUG_COL_FLAGS,
|
||||||
MUG_COL_TIME,
|
MUG_COL_TIME,
|
||||||
MUG_N_COLS
|
MUG_N_COLS
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _MugMsgListViewPrivate MugMsgListViewPrivate;
|
typedef struct _MugMsgListViewPrivate MugMsgListViewPrivate;
|
||||||
struct _MugMsgListViewPrivate {
|
struct _MugMsgListViewPrivate {
|
||||||
GtkTreeStore *_store;
|
GtkTreeStore *_store;
|
||||||
char *_xpath;
|
char *_xpath;
|
||||||
char *_query;
|
char *_query;
|
||||||
};
|
};
|
||||||
#define MUG_MSG_LIST_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
#define MUG_MSG_LIST_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
||||||
MUG_TYPE_MSG_LIST_VIEW, \
|
MUG_TYPE_MSG_LIST_VIEW, \
|
||||||
|
@ -67,361 +68,354 @@ G_DEFINE_TYPE (MugMsgListView, mug_msg_list_view, GTK_TYPE_TREE_VIEW);
|
||||||
static void
|
static void
|
||||||
mug_msg_list_view_class_init (MugMsgListViewClass * klass)
|
mug_msg_list_view_class_init (MugMsgListViewClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
|
||||||
parent_class = (GtkTreeViewClass*)g_type_class_peek_parent (klass);
|
parent_class = (GtkTreeViewClass*)g_type_class_peek_parent (klass);
|
||||||
gobject_class->finalize = mug_msg_list_view_finalize;
|
gobject_class->finalize = mug_msg_list_view_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class,
|
g_type_class_add_private (gobject_class,
|
||||||
sizeof (MugMsgListViewPrivate));
|
sizeof (MugMsgListViewPrivate));
|
||||||
|
|
||||||
signals[MUG_MSG_SELECTED] =
|
signals[MUG_MSG_SELECTED] =
|
||||||
g_signal_new ("msg-selected",
|
g_signal_new ("msg-selected",
|
||||||
G_TYPE_FROM_CLASS (gobject_class),
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (MugMsgListViewClass,
|
G_STRUCT_OFFSET (MugMsgListViewClass,
|
||||||
msg_selected),
|
msg_selected),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__STRING,
|
g_cclosure_marshal_VOID__STRING,
|
||||||
G_TYPE_NONE, 1, G_TYPE_STRING);
|
G_TYPE_NONE, 1, G_TYPE_STRING);
|
||||||
signals[MUG_ERROR_OCCURED] =
|
signals[MUG_ERROR_OCCURED] =
|
||||||
g_signal_new ("error-occured",
|
g_signal_new ("error-occured",
|
||||||
G_TYPE_FROM_CLASS (gobject_class),
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (MugMsgListViewClass,
|
G_STRUCT_OFFSET (MugMsgListViewClass,
|
||||||
error_occured),
|
error_occured),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__UINT,
|
g_cclosure_marshal_VOID__UINT,
|
||||||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_cursor_changed (GtkTreeView * tview, MugMsgListView * lst)
|
on_cursor_changed (GtkTreeView * tview, MugMsgListView * lst)
|
||||||
{
|
{
|
||||||
GtkTreeSelection *sel;
|
GtkTreeSelection *sel;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
MugMsgListViewPrivate *priv;
|
MugMsgListViewPrivate *priv;
|
||||||
|
|
||||||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (tview);
|
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (tview);
|
||||||
|
|
||||||
sel = gtk_tree_view_get_selection (tview);
|
sel = gtk_tree_view_get_selection (tview);
|
||||||
if (!sel)
|
if (!sel)
|
||||||
return; /* hmmm */
|
return; /* hmmm */
|
||||||
if (gtk_tree_selection_get_selected (sel, NULL, &iter)) {
|
if (gtk_tree_selection_get_selected (sel, NULL, &iter)) {
|
||||||
char *path;
|
char *path;
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->_store), &iter,
|
gtk_tree_model_get (GTK_TREE_MODEL (priv->_store), &iter,
|
||||||
MUG_COL_PATH, &path, -1);
|
MUG_COL_PATH, &path, -1);
|
||||||
g_signal_emit (G_OBJECT (lst),
|
g_signal_emit (G_OBJECT (lst),
|
||||||
signals[MUG_MSG_SELECTED], 0, path);
|
signals[MUG_MSG_SELECTED], 0, path);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
treecell_func (GtkTreeViewColumn * tree_column, GtkCellRenderer * renderer,
|
treecell_func (GtkTreeViewColumn * tree_column, GtkCellRenderer * renderer,
|
||||||
GtkTreeModel * tree_model, GtkTreeIter * iter, gpointer data)
|
GtkTreeModel * tree_model, GtkTreeIter * iter, gpointer data)
|
||||||
{
|
{
|
||||||
MuFlags flags;
|
MuFlags flags;
|
||||||
MuMsgPrio prio;
|
MuMsgPrio prio;
|
||||||
|
|
||||||
gtk_tree_model_get (tree_model, iter,
|
gtk_tree_model_get (tree_model, iter,
|
||||||
MUG_COL_FLAGS, &flags, MUG_COL_PRIO, &prio, -1);
|
MUG_COL_FLAGS, &flags, MUG_COL_PRIO, &prio, -1);
|
||||||
|
|
||||||
g_object_set (G_OBJECT (renderer),
|
g_object_set (G_OBJECT (renderer),
|
||||||
"weight", (flags & MU_FLAG_NEW) ? 800 : 400,
|
"weight", (flags & MU_FLAG_NEW) ? 800 : 400,
|
||||||
"weight", (flags & MU_FLAG_SEEN) ? 400 : 800,
|
"weight", (flags & MU_FLAG_SEEN) ? 400 : 800,
|
||||||
"foreground", prio == MU_MSG_PRIO_HIGH ? "red" : NULL,
|
"foreground", prio == MU_MSG_PRIO_HIGH ? "red" : NULL,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sortcolidx == -1 means 'sortcolidx = colidx' */
|
/* sortcolidx == -1 means 'sortcolidx = colidx' */
|
||||||
static void
|
static void
|
||||||
append_col (GtkTreeView * treeview, const char *label, int colidx,
|
append_col (GtkTreeView * treeview, const char *label, int colidx,
|
||||||
int sortcolidx, gint maxwidth)
|
int sortcolidx, gint maxwidth)
|
||||||
{
|
{
|
||||||
GtkTreeViewColumn *col;
|
GtkTreeViewColumn *col;
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END,
|
g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
col = gtk_tree_view_column_new_with_attributes (label, renderer, "text",
|
col = gtk_tree_view_column_new_with_attributes (label, renderer, "text",
|
||||||
colidx, NULL);
|
colidx, NULL);
|
||||||
g_object_set (G_OBJECT (col), "resizable", TRUE, NULL);
|
g_object_set (G_OBJECT (col), "resizable", TRUE, NULL);
|
||||||
|
|
||||||
gtk_tree_view_column_set_sort_indicator (col, TRUE);
|
gtk_tree_view_column_set_sort_indicator (col, TRUE);
|
||||||
|
|
||||||
if (sortcolidx == -1)
|
if (sortcolidx == -1)
|
||||||
sortcolidx = colidx;
|
sortcolidx = colidx;
|
||||||
gtk_tree_view_column_set_sort_column_id (col, sortcolidx);
|
gtk_tree_view_column_set_sort_column_id (col, sortcolidx);
|
||||||
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
|
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||||
|
|
||||||
if (maxwidth) {
|
if (maxwidth) {
|
||||||
gtk_tree_view_column_set_fixed_width (col, maxwidth);
|
gtk_tree_view_column_set_fixed_width (col, maxwidth);
|
||||||
gtk_tree_view_column_set_expand (col, FALSE);
|
gtk_tree_view_column_set_expand (col, FALSE);
|
||||||
} else
|
} else
|
||||||
gtk_tree_view_column_set_expand (col, TRUE);
|
gtk_tree_view_column_set_expand (col, TRUE);
|
||||||
|
|
||||||
gtk_tree_view_column_set_cell_data_func (col, renderer,
|
gtk_tree_view_column_set_cell_data_func (col, renderer,
|
||||||
(GtkTreeCellDataFunc)
|
(GtkTreeCellDataFunc)
|
||||||
treecell_func, NULL, NULL);
|
treecell_func, NULL, NULL);
|
||||||
|
|
||||||
gtk_tree_view_append_column (treeview, col);
|
gtk_tree_view_append_column (treeview, col);
|
||||||
|
|
||||||
gtk_tree_view_columns_autosize (treeview);
|
gtk_tree_view_columns_autosize (treeview);
|
||||||
gtk_tree_view_set_fixed_height_mode (treeview, TRUE);
|
gtk_tree_view_set_fixed_height_mode (treeview, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mug_msg_list_view_init (MugMsgListView * obj)
|
mug_msg_list_view_init (MugMsgListView * obj)
|
||||||
{
|
{
|
||||||
MugMsgListViewPrivate *priv;
|
MugMsgListViewPrivate *priv;
|
||||||
GtkTreeView *tview;
|
GtkTreeView *tview;
|
||||||
|
|
||||||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (obj);
|
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (obj);
|
||||||
|
|
||||||
priv->_xpath = priv->_query = NULL;
|
priv->_xpath = priv->_query = NULL;
|
||||||
priv->_store = gtk_tree_store_new (MUG_N_COLS, G_TYPE_STRING, /* date */
|
priv->_store = gtk_tree_store_new (MUG_N_COLS, G_TYPE_STRING, /* date */
|
||||||
G_TYPE_STRING,/* folder */
|
G_TYPE_STRING,/* folder */
|
||||||
G_TYPE_STRING,/* flagstr */
|
G_TYPE_STRING,/* flagstr */
|
||||||
G_TYPE_STRING, /* from */
|
G_TYPE_STRING, /* from */
|
||||||
G_TYPE_STRING,/* to */
|
G_TYPE_STRING,/* to */
|
||||||
G_TYPE_STRING,/* subject */
|
G_TYPE_STRING,/* subject */
|
||||||
G_TYPE_STRING, /* path */
|
G_TYPE_STRING, /* path */
|
||||||
G_TYPE_UINT, /* prio */
|
G_TYPE_UINT, /* prio */
|
||||||
G_TYPE_UINT, /* flags */
|
G_TYPE_UINT, /* flags */
|
||||||
G_TYPE_INT); /* timeval */
|
G_TYPE_INT); /* timeval */
|
||||||
|
|
||||||
tview = GTK_TREE_VIEW (obj);
|
tview = GTK_TREE_VIEW (obj);
|
||||||
gtk_tree_view_set_model (tview, GTK_TREE_MODEL (priv->_store));
|
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_headers_clickable (GTK_TREE_VIEW (obj), TRUE);
|
||||||
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (obj),
|
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (obj),
|
||||||
GTK_TREE_VIEW_GRID_LINES_VERTICAL);
|
GTK_TREE_VIEW_GRID_LINES_VERTICAL);
|
||||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (obj), TRUE);
|
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, "Date", MUG_COL_DATESTR, MUG_COL_TIME, 80);
|
||||||
append_col (tview, "Folder", MUG_COL_MAILDIR, -1, 60);
|
append_col (tview, "Folder", MUG_COL_MAILDIR, -1, 60);
|
||||||
append_col (tview, "F", MUG_COL_FLAGSSTR, -1, 25);
|
append_col (tview, "F", MUG_COL_FLAGSSTR, -1, 25);
|
||||||
append_col (tview, "From", MUG_COL_FROM, -1, 0);
|
append_col (tview, "From", MUG_COL_FROM, -1, 0);
|
||||||
append_col (tview, "To", MUG_COL_TO, -1, 0);
|
append_col (tview, "To", MUG_COL_TO, -1, 0);
|
||||||
append_col (tview, "Subject", MUG_COL_SUBJECT, -1, 0);
|
append_col (tview, "Subject", MUG_COL_SUBJECT, -1, 0);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (obj), "cursor-changed",
|
g_signal_connect (G_OBJECT (obj), "cursor-changed",
|
||||||
G_CALLBACK (on_cursor_changed), obj);
|
G_CALLBACK (on_cursor_changed), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mug_msg_list_view_finalize (GObject * obj)
|
mug_msg_list_view_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
MugMsgListViewPrivate *priv;
|
MugMsgListViewPrivate *priv;
|
||||||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (obj);
|
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (obj);
|
||||||
|
|
||||||
if (priv->_store)
|
if (priv->_store)
|
||||||
g_object_unref (priv->_store);
|
g_object_unref (priv->_store);
|
||||||
|
|
||||||
g_free (priv->_xpath);
|
g_free (priv->_xpath);
|
||||||
g_free (priv->_query);
|
g_free (priv->_query);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mug_msg_list_view_move_first (MugMsgListView * self)
|
mug_msg_list_view_move_first (MugMsgListView * self)
|
||||||
{
|
{
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
|
|
||||||
g_return_if_fail (MUG_IS_MSG_LIST_VIEW (self));
|
g_return_if_fail (MUG_IS_MSG_LIST_VIEW (self));
|
||||||
|
|
||||||
path = gtk_tree_path_new_first ();
|
path = gtk_tree_path_new_first ();
|
||||||
gtk_tree_view_set_cursor (GTK_TREE_VIEW (self), path, NULL, FALSE);
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (self), path, NULL, FALSE);
|
||||||
|
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
msg_list_view_move (MugMsgListView * self, gboolean next)
|
msg_list_view_move (MugMsgListView * self, gboolean next)
|
||||||
{
|
{
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
|
|
||||||
gtk_tree_view_get_cursor (GTK_TREE_VIEW (self), &path, NULL);
|
gtk_tree_view_get_cursor (GTK_TREE_VIEW (self), &path, NULL);
|
||||||
if (!path)
|
if (!path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (next)
|
if (next)
|
||||||
gtk_tree_path_next (path);
|
gtk_tree_path_next (path);
|
||||||
else
|
else
|
||||||
gtk_tree_path_prev (path);
|
gtk_tree_path_prev (path);
|
||||||
|
|
||||||
gtk_tree_view_set_cursor (GTK_TREE_VIEW (self), path, NULL, FALSE);
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (self), path, NULL, FALSE);
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mug_msg_list_view_move_next (MugMsgListView * self)
|
mug_msg_list_view_move_next (MugMsgListView * self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
|
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
|
||||||
|
|
||||||
return msg_list_view_move (self, TRUE);
|
return msg_list_view_move (self, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mug_msg_list_view_move_prev (MugMsgListView * self)
|
mug_msg_list_view_move_prev (MugMsgListView * self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
|
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
|
||||||
|
|
||||||
return msg_list_view_move (self, FALSE);
|
return msg_list_view_move (self, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
mug_msg_list_view_new (const char *xpath)
|
mug_msg_list_view_new (const char *xpath)
|
||||||
{
|
{
|
||||||
GtkWidget *w;
|
GtkWidget *w;
|
||||||
MugMsgListViewPrivate *priv;
|
MugMsgListViewPrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (xpath, NULL);
|
g_return_val_if_fail (xpath, NULL);
|
||||||
|
|
||||||
w = GTK_WIDGET (g_object_new (MUG_TYPE_MSG_LIST_VIEW, NULL));
|
w = GTK_WIDGET (g_object_new (MUG_TYPE_MSG_LIST_VIEW, NULL));
|
||||||
|
|
||||||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (w);
|
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (w);
|
||||||
priv->_xpath = g_strdup (xpath);
|
priv->_xpath = g_strdup (xpath);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
empty_or_display_contact (const gchar * str)
|
empty_or_display_contact (const gchar * str)
|
||||||
{
|
{
|
||||||
if (!str || *str == '\0')
|
if (!str || *str == '\0')
|
||||||
return g_strdup ("-");
|
return g_strdup ("-");
|
||||||
else
|
else
|
||||||
return mu_str_display_contact (str);
|
return mu_str_display_contact (str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MuMsgIter *
|
static Mu::Option<Mu::QueryResults>
|
||||||
run_query (const char *xpath, const char *expr, MugMsgListView * self) try
|
run_query (const char *xpath, const char *expr, MugMsgListView * self)
|
||||||
{
|
{
|
||||||
Mu::Store store{xpath};
|
Mu::Store store{xpath};
|
||||||
Mu::Query query{store};
|
Mu::Query query{store};
|
||||||
|
|
||||||
return query.run(expr, MU_MSG_FIELD_ID_DATE,
|
return query.run(expr, MU_MSG_FIELD_ID_DATE,
|
||||||
Mu::Query::Flags::Descending |
|
Mu::QueryFlags::Descending |
|
||||||
Mu::Query::Flags::SkipUnreadable |
|
Mu::QueryFlags::SkipUnreadable |
|
||||||
Mu::Query::Flags::SkipDups |
|
Mu::QueryFlags::SkipDuplicates |
|
||||||
Mu::Query::Flags::IncludeRelated |
|
Mu::QueryFlags::IncludeRelated |
|
||||||
Mu::Query::Flags::Threading);
|
Mu::QueryFlags::Threading);
|
||||||
} catch (...) {
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_row (GtkTreeStore * store, MuMsg *msg, GtkTreeIter *treeiter)
|
add_row (GtkTreeStore * store, MuMsg *msg, GtkTreeIter *treeiter)
|
||||||
{
|
{
|
||||||
const gchar *datestr, *flagstr;
|
const gchar *datestr, *flagstr;
|
||||||
gchar *from, *to;
|
gchar *from, *to;
|
||||||
time_t timeval;
|
time_t timeval;
|
||||||
|
|
||||||
timeval = mu_msg_get_date (msg);
|
timeval = mu_msg_get_date (msg);
|
||||||
datestr = timeval == 0 ? "-" : mu_date_display_s (timeval);
|
datestr = timeval == 0 ? "-" : mu_date_display_s (timeval);
|
||||||
from = empty_or_display_contact (mu_msg_get_from (msg));
|
from = empty_or_display_contact (mu_msg_get_from (msg));
|
||||||
to = empty_or_display_contact (mu_msg_get_to (msg));
|
to = empty_or_display_contact (mu_msg_get_to (msg));
|
||||||
flagstr = mu_flags_to_str_s (mu_msg_get_flags (msg), MU_FLAG_TYPE_ANY);
|
flagstr = mu_flags_to_str_s (mu_msg_get_flags (msg), MU_FLAG_TYPE_ANY);
|
||||||
|
|
||||||
/* if (0) { */
|
/* if (0) { */
|
||||||
/* GtkTreeIter myiter; */
|
/* GtkTreeIter myiter; */
|
||||||
/* if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(store), */
|
/* if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(store), */
|
||||||
/* &myiter, path)) */
|
/* &myiter, path)) */
|
||||||
/* g_warning ("%s: cannot get iter for %s",
|
/* g_warning ("%s: cannot get iter for %s",
|
||||||
* __func__, path); */
|
* __func__, path); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
gtk_tree_store_set (store, treeiter,
|
gtk_tree_store_set (store, treeiter,
|
||||||
MUG_COL_DATESTR, datestr,
|
MUG_COL_DATESTR, datestr,
|
||||||
MUG_COL_MAILDIR, mu_msg_get_maildir (msg),
|
MUG_COL_MAILDIR, mu_msg_get_maildir (msg),
|
||||||
MUG_COL_FLAGSSTR, flagstr,
|
MUG_COL_FLAGSSTR, flagstr,
|
||||||
MUG_COL_FROM, from,
|
MUG_COL_FROM, from,
|
||||||
MUG_COL_TO, to,
|
MUG_COL_TO, to,
|
||||||
MUG_COL_SUBJECT, mu_msg_get_subject (msg),
|
MUG_COL_SUBJECT, mu_msg_get_subject (msg),
|
||||||
MUG_COL_PATH, mu_msg_get_path (msg),
|
MUG_COL_PATH, mu_msg_get_path (msg),
|
||||||
MUG_COL_PRIO, mu_msg_get_prio (msg),
|
MUG_COL_PRIO, mu_msg_get_prio (msg),
|
||||||
MUG_COL_FLAGS, mu_msg_get_flags (msg),
|
MUG_COL_FLAGS, mu_msg_get_flags (msg),
|
||||||
MUG_COL_TIME, timeval, -1);
|
MUG_COL_TIME, timeval, -1);
|
||||||
g_free (from);
|
g_free (from);
|
||||||
g_free (to);
|
g_free (to);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
update_model (GtkTreeStore *store, const char *xpath, const char *query,
|
update_model (GtkTreeStore *store, const char *xpath, const char *query,
|
||||||
MugMsgListView *self)
|
MugMsgListView *self)
|
||||||
{
|
{
|
||||||
MuMsgIter *iter;
|
const auto res{run_query (xpath, query, self)};
|
||||||
int count;
|
if (!res) {
|
||||||
const MuMsgIterThreadInfo *prev_ti = NULL;
|
g_warning ("error: running query failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
iter = run_query (xpath, query, self);
|
auto count{0};
|
||||||
if (!iter) {
|
|
||||||
g_warning ("error: running query failed\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (count = 0; !mu_msg_iter_is_done (iter);
|
std::string prev_thread_path;
|
||||||
mu_msg_iter_next (iter), ++count) {
|
for (auto&& it: *res) {
|
||||||
|
GtkTreeIter treeiter, prev_treeiter;
|
||||||
|
|
||||||
GtkTreeIter treeiter, prev_treeiter;
|
const auto thread_path{it.query_match().thread_path};
|
||||||
const MuMsgIterThreadInfo *ti;
|
|
||||||
|
|
||||||
ti = mu_msg_iter_get_thread_info (iter);
|
if (prev_thread_path.find(thread_path) == 0)
|
||||||
|
gtk_tree_store_append (store, &treeiter, &prev_treeiter);
|
||||||
|
else
|
||||||
|
gtk_tree_store_append (store, &treeiter, NULL);
|
||||||
|
|
||||||
if (!prev_ti || !g_str_has_prefix (ti->threadpath,
|
/* don't unref msg */
|
||||||
prev_ti->threadpath))
|
add_row (store, it.floating_msg(), &treeiter);
|
||||||
gtk_tree_store_append (store, &treeiter, NULL);
|
|
||||||
else
|
|
||||||
gtk_tree_store_append (store, &treeiter, &prev_treeiter);
|
|
||||||
|
|
||||||
/* don't unref msg */
|
//prev_ti = ti;
|
||||||
add_row (store, mu_msg_iter_get_msg_floating (iter), &treeiter);
|
prev_treeiter = treeiter;
|
||||||
|
prev_thread_path = thread_path;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
prev_ti = ti;
|
return count;
|
||||||
prev_treeiter = treeiter;
|
|
||||||
}
|
|
||||||
|
|
||||||
mu_msg_iter_destroy (iter);
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mug_msg_list_view_query (MugMsgListView * self, const char *query)
|
mug_msg_list_view_query (MugMsgListView * self, const char *query)
|
||||||
{
|
{
|
||||||
MugMsgListViewPrivate *priv;
|
MugMsgListViewPrivate *priv;
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
|
|
||||||
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
|
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
|
||||||
|
|
||||||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (self);
|
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (self);
|
||||||
gtk_tree_store_clear (priv->_store);
|
gtk_tree_store_clear (priv->_store);
|
||||||
|
|
||||||
g_free (priv->_query);
|
g_free (priv->_query);
|
||||||
priv->_query = query ? g_strdup (query) : NULL;
|
priv->_query = query ? g_strdup (query) : NULL;
|
||||||
|
|
||||||
if (!query)
|
if (!query)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
rv = update_model (priv->_store, priv->_xpath, query, self);
|
rv = update_model (priv->_store, priv->_xpath, query, self);
|
||||||
|
|
||||||
gtk_tree_view_expand_all (GTK_TREE_VIEW(self));
|
gtk_tree_view_expand_all (GTK_TREE_VIEW(self));
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
mug_msg_list_view_get_query (MugMsgListView * self)
|
mug_msg_list_view_get_query (MugMsgListView * self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), NULL);
|
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), NULL);
|
||||||
|
|
||||||
return MUG_MSG_LIST_VIEW_GET_PRIVATE (self)->_query;
|
return MUG_MSG_LIST_VIEW_GET_PRIVATE (self)->_query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -16,16 +16,16 @@
|
||||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CONFIG
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif /*HAVE_CONFIG*/
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "mu-msg-view.h"
|
#include "mu-msg-view.hh"
|
||||||
#include "mug-msg-view.h"
|
#include "mug-msg-view.h"
|
||||||
#include "mu-msg.h"
|
#include "mu-msg.hh"
|
||||||
#include "utils/mu-str.h"
|
#include "utils/mu-str.h"
|
||||||
|
|
||||||
|
using namespace Mu;
|
||||||
|
|
||||||
/* 'private'/'protected' functions */
|
/* 'private'/'protected' functions */
|
||||||
static void mug_msg_view_class_init (MugMsgViewClass * klass);
|
static void mug_msg_view_class_init (MugMsgViewClass * klass);
|
||||||
static void mug_msg_view_init (MugMsgView * obj);
|
static void mug_msg_view_init (MugMsgView * obj);
|
||||||
|
@ -58,7 +58,7 @@ mug_msg_view_class_init (MugMsgViewClass * klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = (GtkBoxClass*)g_type_class_peek_parent (klass);
|
||||||
gobject_class->finalize = mug_msg_view_finalize;
|
gobject_class->finalize = mug_msg_view_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (MugMsgViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof (MugMsgViewPrivate));
|
||||||
|
@ -116,7 +116,7 @@ mug_msg_view_set_msg (MugMsgView * self, const char *msgpath)
|
||||||
if (!msgpath)
|
if (!msgpath)
|
||||||
mu_msg_view_set_message (MU_MSG_VIEW(priv->_view), NULL);
|
mu_msg_view_set_message (MU_MSG_VIEW(priv->_view), NULL);
|
||||||
else {
|
else {
|
||||||
MuMsg *msg;
|
Mu::MuMsg *msg;
|
||||||
|
|
||||||
if (access (msgpath, R_OK) == 0) {
|
if (access (msgpath, R_OK) == 0) {
|
||||||
msg = mu_msg_new_from_file (msgpath, NULL, NULL);
|
msg = mu_msg_new_from_file (msgpath, NULL, NULL);
|
Loading…
Reference in New Issue