* implement mug_msg_list_view_move_(next|prev) to move cursor to prev/next

row; hook it up with the toolbar
This commit is contained in:
Dirk-Jan C. Binnema 2010-11-02 21:51:10 +02:00
parent 70648b8bd5
commit 484808d641
3 changed files with 64 additions and 4 deletions

View File

@ -202,6 +202,50 @@ mug_msg_list_view_finalize (GObject *obj)
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
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)
{

View File

@ -56,6 +56,10 @@ GtkWidget* mug_msg_list_view_new (const char *xpath);
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);
G_END_DECLS
#endif /* __MUG_MSG_LIST_VIEW_H__ */

View File

@ -59,15 +59,22 @@ enum _ToolAction {
typedef enum _ToolAction ToolAction;
static void
on_tool_button_clicked (GtkToolButton *btn, MugData *data)
on_tool_button_clicked (GtkToolButton *btn, MugData *mugdata)
{
ToolAction action;
action = (ToolAction)GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(btn), "action"));
action = (ToolAction)GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(btn),
"action"));
switch (action) {
case ACTION_DO_QUIT:
gtk_main_quit();
break;
case ACTION_NEXT_MSG:
mug_msg_list_view_move_next (MUG_MSG_LIST_VIEW(mugdata->mlist));
break;
case ACTION_PREV_MSG:
mug_msg_list_view_move_prev (MUG_MSG_LIST_VIEW(mugdata->mlist));
break;
default:
g_print ("%u\n", action);
}
@ -174,11 +181,16 @@ mug_query_area (MugData *mugdata)
GtkWidget *queryarea;
GtkWidget *paned, *querybar;
GtkWidget *scrolled;
gchar* xdir;
queryarea = gtk_vbox_new (FALSE, 2);
paned = gtk_vpaned_new ();
mugdata->mlist = mug_msg_list_view_new("/home/dbinnema/.mu/xapian/");
xdir = mu_util_guess_xapian_dir (NULL);
mugdata->mlist = mug_msg_list_view_new(xdir);
g_free (xdir);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER(scrolled), mugdata->mlist);