Example #1
0
gint display_send_files_dbox(void)
{
	const gchar *ext;
	gchar **filenames;
	static gchar *folder = NULL;
	int ret = 0;
	
	// Check for null cable
	if(linkp.cable_model != CABLE_ILP)
	{
		int err;
		gchar *str;

		str = g_strdup_printf(_("The current link cable <%s> port <%s> does not allow direct file loading. Do you let me change link port settings to allow direct file loading?"),
			ticables_model_to_string(linkp.cable_model), ticables_port_to_string(linkp.cable_port));
		
		ret= msg_box2(_("Warning"), str);
		g_free(str);
		
		if(ret == BUTTON2)
			return -1;

		// reconfigure link port
		ti68k_linkport_unconfigure();

		linkp.cable_model = CABLE_ILP;
		linkp.cable_port = PORT_0;

        err = ti68k_linkport_reconfigure();
		handle_error();
	}

    // set mask
    switch(tihw.calc_type) 
	{
    case TI92:
        ext = "*.92?";
		break;
	default:
        ext = "*.89?;*.92?;*.9x?;*.9X?;*.v2?;*.V2?;*.tig";
        break;
    }

	// get filename
	if(folder == NULL)
		folder = g_strdup(inst_paths.base_dir);

	filenames = create_fsels(folder, NULL, (char *)ext);
	if(!filenames)
		return 0;

	// keep folder
	g_free(folder);
	folder = g_path_get_dirname(filenames[0]);

	ret = fs_send_files(filenames);
	g_strfreev(filenames);

	return ret;
}
Example #2
0
gint display_device_dbox()
{
	GladeXML *xml;
	GtkWidget *dbox;
	GtkWidget *data;
	gint result;
	int err;

	xml = glade_xml_new(tilp_paths_build_glade("device-2.glade"), "device_dbox", PACKAGE);
	if (!xml)
		g_error(_("comm.c: GUI loading failed !\n"));
	glade_xml_signal_autoconnect(xml);

	dbox = glade_xml_get_widget(xml, "device_dbox");
	gtk_dialog_set_alternative_button_order(GTK_DIALOG(dbox), GTK_RESPONSE_OK,
	                                        GTK_RESPONSE_CANCEL,-1);

	lbl = glade_xml_get_widget(xml, "label7");

	// Cable  
	data = comm_cable = glade_xml_get_widget(xml, "combobox1");
	switch (linkp.cable_model) 
	{
	case CABLE_NUL:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 0);
	break;

	case CABLE_GRY:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 1);
	break;
		
	case CABLE_BLK:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 2);
	break;

	case CABLE_PAR:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 3);
	break;

	case CABLE_SLV:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 4);
	break;	

	case CABLE_USB:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 5);
	break;	

	case CABLE_VTI:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 6);
	break;

    case CABLE_TIE:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 7);
	break;
	
	case CABLE_ILP:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 8);
	break;

	default:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 0);
	break;
	}

	// Port
	data = comm_port = glade_xml_get_widget(xml, "combobox2");
	switch (linkp.cable_port) 
	{
	case PORT_0:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 0);
	break;
	case PORT_1:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 1);
	break;
	case PORT_2:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 2);
	break;
	case PORT_3:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 3);
	break;
	case PORT_4:
		gtk_combo_box_set_active(GTK_COMBO_BOX(data), 4);
	break;
	}

	// Timeout
	data = glade_xml_get_widget(xml, "spinbutton_comm_timeout");
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(data), linkp.cable_timeout);
	
	// Delay
	data = glade_xml_get_widget(xml, "spinbutton_comm_delay");
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(data), linkp.cable_delay);

	// Data exchange
	memcpy(&tmp, &linkp, sizeof(DeviceOptions));
	memcpy(&old, &linkp, sizeof(DeviceOptions));
	
	// Loop
	result = gtk_dialog_run(GTK_DIALOG(dbox));
	switch (result) 
	{
	case GTK_RESPONSE_CANCEL:
		break;
	case GTK_RESPONSE_OK:
		ti68k_linkport_unconfigure();

		data = glade_xml_get_widget(xml, "spinbutton_comm_delay");
		tmp.cable_delay = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data));

		data = glade_xml_get_widget(xml, "spinbutton_comm_timeout");
		tmp.cable_timeout =	gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data));

		memcpy(&linkp, &tmp, sizeof(DeviceOptions));
		tmp.calc_model = ti68k_calc_to_libti_calc();

        err = ti68k_linkport_reconfigure();
		if(err)
		{
			// if reconfiguring fails, fallback to null cable & port
			ti68k_linkport_unconfigure();

			memcpy(&linkp, &old, sizeof(DeviceOptions));
			tmp.calc_model = ti68k_calc_to_libti_calc();

			ti68k_linkport_reconfigure();
		}
		break;
	case GTK_RESPONSE_HELP:
		break;
	default:
		break;
	}
	gtk_widget_destroy(dbox);
	return 0;
}