#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,
gchar *buffer = NULL;
GError *error = NULL;
gsize termpos;
- /* FIXME: it should be possible to terminate the command with a null character */
+ /** @FIXME it should be possible to terminate the command with a null character */
g_io_channel_set_line_term(source, "<gq_end_of_command>", -1);
while ((status = g_io_channel_read_line(source, &buffer, NULL, &termpos, &error)) == G_IO_STATUS_NORMAL)
{
addr.sun_family = AF_UNIX;
sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX);
strncpy(addr.sun_path, path, sun_path_len);
- if (bind(fd, &addr, sizeof(addr)) == -1 ||
+ if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1 ||
listen(fd, REMOTE_SERVER_BACKLOG) == -1)
{
log_printf("error subscribing to socket: %s\n", strerror(errno));
addr.sun_family = AF_UNIX;
sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX);
strncpy(addr.sun_path, path, sun_path_len);
- if (connect(fd, &addr, sizeof(addr)) == -1)
+ if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
{
DEBUG_1("error connecting to socket: %s", strerror(errno));
close(fd);
static void gr_slideshow_start_rec(const gchar *text, GIOChannel *channel, gpointer data)
{
GList *list;
- FileData *dir_fd = file_data_new_dir(text);
+ gchar *tilde_filename;
+
+ tilde_filename = expand_tilde(text);
+
+ FileData *dir_fd = file_data_new_dir(tilde_filename);
+ g_free(tilde_filename);
layout_valid(&lw_id);
list = filelist_recursive_full(dir_fd, lw_id->sort_method, lw_id->sort_ascend);
{
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 collection_list List of all collections in argv
+ * @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 (gchar *path)
+ * @param collection_list List of all collections in argv
*/
void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path,
GList *cmd_list, GList *collection_list)
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;
}