mirror of https://github.com/djcb/mu.git
* mug-msg-list-view: remember query, add mug_msg_list_view_get_query to
retrieve it. update mug.cc to use in in the statusbar
This commit is contained in:
parent
8eb60ec141
commit
cf77cbc1d2
|
@ -47,6 +47,7 @@ typedef struct _MugMsgListViewPrivate MugMsgListViewPrivate;
|
|||
struct _MugMsgListViewPrivate {
|
||||
GtkListStore *_store;
|
||||
char *_xpath;
|
||||
char *_query;
|
||||
};
|
||||
#define MUG_MSG_LIST_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
||||
MUG_TYPE_MSG_LIST_VIEW, \
|
||||
|
@ -155,6 +156,7 @@ mug_msg_list_view_init (MugMsgListView *obj)
|
|||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(obj);
|
||||
|
||||
priv->_xpath = NULL;
|
||||
priv->_query = NULL;
|
||||
|
||||
priv->_store = gtk_list_store_new (MUG_N_COLS,
|
||||
G_TYPE_STRING,
|
||||
|
@ -198,6 +200,7 @@ mug_msg_list_view_finalize (GObject *obj)
|
|||
g_object_unref (priv->_store);
|
||||
|
||||
g_free (priv->_xpath);
|
||||
g_free (priv->_query);
|
||||
|
||||
G_OBJECT_CLASS(parent_class)->finalize (obj);
|
||||
}
|
||||
|
@ -243,9 +246,6 @@ mug_msg_list_view_move_prev (MugMsgListView *self)
|
|||
return msg_list_view_move (self, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GtkWidget*
|
||||
mug_msg_list_view_new (const char *xpath)
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ update_model (GtkListStore *store, const char *xpath, const char *query)
|
|||
MuQuery *xapian;
|
||||
MuMsgIter *iter;
|
||||
int count;
|
||||
|
||||
|
||||
xapian = mu_query_new (xpath);
|
||||
if (!xapian) {
|
||||
g_printerr ("Failed to create a Xapian query\n");
|
||||
|
@ -319,8 +319,20 @@ mug_msg_list_view_query (MugMsgListView *self, const char *query)
|
|||
priv = MUG_MSG_LIST_VIEW_GET_PRIVATE(self);
|
||||
gtk_list_store_clear (priv->_store);
|
||||
|
||||
g_free (priv->_query);
|
||||
priv->_query = query ? g_strdup(query) : NULL;
|
||||
|
||||
if (!query)
|
||||
return TRUE;
|
||||
|
||||
|
||||
return update_model (priv->_store, priv->_xpath, query);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ int mug_msg_list_view_query (MugMsgListView *self, const char *query);
|
|||
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
|
||||
|
||||
|
|
20
mug/mug.cc
20
mug/mug.cc
|
@ -35,7 +35,7 @@ struct _MugData {
|
|||
GtkWidget *statusbar;
|
||||
GtkWidget *mlist;
|
||||
GtkWidget *toolbar;
|
||||
GtkWidget *msg;
|
||||
GtkWidget *msgview;
|
||||
};
|
||||
typedef struct _MugData MugData;
|
||||
|
||||
|
@ -136,11 +136,18 @@ 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);
|
||||
|
||||
count = mug_msg_list_view_query (MUG_MSG_LIST_VIEW(mugdata->mlist),
|
||||
query);
|
||||
if (count >= 0) {
|
||||
gchar *msg = g_strdup_printf ("%d message%s found", count,
|
||||
count > 1 ? "s" : "");
|
||||
gchar *msg =
|
||||
g_strdup_printf ("%d message%s found matching '%s'",
|
||||
count,
|
||||
count > 1 ? "s" : "",
|
||||
mug_msg_list_view_get_query
|
||||
(MUG_MSG_LIST_VIEW(mugdata->mlist)));
|
||||
gtk_statusbar_push (GTK_STATUSBAR(mugdata->statusbar), 0, msg);
|
||||
g_free (msg);
|
||||
}
|
||||
|
@ -151,7 +158,7 @@ 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->msg), mpath);
|
||||
mug_msg_view_set_msg (MUG_MSG_VIEW(mugdata->msgview), mpath);
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,13 +216,13 @@ mug_query_area (MugData *mugdata)
|
|||
gtk_container_add (GTK_CONTAINER(scrolled), mugdata->mlist);
|
||||
gtk_paned_add1 (GTK_PANED (paned), scrolled);
|
||||
|
||||
mugdata->msg = mug_msg_view_new ();
|
||||
mugdata->msgview = mug_msg_view_new ();
|
||||
g_signal_connect (G_OBJECT(mugdata->mlist), "msg-selected",
|
||||
G_CALLBACK(on_msg_selected), mugdata);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled),
|
||||
mugdata->msg);
|
||||
mugdata->msgview);
|
||||
gtk_paned_add2 (GTK_PANED (paned), scrolled);
|
||||
|
||||
querybar = mug_querybar();
|
||||
|
@ -245,7 +252,6 @@ mug_main_area (MugData *mugdata)
|
|||
}
|
||||
|
||||
|
||||
|
||||
GtkWidget*
|
||||
mug_shell (MugData *mugdata)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue