Beispiel #1
0
// Recv TIGroup
TILP_EXPORT void on_tilp_button7_clicked(GtkButton* button, gpointer user_data)
{
	char* src_filename;
	const char *dst_filename;
	const char *dst_filename2;
	int ret;
	int mode = TIG_ALL;

	ret = backup_box(_("Backup"), _("Data to backup:"), &mode);
	if(ret != BUTTON1)
		return;

	if (tilp_calc_recv_tigroup(mode) != 0)
		return;

	src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_TIGROUP, NULL);
	dst_filename = create_fsel(local.cwdir, "backup", "*.tig", TRUE);

	if(!dst_filename)
	{
		g_free(src_filename);
		return;
	}

	if (!strcmp(tifiles_fext_get(dst_filename), ""))
		dst_filename2 = g_strconcat(dst_filename, ".tig", NULL);
	else
		dst_filename2 = g_strdup(dst_filename);
	//g_free((void *)dst_filename);

	if (dst_filename2)
	{
		tilp_file_move_with_check(src_filename, dst_filename2);
	}
	g_free(src_filename);
	g_free((void *)dst_filename2);

	tilp_dirlist_local();
	clist_refresh();
	labels_refresh();
}
Beispiel #2
0
static int save_group(void)
{
	char* src_filename;
	const char *dst_filename;
	const char *dst_filename2;
	char *ext;

	src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_GROUP, 
		".", tifiles_fext_of_group(options.calc_model), NULL);

	ext = g_strconcat("*.", tifiles_fext_of_group(options.calc_model), NULL);
	dst_filename = create_fsel(local.cwdir, "group", ext, TRUE);
	g_free(ext);

	if (!dst_filename)
	{
		g_free(src_filename);
		return -1;
	}

	if (!strcmp(tifiles_fext_get(dst_filename), ""))
		dst_filename2 = g_strconcat(dst_filename, ".", tifiles_fext_of_group(options.calc_model), NULL);
	else
		dst_filename2 = g_strdup(dst_filename);
	//g_free((void *)dst_filename);

	if (dst_filename2)
	{
		tilp_file_move_with_check(src_filename, dst_filename2);
	}
	g_free(src_filename);
	g_free((void *)dst_filename2);

	tilp_dirlist_local();
	clist_refresh();
	labels_refresh();

	return 0;
}
Beispiel #3
0
// Backup
TILP_EXPORT void on_tilp_button3b_clicked(GtkButton* button, gpointer user_data)
{
	char* src_filename;
	const char *dst_filename;
	const char *dst_filename2;
	char *ext;

	if (tilp_calc_recv_backup() != 0)
		return;

	src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_BACKUP, NULL);

	ext = g_strconcat("*.", tifiles_fext_of_backup(options.calc_model), NULL);
	dst_filename = create_fsel(local.cwdir, "backup", ext, TRUE);
	g_free(ext);

	if (!dst_filename)
	{
		g_free(src_filename);
		return;
	}

	if (!strcmp(tifiles_fext_get(dst_filename), ""))
		dst_filename2 = g_strconcat(dst_filename, ".", tifiles_fext_of_backup(options.calc_model), NULL);
	else
		dst_filename2 = g_strdup(dst_filename);
	//g_free((void *)dst_filename);

	if (dst_filename2)
	{
		tilp_file_move_with_check(src_filename, dst_filename2);
	}
	g_free(src_filename);
	g_free((void *)dst_filename2);

	tilp_dirlist_local();
	clist_refresh();
	labels_refresh();
}
Beispiel #4
0
TILP_EXPORT void on_rom_dump1_activate(GtkMenuItem* menuitem, gpointer user_data)
{
	char* src_filename;
	const char *dst_filename;
	const char *dst_filename2;
	char filename[128];

	if (tilp_calc_rom_dump())
		return;

	src_filename = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, TMPFILE_ROMDUMP, NULL);

	sprintf(filename, "dump%s", tifiles_model_to_string(options.calc_model));
	dst_filename = create_fsel(local.cwdir, filename, "*.rom", TRUE);
	if (!dst_filename)
	{
		g_free(src_filename);
		return;
	}

	if (!strcmp(tifiles_fext_get(dst_filename), ""))
		dst_filename2 = g_strconcat(dst_filename, ".", "rom", NULL);
	else
		dst_filename2 = g_strdup(dst_filename);
	//g_free((void *)dst_filename);

	if (dst_filename2)
	{
		tilp_file_move_with_check(src_filename, dst_filename2);
	}
	g_free(src_filename);
	g_free((void *)dst_filename2);

	tilp_dirlist_local();
	clist_refresh();
	labels_refresh();
}
Beispiel #5
0
void clist_refresh(void)
{
	GtkTreeView *view = GTK_TREE_VIEW(clist_wnd);
	GtkTreeSelection *selection;
	GtkTreeViewColumn *col;
	GtkTreeIter iter;
	GdkPixbuf *pix1, *pix2, *pix;
	GList *dirlist;
	gsize br, bw;
	gchar *utf8;
	int i;

	if(working_mode & MODE_CMD)
		return;

	// reparse folders
	tilp_local_selection_destroy();
	tilp_dirlist_local();

	selection = gtk_tree_view_get_selection(view);
	g_signal_handlers_block_by_func(G_OBJECT(selection), tree_selection_changed, NULL);
	gtk_list_store_clear(list);
	g_signal_handlers_unblock_by_func(G_OBJECT(selection), tree_selection_changed, NULL);

	// sort files
	for(i = 0; i < CLIST_NVCOLS; i++)
	{
		col = gtk_tree_view_get_column(view, i);
		gtk_tree_view_column_set_sort_indicator(col, FALSE);
	}

	switch (options.local_sort) 
	{
	case SORT_BY_NAME:
		tilp_file_sort_by_name();		
		col = gtk_tree_view_get_column(view, COLUMN_NAME);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_TYPE:
		tilp_file_sort_by_type();
		col = gtk_tree_view_get_column(view, COLUMN_TYPE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_DATE:
		tilp_file_sort_by_date();
		col = gtk_tree_view_get_column(view, COLUMN_DATE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_SIZE:
		tilp_file_sort_by_size();
		col = gtk_tree_view_get_column(view, COLUMN_SIZE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	}

	pix2 = gtk_widget_render_icon(GTK_WIDGET(view), GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
	pix1 = gtk_widget_render_icon(GTK_WIDGET(view), GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU, NULL);

	for (dirlist = local.dirlist; dirlist != NULL; dirlist = dirlist->next) 
	{
		FileEntry *fe = (FileEntry *) dirlist->data;
		gboolean b;

		CalcModel s = tifiles_file_get_model(fe->name);
		CalcModel t = options.calc_model;

		b = options.show_all || S_ISDIR(fe->attrib) ||
			tifiles_file_is_tib(fe->name) ||
#if 0
			tifiles_file_is_tigroup(fe->name) ||
#else
			tifiles_file_test(fe->name, TIFILE_TIGROUP, options.calc_model) ||
#endif
			tifiles_calc_are_compat(s, t);
		if(!b)
			continue;

		if (S_ISDIR(fe->attrib)) 
		{
			pix = strcmp(fe->name, "..") ? pix2 : pix1; 
		} 
		else 
		{
			char icon_name[2048];

			strcpy(icon_name, tifiles_file_get_icon(fe->name));

			if (!strcmp(icon_name, ""))
				strcpy(icon_name, "TIicon1");

			strcat(icon_name, ".ico");
			tilp_file_underscorize(icon_name);
			pix = create_pixbuf(icon_name);
		}

		// filenames are stored in the 'glib filename encoding' and GTK+ uses utf8
		utf8 = g_filename_to_utf8(fe->name, -1, &br, &bw, NULL);
		gtk_list_store_append(list, &iter);
		gtk_list_store_set(list, &iter, 
				   COLUMN_NAME, utf8,
				   COLUMN_TYPE, tilp_file_get_type(fe),
				   COLUMN_SIZE, tilp_file_get_size(fe),
				   COLUMN_DATE, tilp_file_get_date(fe),
				   COLUMN_DATA, (gpointer) fe, 
                   COLUMN_ICON, pix, 
                   -1);
		g_free(utf8);
	}

	g_object_unref(pix1);
	g_object_unref(pix2);
}