Example #1
0
void file_dialog_sync_history(FileDialog *fdlg, gboolean dir_only)
{
	if (!fdlg->dest_path) return;

	if (!dir_only ||
	    (dir_only && isdir(fdlg->dest_path)) )
		{
		tab_completion_append_to_history(fdlg->entry, fdlg->dest_path);
		}
	else
		{
		gchar *buf = remove_level_from_path(fdlg->dest_path);
		tab_completion_append_to_history(fdlg->entry, buf);
		g_free(buf);
		}
}
Example #2
0
gint layout_set_path(LayoutWindow *lw, const gchar *path)
{
	gint have_file = FALSE;

	if (!layout_valid(&lw)) return FALSE;

	if (!path || !isname(path)) return FALSE;
	if (lw->path && path && strcmp(path, lw->path) == 0)
		{
		return TRUE;
		}

	if (isdir(path))
		{
		g_free(lw->path);
		lw->path = g_strdup(path);
		}
	else
		{
		gchar *base;

		base = remove_level_from_path(path);
		if (lw->path && strcmp(lw->path, base) == 0)
			{
			g_free(base);
			}
		else if (isdir(base))
			{
			g_free(lw->path);
			lw->path = base;
			}
		else
			{
			g_free(base);
			return FALSE;
			}
		if (isfile(path)) have_file = TRUE;
		}

	if (lw->path_entry) tab_completion_append_to_history(lw->path_entry, lw->path);
	layout_sync_path(lw);

	if (have_file)
		{
		gint row;

		row = layout_list_get_index(lw, path);
		if (row >= 0)
			{
			layout_image_set_index(lw, row);
			}
		else
			{
			layout_image_set_path(lw, path);
			}
		}
	else if (!lazy_image_sync)
		{
		layout_image_set_index(lw, 0);
		}

	return TRUE;
}