#include "filedata.h"
#include "layout_image.h"
#include "layout_util.h"
+#include "menu.h"
#include "pixbuf_util.h"
#include "ui_fileops.h"
#include "ui_tree_edit.h"
#include "ui_menu.h"
+#include "ui_misc.h"
#include "utilops.h"
#include "uri_utils.h"
#include "view_dir_list.h"
pf->open = gtk_widget_render_icon(widget, GTK_STOCK_OPEN, size, NULL);
pf->deny = gtk_widget_render_icon(widget, GTK_STOCK_STOP, size, NULL);
pf->parent = gtk_widget_render_icon(widget, GTK_STOCK_GO_UP, size, NULL);
- /* FIXME: this is not a suitable icon */
- pf->link = gtk_widget_render_icon(widget, GTK_STOCK_REDO, size, NULL);
+ pf->link = gtk_widget_render_icon(widget, GTK_STOCK_REDO, size, NULL); /** @FIXME this is not a suitable icon */
#else
/* GQView legacy icons */
pf->close = pixbuf_inline(PIXBUF_INLINE_FOLDER_CLOSED);
g_free(vd);
}
-ViewDir *vd_new(DirViewType type, FileData *dir_fd)
+ViewDir *vd_new(LayoutWindow *lw)
{
ViewDir *vd = g_new0(ViewDir, 1);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vd->widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ vd->layout = lw;
vd->pf = folder_icons_new(vd->widget);
- switch (type)
- {
- case DIRVIEW_LIST: vd = vdlist_new(vd, dir_fd); break;
- case DIRVIEW_TREE: vd = vdtree_new(vd, dir_fd); break;
- }
+ switch (lw->options.dir_view_type)
+ {
+ case DIRVIEW_LIST: vd = vdlist_new(vd, lw->dir_fd); break;
+ case DIRVIEW_TREE: vd = vdtree_new(vd, lw->dir_fd); break;
+ }
gtk_container_add(GTK_CONTAINER(vd->widget), vd->view);
file_data_register_notify_func(vd_notify_cb, vd, NOTIFY_PRIORITY_HIGH);
/* vd_set_fd expects that vd_notify_cb is already registered */
- if (dir_fd) vd_set_fd(vd, dir_fd);
+ if (lw->dir_fd) vd_set_fd(vd, lw->dir_fd);
gtk_widget_show(vd->view);
if (vd->layout) layout_refresh(vd->layout);
}
-static void vd_pop_menu_new_rename_cb(gboolean success, const gchar *new_path, gpointer data)
+static void vd_pop_menu_new_folder_cb(gboolean success, const gchar *new_path, gpointer data)
{
ViewDir *vd = data;
FileData *fd = NULL;
+ GtkTreeIter iter;
+ GtkTreePath *tpath;
+ GtkTreeModel *store;
+
if (!success) return;
switch (vd->type)
}
break;
}
- vd_rename_by_data(vd, fd);
+
+ if (!fd || !vd_find_row(vd, fd, &iter)) return;
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
+ tpath = gtk_tree_model_get_path(store, &iter);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE);
+
+ gtk_tree_path_free(tpath);
}
static void vd_pop_menu_new_cb(GtkWidget *widget, gpointer data)
break;
}
- file_util_create_dir(dir_fd, widget, vd_pop_menu_new_rename_cb, vd);
+ file_util_create_dir(dir_fd, vd->layout->window, vd_pop_menu_new_folder_cb, vd);
}
static void vd_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
vd_rename_by_data(vd, vd->click_fd);
}
+static void vd_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data)
+{
+ ViewDir *vd = data;
+ gboolean ascend;
+
+ if (!vd) return;
+
+ if (!vd->layout) return;
+
+ ascend = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
+ layout_views_set_sort(vd->layout, vd->layout->options.dir_view_list_sort.method, ascend);
+
+ if (vd->layout) layout_refresh(vd->layout);
+}
+
+static void vd_pop_menu_sort_cb(GtkWidget *widget, gpointer data)
+{
+ ViewDir *vd;
+ SortType type;
+
+ vd = submenu_item_get_data(widget);
+
+ if (!vd) return;
+ if (!vd->layout) return;
+
+ type = (SortType)GPOINTER_TO_INT(data);
+
+ if (type == SORT_NAME || type == SORT_TIME)
+ {
+ layout_views_set_sort(vd->layout, type, vd->layout->options.dir_view_list_sort.ascend);
+
+ if (vd->layout) layout_refresh(vd->layout);
+ }
+}
+
GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd)
{
GtkWidget *menu;
gboolean active;
gboolean rename_delete_active = FALSE;
gboolean new_folder_active = FALSE;
+ GtkWidget *submenu;
+ GtkWidget *item;
active = (fd != NULL);
switch (vd->type)
menu_item_add_radio(menu, _("View as _Tree"), GINT_TO_POINTER(DIRVIEW_TREE), vd->type == DIRVIEW_TREE,
G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd);
+ if (vd->type == DIRVIEW_LIST)
+ {
+ submenu = submenu_add_dir_sort(NULL, G_CALLBACK(vd_pop_menu_sort_cb), vd, FALSE, FALSE, TRUE, vd->layout->options.dir_view_list_sort.method);
+ menu_item_add_check(submenu, _("Ascending"), vd->layout->options.dir_view_list_sort.ascend, G_CALLBACK(vd_pop_menu_sort_ascend_cb), (vd));
+ item = menu_item_add(menu, _("_Sort"), NULL, NULL);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
+ }
+
menu_item_add_divider(menu);
menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files,
void vd_new_folder(ViewDir *vd, FileData *dir_fd)
{
- file_util_create_dir(dir_fd, vd->widget, vd_pop_menu_new_rename_cb, vd);
+ file_util_create_dir(dir_fd, vd->layout->window, vd_pop_menu_new_folder_cb, vd);
}
/*
ViewDir *vd = data;
GtkTreePath *tpath;
FileData *fd = NULL;
+ GdkDragAction action;
vd->click_fd = NULL;
if (active)
{
- if (gdk_drag_context_get_actions(context) == GDK_ACTION_COPY)
+/** @FIXME With GTK2 gdk_drag_context_get_actions() shows the state of the
+ * shift and control keys during the drag operation. With GTK3 this is not
+ * so. This is a workaround.
+ */
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkModifierType mask;
+
+ gdk_window_get_pointer(gtk_widget_get_window(widget), NULL, NULL, &mask);
+ if (mask & GDK_CONTROL_MASK)
+ {
+ action = GDK_ACTION_COPY;
+ }
+ else if (mask & GDK_SHIFT_MASK)
+ {
+ action = GDK_ACTION_MOVE;
+ }
+#else
+ action = (gdk_drag_context_get_actions(context));
+#endif
+ if (action != GDK_ACTION_COPY && action != GDK_ACTION_MOVE)
+ {
+ if (options->dnd_default_action == DND_ACTION_COPY)
+ {
+ action = GDK_ACTION_COPY;
+ }
+ else if (options->dnd_default_action == DND_ACTION_MOVE)
+ {
+ action = GDK_ACTION_MOVE;
+ }
+ }
+
+ if (action == GDK_ACTION_COPY)
{
file_util_copy_simple(list, fd->path, vd->widget);
done = TRUE;
list = NULL;
}
- else if (gdk_drag_context_get_actions(context) == GDK_ACTION_MOVE)
+ else if (action == GDK_ACTION_MOVE)
{
file_util_move_simple(list, fd->path, vd->widget);
done = TRUE;
GtkTreePath *tpath;
FileData *fd = NULL;
+ if (defined_mouse_buttons(widget, bevent, vd->layout))
+ {
+ return TRUE;
+ }
+
if (vd->type == DIRVIEW_LIST && !options->view_dir_list_single_click_enter)
return FALSE;
{
ViewDir *vd = data;
gboolean ret = FALSE;
+ FileData *fd;
+ GtkTreePath *tpath;
+ GtkTreeIter iter;
+ NodeData *nd = NULL;
+ GtkTreeModel *store;
+
+ if (bevent->button == MOUSE_BUTTON_RIGHT)
+ {
+ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, &tpath, NULL, NULL, NULL))
+ {
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
+ gtk_tree_model_get_iter(store, &iter, tpath);
+
+ switch (vd->type)
+ {
+ case DIRVIEW_LIST:
+ gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
+ vd->click_fd = fd;
+ break;
+ case DIRVIEW_TREE:
+ gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
+ vd->click_fd = (nd) ? nd->fd : NULL;
+ }
+
+ if (vd->click_fd)
+ {
+ vd_color_set(vd, vd->click_fd, TRUE);
+ }
+ }
+
+ vd->popup = vd_pop_menu(vd, vd->click_fd);
+ gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
+ bevent->button, bevent->time);
+
+ return TRUE;
+ }
switch (vd->type)
{