Skip to content

Commit

Permalink
add back button to toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jan 29, 2014
1 parent 4997403 commit 59d89ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/dirview.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define TOOLBAR_PREPEND 0

DirView *dirview = NULL;
GtkCTreeNode *prev_node = NULL;

static void cb_dirview_refresh_dir_tree (GtkToolButton *button, DirView *dv);
static void cb_dirview_mkdir (void);
Expand All @@ -59,24 +60,33 @@ static GtkItemFactoryEntry dirview_popup_items[] = {
static void dirview_update_toolbar (DirView * dv);
static void dirview_make_visible (DirView * dv, GtkCTreeNode * node);

static void
cb_dirview_back(GtkToolButton *button, DirView *dv)
{
dirview_select_node(dv, prev_node);
}

static gint
cb_dirview_button_press_event (GtkWidget * widget, GdkEventButton * event,
gpointer data)
{
DirView *dv = data;
GtkCTreeNode *node = GTK_CLIST(dv->dirtree)->selection->data;

if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
prev_node = node;
return FALSE;
}

if (event->type == GDK_BUTTON_PRESS && event->button == 3)
{
GtkWidget *dirview_popup, *menuitem;
GtkItemFactory *ifactory;
GtkCTreeNode *node;
DirTreeNode *dirnode;
gint n_menu_items;
gchar *path, *parent, *node_text;
gboolean expanded, is_leaf;

node = GTK_CLIST (dv->dirtree)->selection->data;

if (!node)
return FALSE;

Expand Down Expand Up @@ -173,6 +183,7 @@ cb_dirview_key_press (GtkWidget * widget, GdkEventKey * event, DirView * dv)
return FALSE;

node = sel_list->data;
prev_node = node;

switch (keyval)
{
Expand Down Expand Up @@ -310,6 +321,7 @@ cb_dirview_home(GtkToolButton *button, DirView *dv)

sel_list = GTK_CLIST (dv->dirtree)->selection;
node = sel_list->data;
prev_node = node;

while (GTK_CTREE_NODE_PREV (node)) {
node = GTK_CTREE_NODE_PREV (node);
Expand Down Expand Up @@ -338,6 +350,7 @@ cb_dirview_down(GtkToolButton *button, DirView *dv)
return;

node = sel_list->data;
prev_node = node;
node = GTK_CTREE_NODE_NEXT (node);

dirview_select_node(dv, node);
Expand All @@ -356,7 +369,7 @@ cb_dirview_up(GtkToolButton *button, DirView *dv)
return;

node = sel_list->data;

prev_node = node;
node = GTK_CTREE_NODE_PREV (node);

dirview_select_node(dv, node);
Expand Down Expand Up @@ -823,6 +836,9 @@ dirview_create_toolbar(DirView * dv)
dirview_register_button(dv, toolbar, &(dv->toolbar_go_home),
"Home", home_xpm, cb_dirview_home);

dirview_register_button(dv, toolbar, &(dv->toolbar_back),
"Back", left_xpm, cb_dirview_back);

gtk_widget_show_all (toolbar);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);

Expand Down
1 change: 1 addition & 0 deletions src/dirview.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct _DirView
GtkToolButton *toolbar_expand_btn;
GtkToolButton *toolbar_show_dotfile_btn;
GtkToolButton *toolbar_go_home;
GtkToolButton *toolbar_back;

GtkWidget *scroll_win;
GtkWidget *dirtree;
Expand Down

0 comments on commit 59d89ff

Please sign in to comment.