* 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:
@ -202,6 +202,50 @@ mug_msg_list_view_finalize (GObject *obj)
|
|||||||
G_OBJECT_CLASS(parent_class)->finalize (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*
|
GtkWidget*
|
||||||
mug_msg_list_view_new (const char *xpath)
|
mug_msg_list_view_new (const char *xpath)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -56,6 +56,10 @@ GtkWidget* mug_msg_list_view_new (const char *xpath);
|
|||||||
|
|
||||||
int mug_msg_list_view_query (MugMsgListView *self, const char *query);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __MUG_MSG_LIST_VIEW_H__ */
|
#endif /* __MUG_MSG_LIST_VIEW_H__ */
|
||||||
|
|||||||
20
mug/mug.cc
20
mug/mug.cc
@ -59,15 +59,22 @@ enum _ToolAction {
|
|||||||
typedef enum _ToolAction ToolAction;
|
typedef enum _ToolAction ToolAction;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_tool_button_clicked (GtkToolButton *btn, MugData *data)
|
on_tool_button_clicked (GtkToolButton *btn, MugData *mugdata)
|
||||||
{
|
{
|
||||||
ToolAction action;
|
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) {
|
switch (action) {
|
||||||
|
|
||||||
case ACTION_DO_QUIT:
|
case ACTION_DO_QUIT:
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
break;
|
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:
|
default:
|
||||||
g_print ("%u\n", action);
|
g_print ("%u\n", action);
|
||||||
}
|
}
|
||||||
@ -175,10 +182,15 @@ mug_query_area (MugData *mugdata)
|
|||||||
GtkWidget *paned, *querybar;
|
GtkWidget *paned, *querybar;
|
||||||
GtkWidget *scrolled;
|
GtkWidget *scrolled;
|
||||||
|
|
||||||
|
gchar* xdir;
|
||||||
|
|
||||||
queryarea = gtk_vbox_new (FALSE, 2);
|
queryarea = gtk_vbox_new (FALSE, 2);
|
||||||
|
|
||||||
paned = gtk_vpaned_new ();
|
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);
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_container_add (GTK_CONTAINER(scrolled), mugdata->mlist);
|
gtk_container_add (GTK_CONTAINER(scrolled), mugdata->mlist);
|
||||||
|
|||||||
Reference in New Issue
Block a user