Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…ys/mug
  • Loading branch information...
commit 2fcdcafe592e8e80cfc113c57e32e414a7da03f0 1 parent b71a27b
@djcb authored
Showing with 235 additions and 2,078 deletions.
  1. +1 −8 Makefile.am
  2. +3 −7 configure.ac
  3. +2 −7 toys/Makefile.am
  4. +46 −20 toys/mug/Makefile.am
  5. 0  {widgets → toys/mug}/mu-msg-attach-view.c
  6. 0  {widgets → toys/mug}/mu-msg-attach-view.h
  7. 0  {widgets → toys/mug}/mu-msg-body-view.c
  8. 0  {widgets → toys/mug}/mu-msg-body-view.h
  9. 0  {widgets → toys/mug}/mu-msg-header-view.c
  10. 0  {widgets → toys/mug}/mu-msg-header-view.h
  11. 0  {widgets → toys/mug}/mu-msg-view.c
  12. 0  {widgets → toys/mug}/mu-msg-view.h
  13. 0  {widgets → toys/mug}/mu-widget-util.c
  14. 0  {widgets → toys/mug}/mu-widget-util.h
  15. +49 −24 toys/mug/mug-msg-list-view.c
  16. +45 −203 toys/mug/mug-msg-view.c
  17. +16 −8 toys/mug/mug-msg-view.h
  18. +10 −40 toys/mug/mug-query-bar.c
  19. +15 −2 toys/mug/mug-query-bar.h
  20. +8 −4 toys/mug/mug-shortcuts.c
  21. +14 −1 toys/mug/mug-shortcuts.h
  22. +26 −20 toys/mug/mug.c
  23. 0  toys/{mug2 → mug}/mug.svg
  24. +0 −65 toys/mug2/Makefile.am
  25. +0 −466 toys/mug2/mug-msg-list-view.c
  26. +0 −82 toys/mug2/mug-msg-list-view.h
  27. +0 −159 toys/mug2/mug-msg-view.c
  28. +0 −69 toys/mug2/mug-msg-view.h
  29. +0 −118 toys/mug2/mug-query-bar.c
  30. +0 −62 toys/mug2/mug-query-bar.h
  31. +0 −163 toys/mug2/mug-shortcuts.c
  32. +0 −79 toys/mug2/mug-shortcuts.h
  33. +0 −422 toys/mug2/mug.c
  34. +0 −49 widgets/Makefile.am
