Пример #1
0
static void tree_selection_changed(GtkTreeSelection* selection, gpointer user_data)
{
	GList *_list;
	GtkTreeIter iter;
	GtkTreeModel *model;
	GtkTreeSelection *sel;

	// destroy selection
	tilp_local_selection_destroy();

	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(ctree_wnd));

	// create local selection
	for(_list = gtk_tree_selection_get_selected_rows(selection, &model); _list; _list = g_list_next(_list))
	{
		GtkTreePath *path = _list->data;
		FileEntry *fe;

		gtk_tree_model_get_iter(model, &iter, path);
		gtk_tree_model_get(model, &iter, COLUMN_DATA, &fe, -1);
		tilp_local_selection_add(fe->name);

	}

	g_list_foreach(_list, (GFunc)gtk_tree_path_free, NULL);
	g_list_free(_list);

	// create file selection
	_list = gtk_tree_selection_get_selected_rows(selection, &model);
	if(_list)
	{
		tilp_file_selection_destroy();

		for(; _list; _list = g_list_next(_list))
		{
			GtkTreePath *path = _list->data;
			FileEntry *fe;
			gchar *full_path;

			gtk_tree_model_get_iter(model, &iter, path);
			gtk_tree_model_get(model, &iter, COLUMN_DATA, &fe, -1);

			full_path = g_strconcat(local.cwdir, G_DIR_SEPARATOR_S, fe->name, NULL);
			tilp_file_selection_add(full_path);
		}

		g_list_foreach(_list, (GFunc)gtk_tree_path_free, NULL);
		g_list_free(_list);
	}
}
Пример #2
0
// Send
TILP_EXPORT void on_tilp_button6_clicked(GtkButton* button, gpointer user_data)
{
	gchar** filenames;
	gchar** ptr;
	char *ext;

	ext = g_strconcat("*.", "*", NULL);
	filenames = create_fsels(local.cwdir, NULL, ext);
	g_free(ext);

	if(filenames == NULL)
		return;

	for(ptr = filenames; *ptr != NULL; ptr++)
		tilp_local_selection_add(*ptr);

	g_strfreev(filenames);

	on_tilp_send("");
	tilp_local_selection_destroy();
}
Пример #3
0
// retrieve data
TILP_EXPORT void
on_treeview1_drag_data_received(GtkWidget * widget,
				GdkDragContext * drag_context,
				gint x,
				gint y,
				GtkSelectionData * data,
				guint info, guint _time, gpointer user_data)
{
	GtkTreeView *view = GTK_TREE_VIEW(widget);
	GtkTreeModel *model = gtk_tree_view_get_model(view);
	GtkTreePath *path;
	GtkTreeViewDropPosition pos;
	GtkTreeIter iter;
	VarEntry *ve;
	gchar *name;
	gchar *target = NULL;
	gboolean success = FALSE;

	if ((data->length >= 0) && (data->format == 8))
	{
		if (drag_context->action == GDK_ACTION_ASK)
		{
			drag_context->action = GDK_ACTION_COPY;
		}

		if (info == TARGET_TEXT_URI_LIST)
		{
			int i;
			gchar **list;
			//list = g_uri_list_extract_uris((gchar *)gtk_selection_data_get_data(data));
			list = gtk_selection_data_get_uris(data);
			tilp_local_selection_destroy();
			for (i = 0;list[i] != NULL; i++)
			{
				name = g_filename_from_uri(list[i], NULL, NULL);
				tilp_local_selection_add(name);
			}
			g_strfreev(list);
		}

		gtk_tree_view_get_dest_row_at_pos(view, x, y, &path, &pos);
		if (path == NULL)
			goto end;
		gtk_tree_model_get_iter(model, &iter, path);
		gtk_tree_model_get(model, &iter, COLUMN_DATA, &ve, -1);
		gtk_tree_model_get(model, &iter, COLUMN_NAME, &name, -1);

		//g_print("Received \"%s\" as selection information.\n", name);

		if(strchr(name, '#'))			// Calc
		{
		}
		else if(!strcmp(name, NODE4))	// Applications
		{
			// send to flash
			target=(char *)"<FLASH>";
		}
		else if (ve && tifiles_has_folder(options.calc_model))
		{
			// send to folder
			if(!strcmp(ve->folder, ""))
				target = ve->name;
			else
				target = ve->folder;
		}
		else if(!strcmp(name, NODE2))	// Operating System
		{
			target=(char *)"";
		}
		else
		{
			if(options.calc_model == CALC_NSPIRE)
			{
				gif->msg_box1(_("Error"), "You have to drag&drop to a target folder!");
				return;
			}
			else
			{
				// send standard
				target=(char *)"";
			}
		}

		if (target!=NULL)
			on_tilp_send(target);

		tilp_local_selection_destroy();
		success = TRUE;
	}
end:
	gtk_drag_finish(drag_context, success, FALSE, _time);
	return;
}
Пример #4
0
/* Search for command line options and build file list (pseudo-selection) */
int tilp_cmdline_scan(int *argc, char ***argv)
{
	GOptionContext* context;
	GError *error = NULL;
	gint ret = 0;

	// parse command line
	context = g_option_context_new ("- Tilp Is a Linking Program");
	g_option_context_add_main_entries(context, entries, ""/*GETTEXT_PACKAGE*/);
	g_option_context_set_help_enabled(context, TRUE);
	g_option_context_set_ignore_unknown_options(context, FALSE);
	g_option_context_parse(context, argc, argv, &error);
	g_option_context_free(context);

	// report error
	if (error) 
	{
		tilp_warning("Failed to parse cmdline: %s\n", error->message);
		g_error_free(error);
	}

	if(show_version)
	{
		exit(0);
	}

	// convert name to value
	if(calc != NULL)
	{
		options.calc_model = ticalcs_string_to_model(calc);
		g_free(calc);
	}

	// convert name to value
	if(cable != NULL)
	{
		options.cable_model = ticables_string_to_model(cable);
		g_free(cable);
	}

	// look for short-options
	if(array != NULL)
	{
		gchar **p;
		gint len;
		int i;

		// check for no extensions
		for(p = array, len = 0; *p != NULL; p++, len++)
		{
			if(strrchr(*p, '.') == NULL)
			{
				for(i = 0; i < CABLE_MAX; i++)
				{
					if(!g_strcasecmp(ticables_model_to_string(i), *p))
						options.cable_model = i;
				}

				for(i = 0; i < CALC_MAX; i++)
				{
					if(!g_strcasecmp(ticalcs_model_to_string(i), *p))
						options.calc_model = i;
				}
			}
		}
	}

	// remap for USB handhelds
	options.calc_model = ticalcs_remap_model_to_usb(options.cable_model, options.calc_model);

	if(!options.cable_port)
	{
		switch(options.cable_model)
		{
		case CABLE_VTI:
		case CABLE_TIE:
			options.cable_port = PORT_0;
			break;
		default:
			options.cable_port = PORT_1;
			break;
		}
	}

	// are files passed ?
	if(array != NULL)
	{
		gchar **p, **q;
		gint len;

		working_mode = MODE_CMD;

		// count files
		for(p = array, len = 0; *p != NULL; p++, len++);

		// allocate list of files
		flist = g_malloc0((len + 1) * sizeof(gchar *));

		// rebuild a list of file with full path
		for(p = array, q = flist; *p != NULL; p++, q++)
		{
			// skip short-options
			if(strrchr(*p, '.') == NULL)
			{
				q--;
				continue;
			}

			// check whether path is local or absolute
			if (!g_path_is_absolute(*p))
				*q = g_strconcat(g_get_current_dir(), G_DIR_SEPARATOR_S, *p, NULL);
			else
				*q = g_strdup(*p);
		}

		// build a pseudo file selection for TiLP
		for(q = flist; *q != NULL; q++)
		{
			if(g_file_test(*q, G_FILE_TEST_EXISTS))
			{
				tilp_local_selection_add(*q);
			}
			else
			{
				gchar *str;

				str = g_strdup_printf(_("The file <%s> does not exist."), *q);
				gif->msg_box1(_("Error"), str);
				g_free(str);
				ret = -1;
			}
		}

		g_strfreev(array);
		g_strfreev(flist);
	}

	// don't use GUI ?
	if(dont_use_gui)
		working_mode &= ~MODE_GUI;
	else
		working_mode |= MODE_GUI;

	return ret;
}