if (lw->vf) vf_select_invert(lw->vf);
}
+void layout_select_list(LayoutWindow *lw, GList *list)
+{
+ if (!layout_valid(&lw)) return;
+
+ if (lw->vf)
+ {
+ vf_select_list(lw->vf, list);
+ }
+}
+
void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode)
{
if (!layout_valid(&lw)) return;
void layout_select_all(LayoutWindow *lw);
void layout_select_none(LayoutWindow *lw);
void layout_select_invert(LayoutWindow *lw);
+void layout_select_list(LayoutWindow *lw, GList *list);
void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode);
void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode);
{
if (!*path) *path = remove_level_from_path(path_parsed);
if (!*file) *file = g_strdup(path_parsed);
- *list = g_list_prepend(*list, file_data_new_no_grouping(path_parsed));
+ *list = g_list_prepend(*list, path_parsed);
}
}
remote_list = g_list_prepend(remote_list, geometry);
}
remote_list = g_list_prepend(remote_list, "--new-window");
- }
+ }
+ else if (!remote_server_exists(app_lock))
+ {
+ /* Geeqie started for first time but with --remote option
+ */
+ remote_do = FALSE;
+ }
g_free(app_lock);
}
remote_list = g_list_prepend(remote_list, pwd);
remote_control(argv[0], remote_list, command_line->path, list, command_line->collection_list);
+ /* There is no return to this point
+ */
g_free(pwd);
g_free(current_dir);
}
}
else
{
- filelist_free(list);
+ string_list_free(list);
command_line->cmd_list = NULL;
}
gchar *buf;
CollectionData *cd = NULL;
gboolean disable_clutter = FALSE;
+ gboolean single_dir = TRUE;
+ LayoutWindow *lw;
#ifdef HAVE_GTHREAD
#if !GLIB_CHECK_VERSION(2,32,0)
layout_editors_reload_start();
+ /* If no --list option, open a separate collection window for each
+ * .gqv file on the command line
+ */
if (command_line->collection_list && !command_line->startup_command_line_collection)
{
GList *work;
command_line->ssi = secure_open(pathl);
}
- if (command_line->cmd_list ||
- (command_line->startup_command_line_collection && command_line->collection_list))
+ /* If there is a files list on the command line and no --list option,
+ * check if they are all in the same folder
+ */
+ if (command_line->cmd_list && !(command_line->startup_command_line_collection))
{
GList *work;
+ gchar *path = NULL;
- if (command_line->startup_command_line_collection)
- {
- CollectWindow *cw;
+ work = command_line->cmd_list;
- cw = collection_window_new("");
- cd = cw->cd;
- }
- else
+ while (work && single_dir)
{
- cd = collection_new(""); /* if we pass NULL, untitled counter is falsely increm. */
+ gchar *dirname;
+
+ dirname = g_path_get_dirname(work->data);
+ if (!path)
+ {
+ path = g_strdup(dirname);
+ }
+ else
+ {
+ if (g_strcmp0(path, dirname) != 0)
+ {
+ single_dir = FALSE;
+ }
+ }
+ g_free(dirname);
+ work = work->next;
}
+ g_free(path);
+ }
- g_free(cd->path);
- cd->path = NULL;
- g_free(cd->name);
- cd->name = g_strdup(_("Command line"));
+ /* Files from multiple folders, or --list option given
+ * then open an unnamed collection and insert all files
+ */
+ if ((command_line->cmd_list && !single_dir) || (command_line->startup_command_line_collection))
+ {
+ GList *work;
+ CollectWindow *cw;
+
+ cw = collection_window_new(NULL);
+ cd = cw->cd;
collection_path_changed(cd);
work = command_line->cmd_list;
while (work)
{
- collection_add(cd, (FileData *)work->data, FALSE);
+ FileData *fd;
+
+ fd = file_data_new_simple(work->data);
+ collection_add(cd, fd, FALSE);
+ file_data_unref(fd);
work = work->next;
}
collection_get_first(first_collection));
}
+ /* If the files on the command line are from one folder, select those files
+ */
+ lw = NULL;
+ layout_valid(&lw);
+
+ if (single_dir && command_line->cmd_list)
+ {
+ GList *work;
+ GList *selected;
+ FileData *fd;
+
+ selected = NULL;
+ work = command_line->cmd_list;
+ while (work)
+ {
+ fd = file_data_new_simple((gchar *)work->data);
+ selected = g_list_append(selected, fd);
+ file_data_unref(fd);
+ work = work->next;
+ }
+ layout_select_list(lw, selected);
+ }
+
buf = g_build_filename(get_rc_dir(), ".command", NULL);
remote_connection = remote_server_init(buf, cd);
g_free(buf);
#include "slideshow.h"
#include "ui_fileops.h"
#include "rcfile.h"
+#include "view_file.h"
#include <sys/socket.h>
#include <sys/un.h>
typedef struct _RemoteData RemoteData;
struct _RemoteData {
CollectionData *command_collection;
+ GList *file_list;
+ gboolean single_dir;
};
/* To enable file names containing newlines to be processed correctly,
{
RemoteData *remote_data = data;
- if (remote_data->command_collection)
- {
- collection_unref(remote_data->command_collection);
- remote_data->command_collection = NULL;
- }
+ remote_data->command_collection = NULL;
+ remote_data->file_list = NULL;
+ remote_data->single_dir = TRUE;
}
static void gr_list_add(const gchar *text, GIOChannel *channel, gpointer data)
{
RemoteData *remote_data = data;
gboolean new = TRUE;
+ gchar *path = NULL;
+ FileData *fd;
+ FileData *first;
- if (!remote_data->command_collection)
+ /* If there is a files list on the command line
+ * check if they are all in the same folder
+ */
+ if (remote_data->single_dir)
{
+ GList *work;
+ work = remote_data->file_list;
+ while (work && remote_data->single_dir)
+ {
+ gchar *dirname;
+ dirname = g_path_get_dirname(((FileData *)work->data)->path);
+ if (!path)
+ {
+ path = g_strdup(dirname);
+ }
+ else
+ {
+ if (g_strcmp0(path, dirname) != 0)
+ {
+ remote_data->single_dir = FALSE;
+ }
+ }
+ g_free(dirname);
+ work = work->next;
+ }
+ g_free(path);
+ }
+
+ gchar *pathname = g_path_get_dirname(text);
+ layout_set_path(lw_id, pathname);
+ g_free(pathname);
+
+ fd = file_data_new_simple(text);
+ remote_data->file_list = g_list_append(remote_data->file_list, fd);
+ file_data_unref(fd);
+
+ vf_select_none(lw_id->vf);
+ remote_data->file_list = g_list_reverse(remote_data->file_list);
+
+ layout_select_list(lw_id, remote_data->file_list);
+ layout_refresh(lw_id);
+ first = (FileData *)(g_list_first(vf_selection_get_list(lw_id->vf))->data);
+ layout_set_fd(lw_id, first);
+
CollectionData *cd;
+ CollectWindow *cw;
- cd = collection_new("");
+ if (!remote_data->command_collection && !remote_data->single_dir)
+ {
+ cw = collection_window_new(NULL);
+ cd = cw->cd;
- g_free(cd->path);
- cd->path = NULL;
- g_free(cd->name);
- cd->name = g_strdup(_("Command line"));
+ collection_path_changed(cd);
remote_data->command_collection = cd;
}
- else
+ else if (!remote_data->single_dir)
{
new = (!collection_get_first(remote_data->command_collection));
}
- if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
+ if (!remote_data->single_dir)
{
layout_image_set_collection(lw_id, remote_data->command_collection, collection_get_first(remote_data->command_collection));
+ if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
+ {
+ layout_image_set_collection(lw_id, remote_data->command_collection, collection_get_first(remote_data->command_collection));
+ }
}
}
* \param arg_exec Binary (argv0)
* \param remote_list Evaluated and recognized remote commands
* \param path The current path
- * \param cmd_list List of all non collections in Path
+ * \param cmd_list List of all non collections in Path (gchar *path)
* \param collection_list List of all collections in argv
*/
void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path,
work = cmd_list;
while (work)
{
- FileData *fd;
gchar *text;
- fd = work->data;
- work = work->next;
-
- text = g_strconcat(prefix, fd->path, NULL);
+ text = g_strconcat(prefix, work->data, NULL);
remote_client_send(rc, text);
g_free(text);
+ work = work->next;
sent = TRUE;
}
void vf_select_none(ViewFile *vf);
void vf_select_invert(ViewFile *vf);
void vf_select_by_fd(ViewFile *vf, FileData *fd);
+void vf_select_list(ViewFile *vf, GList *list);
void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
void vf_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
}
}
+void vf_select_list(ViewFile *vf, GList *list)
+{
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: vflist_select_list(vf, list); break;
+ case FILEVIEW_ICON: vficon_select_list(vf, list); break;
+ }
+}
+
void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
{
switch (vf->type)
vficon_set_focus(vf, fd);
}
+void vficon_select_list(ViewFile *vf, GList *list)
+{
+ GList *work;
+ FileData *fd;
+
+ if (!list) return;
+
+ work = list;
+ while (work)
+ {
+ fd = work->data;
+ if (g_list_find(vf->list, fd))
+ {
+ VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, fd);
+ vficon_selection_add(vf, fd, SELECTION_SELECTED, NULL);
+ }
+ work = work->next;
+ }
+}
+
void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
{
GList *work;
void vficon_select_none(ViewFile *vf);
void vficon_select_invert(ViewFile *vf);
void vficon_select_by_fd(ViewFile *vf, FileData *fd);
+void vficon_select_list(ViewFile *vf, GList *list);
void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
}
}
+void vflist_select_list(ViewFile *vf, GList *list)
+{
+ GtkTreeIter iter;
+ GList *work;
+
+ work = list;
+
+ while (work)
+ {
+ FileData *fd;
+
+ fd = work->data;
+
+ if (vflist_find_row(vf, fd, &iter) < 0) return;
+ if (!vflist_row_is_selected(vf, fd))
+ {
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
+ gtk_tree_selection_select_iter(selection, &iter);
+ }
+ work = work->next;
+ }
+}
+
static void vflist_select_closest(ViewFile *vf, FileData *sel_fd)
{
GList *work;
void vflist_select_none(ViewFile *vf);
void vflist_select_invert(ViewFile *vf);
void vflist_select_by_fd(ViewFile *vf, FileData *fd);
+void vflist_select_list(ViewFile *vf, GList *list);
void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);