View
9 Makefile.am
@@ -16,13 +16,6 @@
include $(top_srcdir)/gtest.mk
-# only build widgets if we have webkit
-if BUILD_WIDGETS
-widgets=widgets
-else
-widgets=
-endif
-
if BUILD_GUILE
guile=guile
else
@@ -35,7 +28,7 @@ else
mu4e=
endif
-SUBDIRS=m4 man lib $(widgets) $(guile) mu $(mu4e) contrib toys
+SUBDIRS=m4 man lib $(guile) mu $(mu4e) contrib toys
ACLOCAL_AMFLAGS=-I m4
View
10 configure.ac
@@ -248,8 +248,8 @@ AS_IF([test "x$buildgui"="xyes"],[
])
AM_CONDITIONAL(HAVE_GIO, [test "x$have_gio" = "xyes"])
-# should we build the widgets/ dir?
-AM_CONDITIONAL(BUILD_WIDGETS, [test "x$build_webkit" = "xyes" -a "x$have_gio" = "xyes"])
+# should we build the gui toys?
+AM_CONDITIONAL(BUILD_GUI, [test "x$build_webkit" = "xyes" -a "x$have_gio" = "xyes"])
###############################################################################
@@ -309,14 +309,12 @@ AS_IF([test "x$PMCCABE" = "xno"],[
###############################################################################
-
AC_CONFIG_FILES([
Makefile
mu/Makefile
mu/tests/Makefile
lib/Makefile
lib/tests/Makefile
-widgets/Makefile
mu4e/Makefile
mu4e/mu4e-meta.el
mu4e/version.texi
@@ -326,7 +324,6 @@ guile/examples/Makefile
guile/tests/Makefile
toys/Makefile
toys/mug/Makefile
-toys/mug2/Makefile
toys/msg2pdf/Makefile
man/Makefile
m4/Makefile
@@ -374,8 +371,7 @@ echo
echo "Build mu4e emacs frontend : $build_mu4e"
echo "Build crypto support (gmime >= 2.6) : $have_gmime_26"
echo "Build unit tests (glib >= 2.22) : $have_gtest"
-echo "Build 'mug' toy-ui (gtk+) : $buildgui"
-echo "Build 'mug2' toy-ui (gtk+, webkit) : $build_webkit"
+echo "Build 'mug' toy-ui (gtk+/webkit) : $buildgui"
echo "McCabe's Cyclomatic Complexity tool : $have_pmccabe"
echo
View
9 toys/Makefile.am
@@ -18,12 +18,7 @@ include $(top_srcdir)/gtest.mk
SUBDIRS=
-# build if there is some gtk available
-if HAVE_GTK
-SUBDIRS += mug
-endif
-
# for mug2 and msg2pdf, we need webkit
-if BUILD_WIDGETS
-SUBDIRS += mug2 msg2pdf
+if BUILD_GUI
+SUBDIRS += mug msg2pdf
endif
View
66 toys/mug/Makefile.am
@@ -1,8 +1,8 @@
-## Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+## Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or
+## t he Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
@@ -19,8 +19,9 @@ include $(top_srcdir)/gtest.mk
# enforce compiling this dir first before decending into tests/
SUBDIRS= .
-
-INCLUDES=-I${top_srcdir}/lib $(GTK_CFLAGS) -DICONDIR='"$(icondir)"'
+INCLUDES=-I${top_srcdir} -I${top_srcdir}/lib $(GTK_CFLAGS) $(WEBKIT_CFLAGS) \
+ -DICONDIR='"$(icondir)"' -DMUGDIR='"$(abs_srcdir)"' \
+ -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE
# don't use -Werror, as it might break on other compilers
# use -Wno-unused-parameters, because some callbacks may not
@@ -28,35 +29,60 @@ INCLUDES=-I${top_srcdir}/lib $(GTK_CFLAGS) -DICONDIR='"$(icondir)"'
AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement
AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
-
-noinst_PROGRAMS= \
+noinst_PROGRAMS= \
mug
# note, mug.cc is '.cc' only because libmu must explicitly
# be linked as c++, not c.
-mug_SOURCES= \
- mug.c \
- mug-msg-list-view.c \
- mug-msg-list-view.h \
- mug-msg-view.h \
- mug-msg-view.c \
- mug-query-bar.h \
- mug-query-bar.c \
- mug-shortcuts.c \
- mug-shortcuts.h \
+mug_SOURCES= \
+ mug.c \
+ mug-msg-list-view.c \
+ mug-msg-list-view.h \
+ mug-msg-view.h \
+ mug-msg-view.c \
+ mug-query-bar.h \
+ mug-query-bar.c \
+ mug-shortcuts.c \
+ mug-shortcuts.h \
dummy.cc
# we need to use dummy.cc to enforce c++ linking...
-BUILT_SOURCES= \
+BUILT_SOURCES= \
dummy.cc
dummy.cc:
touch dummy.cc
-DISTCLEANFILES= \
+DISTCLEANFILES= \
$(BUILT_SOURCES)
-mug_LDADD= \
- ${top_builddir}/lib/libmu.la \
+mug_LDADD= \
+ ${top_builddir}/lib/libmu.la \
+ libmuwidgets.la \
${GTK_LIBS}
+
+
+noinst_LTLIBRARIES= \
+ libmuwidgets.la
+
+libmuwidgets_la_SOURCES= \
+ mu-widget-util.h \
+ mu-widget-util.c \
+ mu-msg-attach-view.c \
+ mu-msg-attach-view.h \
+ mu-msg-body-view.c \
+ mu-msg-body-view.h \
+ mu-msg-header-view.c \
+ mu-msg-header-view.h \
+ mu-msg-view.h \
+ mu-msg-view.c
+
+libmuwidgets_la_LIBADD= \
+ ${top_builddir}/lib/libmu.la \
+ ${GTK_LIBS} \
+ ${WEBKIT_LIBS} \
+ ${GIO_LIBS}
+
+EXTRA_DIST= \
+ mug.svg
View
0  widgets/mu-msg-attach-view.c → toys/mug/mu-msg-attach-view.c
File renamed without changes
View
0  widgets/mu-msg-attach-view.h → toys/mug/mu-msg-attach-view.h
File renamed without changes
View
0  widgets/mu-msg-body-view.c → toys/mug/mu-msg-body-view.c
File renamed without changes
View
0  widgets/mu-msg-body-view.h → toys/mug/mu-msg-body-view.h
File renamed without changes
View
0  widgets/mu-msg-header-view.c → toys/mug/mu-msg-header-view.c
File renamed without changes
View
0  widgets/mu-msg-header-view.h → toys/mug/mu-msg-header-view.h
File renamed without changes
View
0  widgets/mu-msg-view.c → toys/mug/mu-msg-view.c
File renamed without changes
View
0  widgets/mu-msg-view.h → toys/mug/mu-msg-view.h
File renamed without changes
View
0  widgets/mu-widget-util.c → toys/mug/mu-widget-util.c
File renamed without changes
View
0  widgets/mu-widget-util.h → toys/mug/mu-widget-util.h
File renamed without changes
View
73 toys/mug/mug-msg-list-view.c
@@ -1,6 +1,6 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/*
-** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
@@ -22,6 +22,7 @@
#include "mu-query.h"
#include "mu-str.h"
#include "mu-date.h"
+#include "mu-threader.h"
/* 'private'/'protected' functions */
static void mug_msg_list_view_class_init (MugMsgListViewClass * klass);
@@ -51,7 +52,7 @@ enum {
typedef struct _MugMsgListViewPrivate MugMsgListViewPrivate;
struct _MugMsgListViewPrivate {
- GtkListStore *_store;
+ GtkTreeStore *_store;
char *_xpath;
char *_query;
};
@@ -158,10 +159,9 @@ append_col (GtkTreeView * treeview, const char *label, int colidx,
if (sortcolidx == -1)
sortcolidx = colidx;
gtk_tree_view_column_set_sort_column_id (col, sortcolidx);
+ gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
if (maxwidth) {
- gtk_tree_view_column_set_sizing (col,
- GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (col, maxwidth);
gtk_tree_view_column_set_expand (col, FALSE);
} else
@@ -172,6 +172,9 @@ append_col (GtkTreeView * treeview, const char *label, int colidx,
treecell_func, NULL, NULL);
gtk_tree_view_append_column (treeview, col);
+
+ gtk_tree_view_columns_autosize (treeview);
+ gtk_tree_view_set_fixed_height_mode (treeview, TRUE);
}
static void
@@ -183,13 +186,13 @@ mug_msg_list_view_init (MugMsgListView * obj)
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (obj);
priv->_xpath = priv->_query = NULL;
- priv->_store = gtk_list_store_new (MUG_N_COLS, G_TYPE_STRING, /* date */
- G_TYPE_STRING, /* folder */
- G_TYPE_STRING, /* flagstr */
- G_TYPE_STRING, /* from */
- G_TYPE_STRING, /* to */
- G_TYPE_STRING, /* subject */
- G_TYPE_STRING, /* path */
+ priv->_store = gtk_tree_store_new (MUG_N_COLS, G_TYPE_STRING, /* date */
+ G_TYPE_STRING,/* folder */
+ G_TYPE_STRING,/* flagstr */
+ G_TYPE_STRING, /* from */
+ G_TYPE_STRING,/* to */
+ G_TYPE_STRING,/* subject */
+ G_TYPE_STRING, /* path */
G_TYPE_UINT, /* prio */
G_TYPE_UINT, /* flags */
G_TYPE_INT); /* timeval */
@@ -326,7 +329,6 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
MuStore *store;
err = NULL;
-
if (! (store = mu_store_new_read_only (xpath, &err)) ||
! (xapian = mu_query_new (store, &err))) {
if (store)
@@ -340,7 +342,7 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
}
mu_store_unref (store);
- iter = mu_query_run (xapian, query, FALSE, MU_MSG_FIELD_ID_DATE,
+ iter = mu_query_run (xapian, query, TRUE, MU_MSG_FIELD_ID_DATE,
TRUE, -1, &err);
mu_query_destroy (xapian);
if (!iter) {
@@ -356,9 +358,8 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
}
static void
-add_row (GtkListStore * store, MuMsg *msg)
+add_row (GtkTreeStore * store, MuMsg *msg, GtkTreeIter *treeiter)
{
- GtkTreeIter treeiter;
const gchar *datestr, *flagstr;
gchar *from, *to;
time_t timeval;
@@ -369,8 +370,15 @@ add_row (GtkListStore * store, MuMsg *msg)
to = empty_or_display_contact (mu_msg_get_to (msg));
flagstr = mu_flags_to_str_s (mu_msg_get_flags (msg), MU_FLAG_TYPE_ANY);
- gtk_list_store_append (store, &treeiter);
- gtk_list_store_set (store, &treeiter,
+ /* if (0) { */
+ /* GtkTreeIter myiter; */
+ /* if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(store), */
+ /* &myiter, path)) */
+ /* g_warning ("%s: cannot get iter for %s",
+ * __FUNCTION__, path); */
+ /* } */
+
+ gtk_tree_store_set (store, treeiter,
MUG_COL_DATESTR, datestr,
MUG_COL_MAILDIR, mu_msg_get_maildir (msg),
MUG_COL_FLAGSSTR, flagstr,
@@ -386,11 +394,12 @@ add_row (GtkListStore * store, MuMsg *msg)
}
static int
-update_model (GtkListStore * store, const char *xpath, const char *query,
- MugMsgListView * self)
+update_model (GtkTreeStore *store, const char *xpath, const char *query,
+ MugMsgListView *self)
{
MuMsgIter *iter;
int count;
+ const MuMsgIterThreadInfo *prev_ti = NULL;
iter = run_query (xpath, query, self);
if (!iter) {
@@ -399,15 +408,31 @@ update_model (GtkListStore * store, const char *xpath, const char *query,
}
for (count = 0; !mu_msg_iter_is_done (iter);
- mu_msg_iter_next (iter), ++count)
- add_row (store, mu_msg_iter_get_msg_floating(iter)); /* don't unref */
+ mu_msg_iter_next (iter), ++count) {
+
+ GtkTreeIter treeiter, prev_treeiter;
+ const MuMsgIterThreadInfo *ti;
+
+ ti = mu_msg_iter_get_thread_info (iter);
+
+ if (!prev_ti || !g_str_has_prefix (ti->threadpath,
+ prev_ti->threadpath))
+ gtk_tree_store_append (store, &treeiter, NULL);
+ else
+ gtk_tree_store_append (store, &treeiter, &prev_treeiter);
+
+ /* don't unref msg */
+ add_row (store, mu_msg_iter_get_msg_floating (iter), &treeiter);
+
+ prev_ti = ti;
+ prev_treeiter = treeiter;
+ }
mu_msg_iter_destroy (iter);
return count;
}
-
int
mug_msg_list_view_query (MugMsgListView * self, const char *query)
{
@@ -417,7 +442,7 @@ mug_msg_list_view_query (MugMsgListView * self, const char *query)
g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (self);
- gtk_list_store_clear (priv->_store);
+ gtk_tree_store_clear (priv->_store);
g_free (priv->_query);
priv->_query = query ? g_strdup (query) : NULL;
@@ -427,7 +452,7 @@ mug_msg_list_view_query (MugMsgListView * self, const char *query)
rv = update_model (priv->_store, priv->_xpath, query, self);
- gtk_tree_view_columns_autosize (GTK_TREE_VIEW (self));
+ gtk_tree_view_expand_all (GTK_TREE_VIEW(self));
return rv;
}
View
248 toys/mug/mug-msg-view.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
@@ -16,12 +16,15 @@
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
-#include <config.h>
+#ifdef HAVE_CONFIG
+#include "config.h"
+#endif /*HAVE_CONFIG*/
+#include <unistd.h>
+#include "mu-msg-view.h"
#include "mug-msg-view.h"
#include "mu-msg.h"
#include "mu-str.h"
-#include "mu-date.h"
/* 'private'/'protected' functions */
static void mug_msg_view_class_init (MugMsgViewClass * klass);
@@ -35,58 +38,25 @@ enum {
LAST_SIGNAL
};
-enum _HeaderRow {
- HEADER_ROW_FROM,
- HEADER_ROW_TO,
- HEADER_ROW_SUBJECT,
- HEADER_ROW_CC,
- HEADER_ROW_DATE,
- HEADER_ROW_PATH,
- HEADER_ROW_MSGID,
- HEADER_ROW_SIZE,
- HEADER_ROW_NUM
-};
-typedef enum _HeaderRow HeaderRow;
-
-struct _HeaderInfo {
- HeaderRow row;
- const char *title;
-};
-typedef struct _HeaderInfo HeaderInfo;
-
-static const HeaderInfo HEADER_INFO[] = {
- {HEADER_ROW_CC, "Cc"},
- {HEADER_ROW_SUBJECT, "Subject"},
- {HEADER_ROW_DATE, "Date"}
-};
-
-static const HeaderInfo HEADER_INFO_EXPANDER[] = {
- {HEADER_ROW_FROM, "From"},
- {HEADER_ROW_TO, "To"},
- {HEADER_ROW_PATH, "Path"},
- {HEADER_ROW_MSGID, "Message-Id"},
- {HEADER_ROW_SIZE, "Size"}
-};
typedef struct _MugMsgViewPrivate MugMsgViewPrivate;
struct _MugMsgViewPrivate {
-
- GtkWidget *_headers_area;
- GtkWidget *_tablemain, *_tableexpander;
- GtkWidget *_headervals[HEADER_ROW_NUM];
-
- GtkWidget *_expander_header, *_expander;
GtkWidget *_view;
};
#define MUG_MSG_VIEW_GET_PRIVATE(o)(G_TYPE_INSTANCE_GET_PRIVATE((o),MUG_TYPE_MSG_VIEW, MugMsgViewPrivate))
/* globals */
+
+#ifdef HAVE_GTK3
+static GtkBoxClass *parent_class = NULL;
+G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_BOX);
+#else
static GtkVBoxClass *parent_class = NULL;
+G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
+#endif /*!HAVE_GTK3*/
/* uncomment the following if you have defined any signals */
/* static guint signals[LAST_SIGNAL] = {0}; */
-G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
-
static void
mug_msg_view_class_init (MugMsgViewClass * klass)
{
@@ -106,82 +76,6 @@ mug_msg_view_class_init (MugMsgViewClass * klass)
/* etc. */
}
-static GtkWidget *
-create_table (MugMsgViewPrivate * priv, const HeaderInfo * hinfo, guint num)
-{
- guint i;
- GtkWidget *table;
-
- table = gtk_table_new (num, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 5);
-
- for (i = 0; i < num; ++i) {
-
- char *str;
- GtkWidget *l, *al;
-
- l = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
-
- gtk_label_set_justify (GTK_LABEL (l), GTK_JUSTIFY_LEFT);
- str = g_strdup_printf ("<b>%s</b>:", hinfo[i].title);
- gtk_label_set_markup (GTK_LABEL (l), str);
- g_free (str);
-
- al = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_container_add (GTK_CONTAINER (al), l);
- gtk_table_attach (GTK_TABLE (table), al, 0, 1, i, i + 1,
- GTK_FILL, 0, 0, 0);
-
- l = priv->_headervals[hinfo[i].row] = gtk_label_new (NULL);
- al = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_label_set_selectable (GTK_LABEL (l), TRUE);
-
- gtk_container_add (GTK_CONTAINER (al), l);
- gtk_label_set_justify (GTK_LABEL (l), GTK_JUSTIFY_LEFT);
- gtk_label_set_line_wrap_mode (GTK_LABEL (l),
- PANGO_WRAP_WORD_CHAR);
- gtk_label_set_line_wrap (GTK_LABEL (l), FALSE);
- gtk_table_attach (GTK_TABLE (table), al,
- 1, 2, i, i + 1, GTK_FILL, 0, 0, 0);
- }
-
- return table;
-}
-
-static GtkWidget *
-headers_area (MugMsgViewPrivate * priv)
-{
- GtkWidget *scrolled, *vbox;
-
- priv->_tablemain = create_table (priv, HEADER_INFO,
- G_N_ELEMENTS (HEADER_INFO));
- priv->_tableexpander = create_table
- (priv, HEADER_INFO_EXPANDER, G_N_ELEMENTS (HEADER_INFO_EXPANDER));
- priv->_expander = gtk_expander_new ("Details");
- gtk_container_add (GTK_CONTAINER (priv->_expander),
- priv->_tableexpander);
-
-
-#ifdef HAVE_GTK3
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-#else
- vbox = gtk_vbox_new (FALSE, 0);
-#endif /*!HAVE_GTK3 */
-
- gtk_box_pack_start (GTK_BOX (vbox), priv->_tablemain, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), priv->_expander, FALSE, FALSE, 0);
-
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
- vbox);
-
- return priv->_headers_area = scrolled;
-}
-
static void
mug_msg_view_init (MugMsgView * obj)
{
@@ -190,19 +84,15 @@ mug_msg_view_init (MugMsgView * obj)
priv = MUG_MSG_VIEW_GET_PRIVATE (obj);
- priv->_view = gtk_text_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->_view), FALSE);
- gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->_view), 10);
- gtk_text_view_set_right_margin (GTK_TEXT_VIEW (priv->_view), 10);
+ priv->_view = mu_msg_view_new ();
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (scrolled), priv->_view);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
+ priv->_view);
- gtk_box_pack_start (GTK_BOX (obj), headers_area (priv), FALSE, FALSE,
- 0);
gtk_box_pack_start (GTK_BOX (obj), scrolled, TRUE, TRUE, 0);
}
@@ -219,98 +109,50 @@ mug_msg_view_new (void)
return GTK_WIDGET (g_object_new (MUG_TYPE_MSG_VIEW, NULL));
}
-static void
-empty_message (MugMsgView * self)
-{
- int i;
- MugMsgViewPrivate *priv;
- GtkTextBuffer *buf;
- priv = MUG_MSG_VIEW_GET_PRIVATE (self);
-
- for (i = 0; i != HEADER_ROW_NUM; ++i)
- gtk_label_set_markup (GTK_LABEL (priv->_headervals[i]), "");
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->_view));
- gtk_text_buffer_set_text (buf, "", -1);
-}
-
-static gboolean
-set_text (MugMsgView * self, const char *txt)
+gboolean
+mug_msg_view_set_msg (MugMsgView * self, const char *msgpath)
{
MugMsgViewPrivate *priv;
- GtkTextBuffer *buf;
-
g_return_val_if_fail (MUG_IS_MSG_VIEW (self), FALSE);
+
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->_view));
- gtk_text_buffer_set_text (buf, txt ? txt : "", -1);
+ if (!msgpath)
+ mu_msg_view_set_message (MU_MSG_VIEW(priv->_view), NULL);
+ else {
+ MuMsg *msg;
+
+ if (access (msgpath, R_OK) == 0) {
+ msg = mu_msg_new_from_file (msgpath, NULL, NULL);
+ mu_msg_view_set_message (MU_MSG_VIEW(priv->_view), msg);
+ if (msg)
+ mu_msg_unref (msg);
+ } else {
+ gchar *note;
+ note = g_strdup_printf (
+ "<h1>Note</h1><hr>"
+ "<p>Message <tt>%s</tt> does not seem to be present "
+ "on the file system."
+ "<p>Maybe you need to run <tt>mu index</tt>?",
+ msgpath);
+ mu_msg_view_set_note (MU_MSG_VIEW (priv->_view), note);
+ g_free (note);
+ }
+ }
return TRUE;
}
-static void
-fill_header (MugMsgViewPrivate * priv, MuMsg * msg)
-{
- int i;
-
- for (i = 0; i != HEADER_ROW_NUM; ++i) {
- const gchar *val;
- switch (i) {
- case HEADER_ROW_FROM: val = mu_msg_get_from (msg); break;
- case HEADER_ROW_TO: val = mu_msg_get_to (msg); break;
- case HEADER_ROW_SUBJECT: val = mu_msg_get_subject (msg); break;
- case HEADER_ROW_MSGID: val = mu_msg_get_msgid (msg);break;
- case HEADER_ROW_CC: val = mu_msg_get_cc (msg); break;
- case HEADER_ROW_PATH: val = mu_msg_get_path (msg); break;
- case HEADER_ROW_DATE:
- val = mu_date_str_s ("%c", mu_msg_get_date (msg));
- break;
- case HEADER_ROW_SIZE:
- val = mu_str_size_s (mu_msg_get_size (msg));
- break;
- default:
- val = NULL;
- }
-
- {
- gchar *str;
- str = g_markup_escape_text (val ? val : "", -1);
- gtk_label_set_markup
- (GTK_LABEL (priv->_headervals[i]), str);
- g_free (str);
- }
- }
-}
-gboolean
-mug_msg_view_set_msg (MugMsgView * self, const char *msgpath)
+void
+mug_msg_view_set_note (MugMsgView * self, const char* html)
{
MugMsgViewPrivate *priv;
- MuMsg *msg;
- gboolean rv;
-
- g_return_val_if_fail (MUG_IS_MSG_VIEW (self), FALSE);
+ g_return_if_fail (MUG_IS_MSG_VIEW (self));
priv = MUG_MSG_VIEW_GET_PRIVATE (self);
- if (!msgpath) {
- empty_message (self);
- return TRUE;
- }
-
- msg = mu_msg_new_from_file (msgpath, NULL, NULL);
- if (!msg) {
- empty_message (self);
- set_text (self, "Message not found; " "please run 'mu index'");
- return FALSE;
- }
-
- rv = set_text (self, mu_msg_get_body_text (msg));
- fill_header (priv, msg);
-
- mu_msg_unref (msg);
-
- return rv;
+ mu_msg_view_set_note (MU_MSG_VIEW (priv->_view), html);
}
View
24 toys/mug/mug-msg-view.h
@@ -23,6 +23,9 @@
#include <gtk/gtk.h>
/* other include files */
+
+
+
G_BEGIN_DECLS
/* convenience macros */
#define MUG_TYPE_MSG_VIEW (mug_msg_view_get_type())
@@ -35,27 +38,32 @@ typedef struct _MugMsgView MugMsgView;
typedef struct _MugMsgViewClass MugMsgViewClass;
struct _MugMsgView {
+#ifdef HAVE_GTK3
+ GtkBox parent;
+#else
GtkVBox parent;
- /* insert public members, if any */
+#endif /*!HAVE_GTK3*/
};
struct _MugMsgViewClass {
+#ifdef HAVE_GTK3
+ GtkBoxClass parent_class;
+#else
GtkVBoxClass parent_class;
+#endif /*!HAVE_GTK3*/
+
/* insert signal callback declarations, e.g. */
/* void (* my_event) (MugMsg* obj); */
};
/* member functions */
-GType
-mug_msg_view_get_type (void)
- G_GNUC_CONST;
+GType mug_msg_view_get_type (void) G_GNUC_CONST;
/* parameter-less _new function (constructor) */
/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */
-GtkWidget *
-mug_msg_view_new (void);
-gboolean
-mug_msg_view_set_msg (MugMsgView * self, const char *msgpath);
+GtkWidget* mug_msg_view_new (void);
+gboolean mug_msg_view_set_msg (MugMsgView * self, const char *msgpath);
+void mug_msg_view_set_note (MugMsgView * self, const char* html);
G_END_DECLS
#endif /* __MUG_MSG_VIEW_H__ */
View
50 toys/mug/mug-query-bar.c
@@ -1,22 +1,6 @@
-/*
-** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
-**
-** This program is free software; you can redistribute it and/or modify it
-** under the terms of the GNU General Public License as published by the
-** Free Software Foundation; either version 3, or (at your option) any
-** later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software Foundation,
-** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-**
-*/
+/* mug-query-bar.c */
+/* insert (c)/licensing information) */
#include "mug-query-bar.h"
/* include other impl specific header files */
@@ -42,30 +26,16 @@ struct _MugQueryBarPrivate {
/* globals */
static GtkContainerClass *parent_class = NULL;
+
static guint signals[LAST_SIGNAL] = { 0 };
-GType
-mug_query_bar_get_type (void)
-{
- static GType my_type = 0;
- if (!my_type) {
- static const GTypeInfo my_info = {
- sizeof (MugQueryBarClass),
- NULL, /* base init */
- NULL, /* base finalize */
- (GClassInitFunc) mug_query_bar_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof (MugQueryBar),
- 0, /* n_preallocs, ignored since 2.10 */
- (GInstanceInitFunc) mug_query_bar_init,
- NULL
- };
- my_type = g_type_register_static (GTK_TYPE_HBOX,
- "MugQueryBar", &my_info, 0);
- }
- return my_type;
-}
+
+#ifdef HAVE_GTK3
+G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_BOX);
+#else
+G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_HBOX);
+#endif /*!HAVE_GTK3*/
+
static void
mug_query_bar_class_init (MugQueryBarClass * klass)
View
17 toys/mug/mug-query-bar.h
@@ -4,8 +4,11 @@
#ifndef __MUG_QUERY_BAR_H__
#define __MUG_QUERY_BAR_H__
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /*HAVE_CONFIG*/
+
#include <gtk/gtk.h>
-/* other include files */
G_BEGIN_DECLS
/* convenience macros */
@@ -19,12 +22,22 @@ typedef struct _MugQueryBar MugQueryBar;
typedef struct _MugQueryBarClass MugQueryBarClass;
struct _MugQueryBar {
+#ifdef HAVE_GTK3
+ GtkBox parent;
+#else
GtkHBox parent;
- /* insert public members, if any */
+#endif /*!HAVE_GTK3*/
};
struct _MugQueryBarClass {
+#ifdef HAVE_GTK3
+ GtkBox parent;
+ GtkBoxClass parent_class;
+#else
+ GtkHBox parent;
GtkHBoxClass parent_class;
+#endif /*!HAVE_GTK3*/
+
/* insert signal callback declarations, e.g. */
void (*query_changed) (MugQueryBar * obj, const char *query);
};
View
12 toys/mug/mug-shortcuts.c
@@ -16,7 +16,6 @@
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
-#include <config.h>
#include "mug-shortcuts.h"
#include "mu-bookmarks.h"
@@ -46,11 +45,17 @@ struct _MugShortcutsPrivate {
MUG_TYPE_SHORTCUTS, \
MugShortcutsPrivate))
/* globals */
-static GtkVBoxClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
+
+#ifdef HAVE_GTK3
+static GtkBoxClass *parent_class = NULL;
+G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_BOX);
+#else
+static GtkVBoxClass *parent_class = NULL;
G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_VBOX);
+#endif /*!HAVE_GTK3*/
static void
mug_shortcuts_class_init (MugShortcutsClass * klass)
@@ -87,8 +92,7 @@ mug_shortcuts_init (MugShortcuts * obj)
obj->_priv->_bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
#else
obj->_priv->_bbox = gtk_vbutton_box_new ();
-
-#endif /*!HAVE_GTK3 */
+#endif /*!HAVE_GTK3*/
gtk_button_box_set_layout (GTK_BUTTON_BOX (obj->_priv->_bbox),
GTK_BUTTONBOX_START);
View
15 toys/mug/mug-shortcuts.h
@@ -20,6 +20,11 @@
#ifndef __MUG_SHORTCUTS_H__
#define __MUG_SHORTCUTS_H__
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif /*HAVE_CONFIG_H*/
+
+
#include <gtk/gtk.h>
/* other include files */
@@ -36,15 +41,23 @@ typedef struct _MugShortcutsClass MugShortcutsClass;
typedef struct _MugShortcutsPrivate MugShortcutsPrivate;
struct _MugShortcuts {
+#ifdef HAVE_GTK3
+ GtkBox parent;
+#else
GtkVBox parent;
- /* insert public members, if any */
+#endif /*!HAVE_GTK3*/
/* private */
MugShortcutsPrivate *_priv;
};
struct _MugShortcutsClass {
+#ifdef HAVE_GTK3
+ GtkBoxClass parent_class;
+#else
GtkVBoxClass parent_class;
+#endif /*!HAVE_GTK3*/
+
void (*clicked) (MugShortcuts * obj, const char *query);
};
View
46 toys/mug/mug.c
@@ -25,8 +25,10 @@
#include <gdk/gdkkeysyms.h>
#include <string.h> /* for memset */
-#include "mu-util.h"
-#include "mu-runtime.h"
+#include <mu-util.h>
+#include <mu-store.h>
+#include <mu-runtime.h>
+#include <mu-index.h>
#include "mug-msg-list-view.h"
#include "mug-query-bar.h"
@@ -45,6 +47,7 @@ struct _MugData {
};
typedef struct _MugData MugData;
+
static void
about_mug (MugData * mugdata)
{
@@ -64,6 +67,7 @@ about_mug (MugData * mugdata)
enum _ToolAction {
ACTION_PREV_MSG = 1,
ACTION_NEXT_MSG,
+ ACTION_REINDEX,
ACTION_DO_QUIT,
ACTION_ABOUT,
ACTION_SEPARATOR /* pseudo action */
@@ -124,6 +128,8 @@ mug_toolbar (MugData * mugdata)
{GTK_STOCK_GO_UP, ACTION_PREV_MSG},
{GTK_STOCK_GO_DOWN, ACTION_NEXT_MSG},
{NULL, ACTION_SEPARATOR},
+ {GTK_STOCK_REFRESH, ACTION_REINDEX},
+ {NULL, ACTION_SEPARATOR},
{GTK_STOCK_ABOUT, ACTION_ABOUT},
{NULL, ACTION_SEPARATOR},
{GTK_STOCK_QUIT, ACTION_DO_QUIT}};
@@ -178,7 +184,6 @@ on_query_changed (MugQueryBar * bar, const char *query, MugData * mugdata)
int count;
/* clear the old message */
- //mug_msg_view_set_text (MUG_MSG_VIEW(mugdata->msgview), NULL);
mug_msg_view_set_msg (MUG_MSG_VIEW (mugdata->msgview), NULL);
count = mug_msg_list_view_query (MUG_MSG_LIST_VIEW (mugdata->mlist),
@@ -205,7 +210,6 @@ on_query_changed (MugQueryBar * bar, const char *query, MugData * mugdata)
static void
on_msg_selected (MugMsgListView * mlist, const char *mpath, MugData * mugdata)
{
- // g_warning ("msg selected: %s", mpath);
mug_msg_view_set_msg (MUG_MSG_VIEW (mugdata->msgview), mpath);
}
@@ -240,9 +244,8 @@ on_list_view_error (MugMsgListView * mlist, MugError err, MugData * mugdata)
gtk_dialog_run (GTK_DIALOG (errdialog));
gtk_widget_destroy (errdialog);
- if (err == MUG_ERROR_QUERY) {
+ if (err == MUG_ERROR_QUERY)
mug_query_bar_grab_focus (MUG_QUERY_BAR (mugdata->querybar));
- }
}
static GtkWidget *
@@ -258,9 +261,7 @@ mug_querybar (void)
static GtkWidget *
mug_query_area (MugData * mugdata)
{
- GtkWidget *queryarea;
- GtkWidget *paned;
- GtkWidget *scrolled;
+ GtkWidget *queryarea, *paned, *scrolled;
#ifdef HAVE_GTK3
queryarea = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
@@ -268,7 +269,7 @@ mug_query_area (MugData * mugdata)
#else
queryarea = gtk_vbox_new (FALSE, 2);
paned = gtk_vpaned_new ();
-#endif /*!HAVE_GTK3 */
+#endif /*!HAVE_GTK3*/
mugdata->mlist = mug_msg_list_view_new
@@ -282,8 +283,10 @@ mug_query_area (MugData * mugdata)
gtk_paned_add1 (GTK_PANED (paned), scrolled);
mugdata->msgview = mug_msg_view_new ();
-
- mug_msg_view_set_msg (MUG_MSG_VIEW (mugdata->msgview), NULL);
+ mug_msg_view_set_note (MUG_MSG_VIEW(mugdata->msgview),
+ "<h1>Welcome to <i>mug</i>!</h1><hr>"
+ "<tt>mug</tt> is an experimental UI for <tt>mu</tt>, which will "
+ "slowly evolve into something useful.<br><br>Enjoy the ride.");
g_signal_connect (G_OBJECT (mugdata->mlist), "msg-selected",
G_CALLBACK (on_msg_selected), mugdata);
g_signal_connect (G_OBJECT (mugdata->mlist), "error-occured",
@@ -311,7 +314,7 @@ mug_main_area (MugData * mugdata)
mainarea = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
#else
mainarea = gtk_hbox_new (FALSE, 5);
-#endif /*!HAVE_GTK3 */
+#endif /*!HAVE_GTK3*/
w = mug_shortcuts_bar (mugdata);
gtk_box_pack_start (GTK_BOX (mainarea), w, FALSE, FALSE, 0);
@@ -336,7 +339,7 @@ mug_shell (MugData * mugdata)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
#else
vbox = gtk_vbox_new (FALSE, 2);
-#endif /*!HAVE_GTK3 */
+#endif /*!HAVE_GTK3*/
mugdata->toolbar = mug_toolbar (mugdata);
gtk_box_pack_start (GTK_BOX (vbox), mugdata->toolbar, FALSE, FALSE, 2);
@@ -353,12 +356,13 @@ mug_shell (MugData * mugdata)
gtk_window_set_default_size (GTK_WINDOW (mugdata->win), 700, 500);
gtk_window_set_resizable (GTK_WINDOW (mugdata->win), TRUE);
- // {
- // gchar *icon;
- // icon = g_strdup_printf ("%s%cmug.svg", ICONDIR, G_DIR_SEPARATOR);
- // gtk_window_set_icon_from_file (GTK_WINDOW (mugdata->win), icon, NULL);
- // g_free (icon);
- // }
+ {
+ gchar *icon;
+ icon = g_strdup_printf ("%s%cmug.svg",
+ MUGDIR, G_DIR_SEPARATOR);
+ gtk_window_set_icon_from_file (GTK_WINDOW (mugdata->win), icon, NULL);
+ g_free (icon);
+ }
return mugdata->win;
}
@@ -392,10 +396,12 @@ main (int argc, char *argv[])
memset (&mugdata, 0, sizeof (MugData));
if (!g_option_context_parse (octx, &argc, &argv, NULL)) {
+ g_option_context_free (octx);
g_printerr ("mug: error in options\n");
return 1;
}
+ g_option_context_free (octx);
mu_runtime_init (mugdata.muhome, "mug");
mugshell = mug_shell (&mugdata);
View
0  toys/mug2/mug.svg → toys/mug/mug.svg
File renamed without changes
View
65 toys/mug2/Makefile.am
@@ -1,65 +0,0 @@
-## Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## 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 decending into tests/
-SUBDIRS= .
-
-INCLUDES=-I${top_srcdir} -I${top_srcdir}/lib $(GTK_CFLAGS) $(WEBKIT_CFLAGS) -DICONDIR='"$(icondir)"' \
- -DMUG2DIR='"$(abs_srcdir)"' -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE
-
-# don't use -Werror, as it might break on other compilers
-# use -Wno-unused-parameters, because some callbacks may not
-# really need all the params they get
-AM_CFLAGS=-Wall -Wextra -Wno-unused-parameter -Wdeclaration-after-statement
-AM_CXXFLAGS=-Wall -Wextra -Wno-unused-parameter
-
-noinst_PROGRAMS= \
- mug2
-
-# note, mug.cc is '.cc' only because libmu must explicitly
-# be linked as c++, not c.
-mug2_SOURCES= \
- mug.c \
- mug-msg-list-view.c \
- mug-msg-list-view.h \
- mug-msg-view.h \
- mug-msg-view.c \
- mug-query-bar.h \
- mug-query-bar.c \
- mug-shortcuts.c \
- mug-shortcuts.h \
- dummy.cc
-
-# we need to use dummy.cc to enforce c++ linking...
-BUILT_SOURCES= \
- dummy.cc
-
-dummy.cc:
- touch dummy.cc
-
-DISTCLEANFILES= \
- $(BUILT_SOURCES)
-
-
-mug2_LDADD= \
- ${top_builddir}/lib/libmu.la \
- ${top_builddir}/widgets/libmuwidgets.la \
- ${GTK_LIBS}
-
-EXTRA_DIST= \
- mug.svg
View
466 toys/mug2/mug-msg-list-view.c
@@ -1,466 +0,0 @@
-/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
-/*
-** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
-**
-** This program is free software; you can redistribute it and/or modify it
-** under the terms of the GNU General Public License as published by the
-** 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 "mu-query.h"
-#include "mu-str.h"
-#include "mu-date.h"
-#include "mu-threader.h"
-
-/* 'private'/'protected' functions */
-static void mug_msg_list_view_class_init (MugMsgListViewClass * klass);
-static void mug_msg_list_view_init (MugMsgListView * obj);
-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 = 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)
-{
- MuFlags flags;
- MuMsgPrio prio;
-
- gtk_tree_model_get (tree_model, iter,
- MUG_COL_FLAGS, &flags, MUG_COL_PRIO, &prio, -1);
-
- g_object_set (G_OBJECT (renderer),
- "weight", (flags & MU_FLAG_NEW) ? 800 : 400,
- "weight", (flags & MU_FLAG_SEEN) ? 400 : 800,
- "foreground", prio == MU_MSG_PRIO_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 MugError
-mu_result_to_mug_error (MuError r)
-{
- switch (r) {
- case MU_ERROR_XAPIAN_DIR_NOT_ACCESSIBLE:
- return MUG_ERROR_XAPIAN_DIR;
- case MU_ERROR_XAPIAN_NOT_UP_TO_DATE:
- return MUG_ERROR_XAPIAN_NOT_UPTODATE;
- case MU_ERROR_XAPIAN_QUERY:
- return MUG_ERROR_QUERY;
- default:
- return MUG_ERROR_OTHER;
- }
-}
-
-static MuMsgIter *
-run_query (const char *xpath, const char *query, MugMsgListView * self)
-{
- GError *err;
- MuQuery *xapian;
- MuMsgIter *iter;
- MuStore *store;
-
- err = NULL;
- if (! (store = mu_store_new_read_only (xpath, &err)) ||
- ! (xapian = mu_query_new (store, &err))) {
- if (store)
- mu_store_unref (store);
- g_warning ("Error: %s", err->message);
- g_signal_emit (G_OBJECT (self),
- signals[MUG_ERROR_OCCURED], 0,
- mu_result_to_mug_error (err->code));
- g_error_free (err);
- return NULL;
- }
- mu_store_unref (store);
-
- iter = mu_query_run (xapian, query, TRUE, MU_MSG_FIELD_ID_DATE,
- TRUE, -1, &err);
- mu_query_destroy (xapian);
- if (!iter) {
- g_warning ("Error: %s", err->message);
- g_signal_emit (G_OBJECT (self),
- signals[MUG_ERROR_OCCURED], 0,
- mu_result_to_mug_error (err->code));
- g_error_free (err);
- return NULL;
- }
-
- return iter;
-}
-
-static void
-add_row (GtkTreeStore * store, MuMsg *msg, GtkTreeIter *treeiter)
-{
- const gchar *datestr, *flagstr;
- gchar *from, *to;
- time_t timeval;
-
- timeval = mu_msg_get_date (msg);
- datestr = timeval == 0 ? "-" : mu_date_display_s (timeval);
- from = empty_or_display_contact (mu_msg_get_from (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);
-
- /* if (0) { */
- /* GtkTreeIter myiter; */
- /* if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(store), */
- /* &myiter, path)) */
- /* g_warning ("%s: cannot get iter for %s",
- * __FUNCTION__, path); */
- /* } */
-
- gtk_tree_store_set (store, treeiter,
- MUG_COL_DATESTR, datestr,
- MUG_COL_MAILDIR, mu_msg_get_maildir (msg),
- MUG_COL_FLAGSSTR, flagstr,
- 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, timeval, -1);
- g_free (from);
- g_free (to);
-}
-
-static int
-update_model (GtkTreeStore *store, const char *xpath, const char *query,
- MugMsgListView *self)
-{
- MuMsgIter *iter;
- int count;
- const MuMsgIterThreadInfo *prev_ti = NULL;
-
- iter = run_query (xpath, query, self);
- if (!iter) {
- g_warning ("error: running query failed\n");
- return -1;
- }
-
- for (count = 0; !mu_msg_iter_is_done (iter);
- mu_msg_iter_next (iter), ++count) {
-
- GtkTreeIter treeiter, prev_treeiter;
- const MuMsgIterThreadInfo *ti;
-
- ti = mu_msg_iter_get_thread_info (iter);
-
- if (!prev_ti || !g_str_has_prefix (ti->threadpath,
- prev_ti->threadpath))
- gtk_tree_store_append (store, &treeiter, NULL);
- else
- gtk_tree_store_append (store, &treeiter, &prev_treeiter);
-
- /* don't unref msg */
- add_row (store, mu_msg_iter_get_msg_floating (iter), &treeiter);
-
- prev_ti = ti;
- prev_treeiter = treeiter;
- }
-
- mu_msg_iter_destroy (iter);
-
- return count;
-}
-
-int
-mug_msg_list_view_query (MugMsgListView * self, const char *query)
-{
- 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
82 toys/mug2/mug-msg-list-view.h
@@ -1,82 +0,0 @@
-/*
-** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
-**
-** This program is free software; you can redistribute it and/or modify it
-** under the terms of the GNU General Public License as published by the
-** 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 <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
159 toys/mug2/mug-msg-view.c
@@ -1,159 +0,0 @@
-/*
-** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
-**
-** This program is free software; you can redistribute it and/or modify it
-** under the terms of the GNU General Public License as published by the
-** Free Software Foundation; either version 3, or (at your option) any
-** later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software Foundation,
-** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-**
-*/
-#ifdef HAVE_CONFIG
-#include "config.h"
-#endif /*HAVE_CONFIG*/
-
-#include <unistd.h>
-#include <widgets/mu-msg-view.h>
-
-#include "mug-msg-view.h"
-#include "mu-msg.h"
-#include "mu-str.h"
-
-/* '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 */
-
-#ifdef HAVE_GTK3
-static GtkBoxClass *parent_class = NULL;
-G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_BOX);
-#else
-static GtkVBoxClass *parent_class = NULL;
-G_DEFINE_TYPE (MugMsgView, mug_msg_view, GTK_TYPE_VBOX);
-#endif /*!HAVE_GTK3*/
-
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
-static void
-mug_msg_view_class_init (MugMsgViewClass * klass)
-{
- GObjectClass *gobject_class;
- gobject_class = (GObjectClass *) klass;
-
- parent_class = 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_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (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 {
- 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
69 toys/mug2/mug-msg-view.h
@@ -1,69 +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_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 {
-#ifdef HAVE_GTK3
- GtkBox parent;
-#else
- GtkVBox parent;
-#endif /*!HAVE_GTK3*/
-};
-
-struct _MugMsgViewClass {
-#ifdef HAVE_GTK3
- GtkBoxClass parent_class;
-#else
- GtkVBoxClass parent_class;
-#endif /*!HAVE_GTK3*/
-
- /* insert signal callback declarations, e.g. */
- /* void (* my_event) (MugMsg* obj); */
-};
-
-/* member functions */
-GType mug_msg_view_get_type (void) G_GNUC_CONST;
-
-/* 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
118 toys/mug2/mug-query-bar.c
@@ -1,118 +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 };
-
-
-#ifdef HAVE_GTK3
-G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_BOX);
-#else
-G_DEFINE_TYPE (MugQueryBar, mug_query_bar, GTK_TYPE_HBOX);
-#endif /*!HAVE_GTK3*/
-
-
-static void
-mug_query_bar_class_init (MugQueryBarClass * klass)
-{
- 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
62 toys/mug2/mug-query-bar.h
@@ -1,62 +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 {
-#ifdef HAVE_GTK3
- GtkBox parent;
-#else
- GtkHBox parent;
-#endif /*!HAVE_GTK3*/
-};
-
-struct _MugQueryBarClass {
-#ifdef HAVE_GTK3
- GtkBox parent;
- GtkBoxClass parent_class;
-#else
- GtkHBox parent;
- GtkHBoxClass parent_class;
-#endif /*!HAVE_GTK3*/
-
- /* insert signal callback declarations, e.g. */
- void (*query_changed) (MugQueryBar * obj, const char *query);
-};
-
-/* 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
163 toys/mug2/mug-shortcuts.c
@@ -1,163 +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.
-**
-*/
-
-#include "mug-shortcuts.h"
-#include "mu-bookmarks.h"
-
-/* 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 };
-
-
-#ifdef HAVE_GTK3
-static GtkBoxClass *parent_class = NULL;
-G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_BOX);
-#else
-static GtkVBoxClass *parent_class = NULL;
-G_DEFINE_TYPE (MugShortcuts, mug_shortcuts, GTK_TYPE_VBOX);
-#endif /*!HAVE_GTK3*/
-
-static void
-mug_shortcuts_class_init (MugShortcutsClass * klass)
-{
- GObjectClass *gobject_class;
- gobject_class = (GObjectClass *) klass;
-
- parent_class = 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);
-
-#ifdef HAVE_GTK3
- obj->_priv->_bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
-#else
- obj->_priv->_bbox = gtk_vbutton_box_new ();
-#endif /*!HAVE_GTK3*/
-
- 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
79 toys/mug2/mug-shortcuts.h
@@ -1,79 +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 {
-#ifdef HAVE_GTK3
- GtkBox parent;
-#else
- GtkVBox parent;
-#endif /*!HAVE_GTK3*/
-
- /* private */
- MugShortcutsPrivate *_priv;
-};
-
-struct _MugShortcutsClass {
-#ifdef HAVE_GTK3
- GtkBoxClass parent_class;
-#else
- GtkVBoxClass parent_class;
-#endif /*!HAVE_GTK3*/
-
- void (*clicked) (MugShortcuts * obj, const char *query);
-};
-
-/* 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 *